Skip to content

Commit

Permalink
build: fix the main Gradle build file
Browse files Browse the repository at this point in the history
  • Loading branch information
flelli committed Nov 7, 2024
1 parent a416e79 commit f52185d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 59 deletions.
60 changes: 38 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block
------------------------------------------------------------------------------*/
plugins {
// Enable the SonarCloud plugin.
// This creates the 'sonar' task
// See: https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-gradle/
id "org.sonarqube" version "4.4.1.3373"

// Builds a dependency tree of Gradle tasks, i.e. 'gradle <task> taskTree'
// (at times it doesn't work when using the ./gradlew wrapper).
// This plugin can be commented out and used only when needed.
// See: https://github.com/dorongold/gradle-task-tree
id "com.dorongold.task-tree" version "4.0.0"
// Enable the SonarCloud plugin.
// This creates the 'sonar' task
// See: https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-gradle/
id "org.sonarqube" version "4.4.1.3373"

// Builds a dependency tree of Gradle tasks, i.e. 'gradle <task> taskTree'
// (at times it doesn't work when using the ./gradlew wrapper).
// This plugin can be commented out and used only when needed.
// See: https://github.com/dorongold/gradle-task-tree
id "com.dorongold.task-tree" version "4.0.0"
}

import groovy.json.JsonSlurper
Expand All @@ -31,17 +31,26 @@ allprojects {
// See: https://docs.gradle.org/current/userguide/base_plugin.html
apply plugin: 'base'

afterEvaluate {
// Only perform publishing if the Nyx release type enables publishing.
tasks.matching {
it.group.equals('publishing')
}.all {
it.onlyIf { rootProject.nyxState.newRelease }
}
}

/*------------------------------------------------------------------------------
Extension configurations
------------------------------------------------------------------------------*/
// Configure SonarCloud
// See: https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-gradle/
sonarqube {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "mooltiverse"
property "sonar.verbose", true
}
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "mooltiverse"
property "sonar.verbose", true
}
}

// This task is useful to run all verification tasks (check, test but also functionalTest and integrationTest)
Expand All @@ -50,8 +59,8 @@ allprojects {
group 'Verification'

dependsOn project.tasks.matching {
// skip this task itself to avoid circular dependencies
it.group.equals('verification') && !it.name.equals('verify')
// skip this task itself to avoid circular dependencies
it.group.equals('verification') && !it.name.equals('verify')
}
}

Expand All @@ -73,8 +82,8 @@ allprojects {
This is the configuration for all sub-projects
------------------------------------------------------------------------------*/
subprojects {
// let all sub projects have the same version as the root project
version = rootProject.version
// let all sub projects have the same version as the root project
version = rootProject.version
}

/*------------------------------------------------------------------------------
Expand All @@ -83,9 +92,9 @@ subprojects {
// Configure SonarCloud
// See: https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarscanner-for-gradle/
sonarqube {
properties {
property "sonar.projectKey", "mooltiverse_nyx"
}
properties {
property "sonar.projectKey", "mooltiverse_nyx"
}
}

/*------------------------------------------------------------------------------
Expand Down Expand Up @@ -201,3 +210,10 @@ task testClean() {

dependsOn deleteTestDirectories, deleteGitHubTestProjects, deleteGitLabTestProjects
}

/*------------------------------------------------------------------------------
Additional task dependencies
------------------------------------------------------------------------------*/
// Only perform publishing if the Nyx release type enables publishing.
tasks.nyxMark.onlyIf { rootProject.nyxState.newRelease }
tasks.nyxPublish.onlyIf { rootProject.nyxState.newRelease }
12 changes: 0 additions & 12 deletions modules/go/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,6 @@ subprojects {
tasks.assemble.dependsOn tasks.goBuild
tasks.test.dependsOn tasks.goTest
tasks.check.dependsOn tasks.test

afterEvaluate {
// Only perform publishing if the Nyx release type enables publishing
// Remember that setting the 'onlyIf' on a task does not prevent its dependencies
// to run so the tasks of the entire tree must be disabled
// This is why we set the onlyIf to all tasks in the Publish group
tasks.matching {
it.group.equals('publishing')
}.all {
it.onlyIf { rootProject.nyxState.newRelease }
}
}
}

/*------------------------------------------------------------------------------
Expand Down
12 changes: 0 additions & 12 deletions modules/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,6 @@ allprojects.each {prj ->
}
}
}

afterEvaluate {
// Only perform publishing if the Nyx release type enables publishing
// Remember that setting the 'onlyIf' on a task does not prevent its dependencies
// to run so the tasks of the entire tree must be disabled
// This is why we set the onlyIf to all tasks in the Publish group
tasks.matching {
it.group.equals('publishing')
}.all {
it.onlyIf { rootProject.nyxState.newRelease }
}
}
}

/*------------------------------------------------------------------------------
Expand Down
16 changes: 3 additions & 13 deletions modules/java/gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,7 @@ tasks.publish.dependsOn tasks.publishPlugins
tasks.test.dependsOn project(':modules:java:main').tasks.test

afterEvaluate {
// Only perform publishing if the Nyx release type enables publishing
// Remember that setting the 'onlyIf' on a task does not prevent its dependencies
// to run so the tasks of the entire tree must be disabled
// This is why we set the onlyIf to all tasks in the Publish group
tasks.matching {
it.group.equals('publishing')
}.all {
it.onlyIf { rootProject.nyxState.newRelease }
}

// The tasks listed here are those not caught in the section above
tasks.publish.onlyIf { rootProject.nyxState.newRelease } // this actually belongs to the 'publishing' group but doesn't get captured by the above section for some reason
tasks.publishPlugins.onlyIf { rootProject.nyxState.newRelease } // from the 'plugin portal' group
// The tasks listed here are those not caught in the section above
tasks.publish.onlyIf { rootProject.nyxState.newRelease } // this actually belongs to the 'publishing' group but doesn't get captured by the above section for some reason
tasks.publishPlugins.onlyIf { rootProject.nyxState.newRelease } // from the 'plugin portal' group
}

0 comments on commit f52185d

Please sign in to comment.