From cdff92df41b49fecc1d4d31f650ca4d9bbf127c6 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 5 Jul 2024 18:57:07 +0200 Subject: [PATCH 1/4] fix: disable sonar implicit compilation --- .github/workflows/build.yml | 2 +- helper.gradle | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcbfc14..c8a399e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Analyze if: ${{ inputs.sonarqube == true }} - run: ./gradlew sonar + run: ./gradlew assemble sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/helper.gradle b/helper.gradle index 52994f5..0c6762c 100644 --- a/helper.gradle +++ b/helper.gradle @@ -334,6 +334,7 @@ tasks.register('codeCoverageReport', JacocoReport) { } ext.enableSonarQube = (String projectKey, String organization = "refinedmods") -> { + System.setProperty("sonar.gradle.skipCompile", "true") apply plugin: org.sonarqube.gradle.SonarQubePlugin // https://docs.sonarqube.org/latest/analysis/github-integration/ sonarqube { From 078b2a9b1b8bc5ddbc32e1e674008f4bbe036091 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 5 Jul 2024 18:58:21 +0200 Subject: [PATCH 2/4] ci: upgrade wrapper validation action --- .github/actions/setup-java/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-java/action.yml b/.github/actions/setup-java/action.yml index 60cd5e8..8cfe99e 100644 --- a/.github/actions/setup-java/action.yml +++ b/.github/actions/setup-java/action.yml @@ -4,7 +4,7 @@ runs: using: "composite" steps: - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/actions/wrapper-validation@v3 - name: Setup JDK 21 uses: actions/setup-java@v4 with: From 2c0ab1df41b730238166dd6f7b4f00631f166302 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 5 Jul 2024 18:59:32 +0200 Subject: [PATCH 3/4] ci: upgrade cache action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8a399e..65027c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: # https://docs.sonarqube.org/latest/analysis/github-integration/ - name: Cache SonarQube packages if: ${{ inputs.sonarqube == true }} - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar From cc9ad824478ab01574b1463fb23d22ad73a0c9be Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Fri, 5 Jul 2024 19:03:03 +0200 Subject: [PATCH 4/4] build: switch to moddevgradle Thanks to shartte. See: https://github.com/refinedmods/refinedstorage2/pull/592 --- CHANGELOG.md | 6 +++ helper.gradle | 106 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ecdca5..f187425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + +- Switched from NeoGradle to ModDevGradle. +- Upgrade cache and Gradle wrapper validation actions. +- Disable implicit compilation in Sonar Gradle plugin. + ## [0.14.3] - 2024-07-03 ### Fixed diff --git a/helper.gradle b/helper.gradle index 0c6762c..c01d55d 100644 --- a/helper.gradle +++ b/helper.gradle @@ -21,11 +21,11 @@ buildscript { dependencies { classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0' classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373' - classpath 'org.spongepowered:vanillagradle:0.2.1-SNAPSHOT' - classpath 'net.neoforged.gradle:userdev:7.0.152' classpath 'fabric-loom:fabric-loom.gradle.plugin:1.7-SNAPSHOT' classpath 'net.darkhax.curseforgegradle:CurseForgeGradle:1.1.18' classpath 'com.modrinth.minotaur:Minotaur:2.+' + // https://projects.neoforged.net/neoforged/ModDevGradle + classpath 'net.neoforged:moddev-gradle:0.1.122' } } @@ -84,6 +84,8 @@ allprojects { ext { minecraftVersion = "1.21" + // See: https://projects.neoforged.net/neoforged/neoform + neoFormVersion = "1.21-20240613.152323" forgeVersion = "21.0.42-beta" fabricLoaderVersion = "0.15.11" fabricApiVersion = "0.100.4+1.21" @@ -165,9 +167,10 @@ allprojects { } ext.commonProject = { - apply plugin: org.spongepowered.gradle.vanilla.VanillaGradle - minecraft { - version(minecraftVersion) + apply plugin: net.neoforged.moddevgradle.boot.ModDevPlugin + neoForge { + neoFormVersion = rootProject.neoFormVersion + addModdingDependenciesTo(project.sourceSets.test) } sourceSets { main.resources.srcDirs += 'src/generated/resources' @@ -178,64 +181,81 @@ allprojects { } ext.forgeProject = { String modId, Project commonProject = null, ArrayList apis = [], ArrayList compileApis = [] -> - apply plugin: net.neoforged.gradle.userdev.UserDevPlugin - if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) { - minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg') - } - runs { - configureEach { - modSource project.sourceSets.main - } - client { - systemProperty 'neoforge.enabledGameTestNamespaces', modId - } - server { - systemProperty 'neoforge.enabledGameTestNamespaces', modId - programArgument '--nogui' - } - gameTestServer { - systemProperty 'neoforge.enabledGameTestNamespaces', modId - modSource project.sourceSets.test + apply plugin : net.neoforged.moddevgradle.boot.ModDevPlugin + + neoForge { + version = forgeVersion + // The test source set does not inherit any "local" dependencies of main + // this ensures Minecraft classes are available to it. + addModdingDependenciesTo(project.sourceSets.test) + mods { + "${modId}" { + modSourceSets = [project.sourceSets.main, project.sourceSets.test] + for (var api : apis) { + modSourceSets.add(project(api).sourceSets.main) + } + for (var api : compileApis) { + modSourceSets.add(project(api).sourceSets.main) + } + if (commonProject != null) { + modSourceSets.add(commonProject.sourceSets.main) + } + } } - data { - var destinationProject = commonProject != null ? commonProject : project - var existingProject = commonProject != null ? commonProject : project - programArguments.addAll '--mod', modId, '--all', '--output', destinationProject.file('src/generated/resources/').getAbsolutePath(), '--existing', existingProject.file('src/main/resources/').getAbsolutePath() + runs { + client { + client() + systemProperty 'neoforge.enabledGameTestNamespaces', modId + } + server { + server() + systemProperty 'neoforge.enabledGameTestNamespaces', modId + programArgument '--nogui' + } + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', modId + sourceSet = project.sourceSets.test + } + data { + data() + var destinationProject = commonProject != null ? commonProject : project + var existingProject = commonProject != null ? commonProject : project + programArguments.addAll '--mod', modId, '--all', '--output', destinationProject.file('src/generated/resources/').getAbsolutePath(), '--existing', existingProject.file('src/main/resources/').getAbsolutePath() + } } } dependencies { - implementation "net.neoforged:neoforge:${forgeVersion}" testImplementation "net.neoforged:testframework:${forgeVersion}" apis.collect { - implementation project(it) + compileOnly project(it) + testCompileOnly project(it) } compileApis.collect { - implementation project(it) + compileOnly project(it) + testCompileOnly project(it) } if (commonProject != null) { - implementation commonProject + compileOnly commonProject + testCompileOnly commonProject } } sourceSets { main.resources.srcDirs += 'src/generated/resources' } - processResources { - if (commonProject != null) { - from commonProject.sourceSets.main.resources - } - from project.sourceSets.main.resources - } - Spec notNeoTask = { Task t -> !t.name.startsWith("neo") } as Spec - tasks.withType(JavaCompile).matching(notNeoTask).configureEach { + tasks.withType(Jar).configureEach { + duplicatesStrategy = "exclude" apis.collect { - source(project(it).sourceSets.main.allSource) + from(project(it).sourceSets.main.output) } compileApis.collect { - source(project(it).sourceSets.main.allSource) + from(project(it).sourceSets.main.output) } if (commonProject != null) { - source(commonProject.sourceSets.main.allSource) + from(commonProject.sourceSets.main.output) } + // These come in from the common API jars but should not end up in the neoforge jar + excludes = ['fabric.mod.json'] } } @@ -345,4 +365,4 @@ ext.enableSonarQube = (String projectKey, String organization = "refinedmods") - property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/codeCoverageReport/codeCoverageReport.xml" } } -} \ No newline at end of file +}