diff --git a/.github/gradle/gradle.gradle b/.github/gradle/gradle.gradle index d665ffd71..9e584e7cd 100644 --- a/.github/gradle/gradle.gradle +++ b/.github/gradle/gradle.gradle @@ -1,18 +1,94 @@ +import groovy.json.JsonBuilder +import groovy.transform.CompileStatic + if (!project.hasProperty('githubCiTesting') && System.env['GITHUB_OUTPUT'] == null) { // If the property is not set and we are not running in the CI environment then we will do nothing return } -static def outputUnitTest(Project project, Task test) { - project.getLogger().lifecycle("<< TEST >>${test.path}") +static Map removeCommonPrefix(List list) { + if (list.size() == 0) { + return [:] + } + + def result = new HashMap() + + if (list.unique(false).size() == 1) { + def sections = list[0].split("\\.") + result.put(list[0], sections.last()) + return result + } + + Collections.sort(list, { String a, String b -> a.length() - b.length() }) + def max = list[0].length() + def prefix = "" + + for(int index = 0; index < max; index++) { + def currentChar = list[0][index] + for (String item : list) { + if (item[index] != currentChar) { + for (final def entry in list) { + result.put(entry, entry.substring(prefix.length())) + } + return result + } + } + + prefix += currentChar + } + + throw new IllegalArgumentException("Could not remove common prefix: ${list}") } -static def outputClassTest(Project project, Task test, String className) { - project.getLogger().lifecycle("<< TEST >>${test.path} --tests \"${className}\"") +static String createDisplayNameSuffix(String path, String filter) { + //The path starts with a : and then the project name: + path = path.substring(path.indexOf(":") + 1) + + //Now split the path into parts + def parts = path.split(":") + def capitalizedParts = parts.collect { it.capitalize() } + + //Combine the parts with -> + path = capitalizedParts.join(" -> ") + + if (filter === null) { + return path + } + + //Next the filter has its common prefix stripped, is however still in domain name form + def filterParts = filter.split("\\.") + def capitalizedFilterParts = filterParts.collect { it.capitalize() } + filter = capitalizedFilterParts.join("/") + + return "${path} (${filter})" +} + +static List createTestRuns(Task it, List testClasses) { + def testRuns = [] + if (testClasses.size() == 0) { + testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, null)}", path: it.path, filter: null)) + return testRuns + } + + def testClassesWithoutCommonPrefix = removeCommonPrefix(testClasses) + testClassesWithoutCommonPrefix.forEach { className, displayName -> + testRuns.add(new TestRun(displayName: "Test - ${createDisplayNameSuffix(it.path, displayName)}", path: it.path, filter: className)) + } + + return testRuns +} + +@CompileStatic +class TestRun { + String displayName + String path + String filter } subprojects.forEach { Project subProject -> subProject.tasks.register('determineTests') { Task it -> + def tests = [] + it.group = 'infrastructure' it.doLast { subProject.tasks.withType(Test).forEach { Task test -> @@ -20,22 +96,24 @@ subprojects.forEach { Project subProject -> if (testSourceSetCandidate != null) { SourceSet testSourceSet = testSourceSetCandidate as SourceSet + def testClasses = [] + testSourceSet.java.srcDirs .collect { File file -> subProject.fileTree(file.parentFile) } .collect { FileTree fileTree -> - return fileTree.matching { - include '**/*Test.java' - include '**/*Tests.java' - include '**/*Test.groovy' - include '**/*Tests.groovy' + return fileTree.matching { PatternFilterable pattern -> + pattern.include '**/*Test.java' + pattern.include '**/*Tests.java' + pattern.include '**/*Test.groovy' + pattern.include '**/*Tests.groovy' } } .forEach { it.visit { FileVisitDetails details -> if (details.isDirectory()) - return; + return String className = details.relativePath.pathString .replace("groovy/", "") @@ -44,14 +122,19 @@ subprojects.forEach { Project subProject -> .replace(".java", "") .replace("/", ".") - outputClassTest(subProject, test, className) + testClasses.add(className) } } + tests.addAll(createTestRuns(test, testClasses)) } else { - outputUnitTest(subProject, test) + tests.addAll(createTestRuns(test, new ArrayList())) } } + + if (!tests.isEmpty()) { + project.getLogger().lifecycle("<< TEST >>${new JsonBuilder(tests)}") + } } } } diff --git a/.github/scripts/collect-tests.sh b/.github/scripts/collect-tests.sh index 88367d47c..1f5be0a32 100755 --- a/.github/scripts/collect-tests.sh +++ b/.github/scripts/collect-tests.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' > ./tasks -TESTS=$(cat tasks | jq --raw-input . | jq --compact-output --slurp .) +TESTS=$(./gradlew determineTests | grep -e '<< TEST >>' | sed -e 's/<< TEST >>//g' | jq -s 'add' | jq -c .) # Check if the GITHUB_OUTPUT is set if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command diff --git a/.github/workflows/test-prs.yml b/.github/workflows/test-prs.yml index 4e7afb9a3..d41cb6846 100644 --- a/.github/workflows/test-prs.yml +++ b/.github/workflows/test-prs.yml @@ -9,6 +9,10 @@ on: - ready_for_review - reopened +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: setup: name: Setup @@ -62,13 +66,15 @@ jobs: run: ./gradlew --info -s -x assemble test: - name: Test - runs-on: ubuntu-latest + name: "${{ matrix.test.displayName }} (${{ matrix.os }})" + runs-on: "${{ matrix.os }}-latest" needs: setup strategy: + max-parallel: 15 fail-fast: false matrix: test: ${{ fromJSON(needs.setup.outputs.tests-to-run) }} + os: [ubuntu, windows, macos] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -83,10 +89,15 @@ jobs: distribution: 'microsoft' - name: Setup Gradle - uses: gradle/gradle-build-action@v3 + uses: gradle/actions/setup-gradle@v3 - name: Test - run: ./gradlew --info -s ${{ matrix.test }} + if: ${{ matrix.test.filter != null }} + run: ./gradlew --info -s ${{ matrix.test.path }} --tests "${{ matrix.test.filter }}" + + - name: Test + if: ${{ matrix.test.filter == null }} + run: ./gradlew --info -s ${{ matrix.test.path }} # Always upload test results - name: Merge Test Reports @@ -94,34 +105,61 @@ jobs: run: npx junit-report-merger junit.xml "**/TEST-*.xml" - name: Format test run name as artifact name - id: format-artifact-name + if: (success() || failure()) && runner.os == 'Windows' + id: format-artifact-name-windows + # Use the GITHUB_OUTPUT mechanic to set the output variable + run: | + # We need to remove all invalid characters from the test name: + # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / + $NAME = "${{ matrix.test.displayName }}" -replace '[":<>|*?\\/]', '-' -replace ' ', '' + + # Check if the GITHUB_OUTPUT is set + Write-Output "Determined name to be $NAME-${{ matrix.os }}" + if ([string]::IsNullOrEmpty($env:GITHUB_OUTPUT)) { + # We do not have github output, then use the set output command + Write-Output "::set-output name=artifact-name::$NAME-${{ matrix.os }}" + exit + } + Add-Content -Path $env:GITHUB_OUTPUT -Value "artifact-name=$NAME-${{ matrix.os }}" + + - name: Format test run name as artifact name + if: (success() || failure()) && runner.os != 'Windows' + id: format-artifact-name-unix # Use the GITHUB_OUTPUT mechanic to set the output variable run: | - # We have two cases here, one with a gradle task path, there we replace the : with a - and strip the leading - - # The other case is complexer, again we replace the : with a - and strip the leading - but now we also remove the ' --tests ' part - # Remove the '"' from the string and replace the '.' with a '-' - NAME=$(echo "${{ matrix.test }}" | sed 's/:/-/g' | sed 's/^-//' | sed 's/ --tests /-/g' | sed 's/"//g' | sed 's/\./-/g') + # We need to remove all invalid characters from the test name: + # Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n, Backslash \, Forward slash / + NAME=$(echo "${{ matrix.test.displayName }}" | tr '":<>|*?\\/' '-' | tr -d ' ') # Check if the GITHUB_OUTPUT is set + echo "Determined name to be $NAME-${{ matrix.os }}" if [ -z "$GITHUB_OUTPUT" ]; then # We do not have github output, then use the set output command - echo "::set-output name=artifact-name::$NAME" + echo "::set-output name=artifact-name::$NAME-${{ matrix.os }}" exit 0 fi - echo "artifact-name=$NAME" >> "$GITHUB_OUTPUT" + echo "artifact-name=$NAME-${{ matrix.os }}" >> "$GITHUB_OUTPUT" + - uses: actions/upload-artifact@v4 + if: (success() || failure()) && runner.os != 'Windows' + with: + if-no-files-found: ignore + name: test-results-${{ steps.format-artifact-name-unix.outputs.artifact-name }} + path: junit.xml + retention-days: 1 - uses: actions/upload-artifact@v4 - if: success() || failure() + if: (success() || failure()) && runner.os == 'Windows' with: if-no-files-found: ignore - name: test-results-${{ steps.format-artifact-name.outputs.artifact-name }} + name: test-results-${{ steps.format-artifact-name-windows.outputs.artifact-name }} path: junit.xml retention-days: 1 process-test-data: + name: Process Test Data runs-on: ubuntu-latest needs: test - if: success() || failure() + if: always() steps: - uses: actions/checkout@v3 @@ -133,16 +171,29 @@ jobs: - name: Publish Test Report uses: mikepenz/action-junit-report@v4 - if: success() || failure() # always run even if the previous step fails + if: always() # always run even if the previous step fails with: report_paths: '**/*.xml' - name: Merge Test Reports - if: success() || failure() + if: always() run: npx junit-report-merger junit.xml "**/*.xml" - uses: actions/upload-artifact@v4 - if: success() || failure() + if: always() with: name: test-results path: junit.xml + + - name: Failed build detection + uses: actions/github-script@v7 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + || contains(needs.*.result, 'skipped') + }} + with: + script: | + core.setFailed('Test build failure!') + diff --git a/build.gradle b/build.gradle index 6662bb0b3..650c2710f 100644 --- a/build.gradle +++ b/build.gradle @@ -163,6 +163,7 @@ subprojects.forEach { subProject -> spec.exclude group: 'org.codehaus.groovy' } evalSubProject.dependencies.functionalTestImplementation "net.neoforged.trainingwheels:gradle-functional:${project.trainingwheels_version}" + evalSubProject.dependencies.functionalTestImplementation project(':test-utils') //Configure the plugin metadata, so we can publish it. evalSubProject.gradlePlugin.plugins { NamedDomainObjectContainer plugins -> diff --git a/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java b/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java index a43ede574..ec84a5072 100644 --- a/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java +++ b/common/src/main/java/net/neoforged/gradle/common/CommonPlugin.java @@ -2,12 +2,12 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; +import org.jetbrains.annotations.NotNull; public class CommonPlugin implements Plugin { @Override - public void apply(Object o) { - if (o instanceof Project) { - final Project project = (Project) o; + public void apply(@NotNull Object o) { + if (o instanceof Project project) { project.getPluginManager().apply(CommonProjectPlugin.class); } else { throw new IllegalArgumentException("CommonPlugin can only be applied to a project"); diff --git a/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java b/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java index e33e84ec5..586b0052d 100644 --- a/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java +++ b/common/src/main/java/net/neoforged/gradle/common/CommonProjectPlugin.java @@ -116,7 +116,7 @@ public void apply(Project project) { project.getRepositories().maven(e -> { e.setUrl(UrlConstants.MOJANG_MAVEN); - e.metadataSources(MavenArtifactRepository.MetadataSources::artifact); + e.metadataSources(MavenArtifactRepository.MetadataSources::mavenPom); }); project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> { diff --git a/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java b/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java index 7ba8754cc..db241d321 100644 --- a/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java +++ b/common/src/main/java/net/neoforged/gradle/common/util/ToolUtilities.java @@ -1,12 +1,10 @@ package net.neoforged.gradle.common.util; -import net.neoforged.gradle.dsl.common.extensions.repository.Repository; import net.neoforged.gradle.dsl.common.util.ConfigurationUtils; import net.neoforged.gradle.util.ModuleDependencyUtils; import org.gradle.api.Project; import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ResolvedArtifact; -import org.gradle.api.artifacts.repositories.ArtifactRepository; import java.io.File; import java.util.function.Supplier; @@ -18,7 +16,7 @@ private ToolUtilities() { } public static File resolveTool(final Project project, final String tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), project.getDependencies().create(tool) @@ -26,7 +24,7 @@ public static File resolveTool(final Project project, final String tool) { } public static ResolvedArtifact resolveToolArtifact(final Project project, final String tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), project.getDependencies().create(tool) @@ -34,17 +32,14 @@ public static ResolvedArtifact resolveToolArtifact(final Project project, final } public static ResolvedArtifact resolveToolArtifact(final Project project, final Dependency tool) { - return resolveTool(project, () -> ConfigurationUtils.temporaryUnhandledConfiguration( + return resolveTool(() -> ConfigurationUtils.temporaryUnhandledConfiguration( project.getConfigurations(), "ToolLookupFor" + ModuleDependencyUtils.toConfigurationName(tool), tool ).getResolvedConfiguration().getResolvedArtifacts().iterator().next()); } - private static T resolveTool(final Project project, final Supplier searcher) { - //Grab the dynamic repository - final Repository repository = project.getExtensions().getByType(Repository.class); - + private static T resolveTool(final Supplier searcher) { //Return the resolved artifact return searcher.get(); } diff --git a/gradle.properties b/gradle.properties index 743dd54cf..e6dcbc3f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,4 +36,4 @@ spock_version=2.1 spock_groovy_version=3.0 mockito_version=4.11.0 jimfs_version=1.2 -trainingwheels_version=1.0.46 +trainingwheels_version=1.0.48 \ No newline at end of file diff --git a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy index 82a2a8b3a..317584372 100644 --- a/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy +++ b/neoform/src/functionalTest/groovy/net/neoforged/gradle/neoform/FunctionalTests.groovy @@ -30,7 +30,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) } when: @@ -57,7 +57,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) } when: @@ -102,7 +102,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) } when: @@ -141,7 +141,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() } diff --git a/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java b/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java index 27660e262..0f9688c9f 100644 --- a/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java +++ b/neoform/src/main/java/net/neoforged/gradle/neoform/naming/NeoFormOfficialNamingChannelConfigurator.java @@ -215,7 +215,7 @@ public abstract static class MappingsFileValueSource implements ValueSource f.getAbsoluteFile().getPath().endsWith(getParameters().getMappingsFilePath().get())).getSingleFile(); + return getParameters().getNeoFormArchive().filter(f -> f.getAbsoluteFile().getPath().replace(File.separator, "/").endsWith(getParameters().getMappingsFilePath().get())).getSingleFile(); } } } diff --git a/settings.gradle b/settings.gradle index ccfffe2be..78d468739 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,6 +11,7 @@ plugins { rootProject.name = 'NeoGradle' include 'utils' +include 'test-utils' include 'common' include 'vanilla' include 'neoform' diff --git a/test-utils/build.gradle b/test-utils/build.gradle new file mode 100644 index 000000000..4b234197a --- /dev/null +++ b/test-utils/build.gradle @@ -0,0 +1,17 @@ +plugins { + id 'groovy' +} + +dependencies.api dependencies.gradleTestKit() +dependencies.api "org.junit.jupiter:junit-jupiter-api:${project.junit_version}" +dependencies.api "org.junit.jupiter:junit-jupiter-params:${project.junit_version}" +dependencies.api "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}" +dependencies.api "org.junit.platform:junit-platform-engine:${project.junit_platform_version}" +dependencies.api "org.mockito:mockito-junit-jupiter:${project.mockito_version}" +dependencies.api "org.mockito:mockito-core:${project.mockito_version}" +dependencies.api "org.mockito:mockito-inline:${project.mockito_version}" +dependencies.api "net.neoforged.trainingwheels:base:${project.trainingwheels_version}" +dependencies.api "net.neoforged.trainingwheels:gradle-base:${project.trainingwheels_version}" +dependencies.api "net.neoforged.trainingwheels:gradle-functional:${project.trainingwheels_version}" + +dependencies.implementation project(':common') \ No newline at end of file diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy new file mode 100644 index 000000000..07f9d0038 --- /dev/null +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/FileExtensions.groovy @@ -0,0 +1,16 @@ +package net.neoforged.gradle.utils.test.extensions + +import groovy.transform.CompileStatic + +/** + * Extensions for the [File] class. + */ +class FileExtensions { + + /** + * @return the absolute path of the file with backslashes escaped. + */ + static String getPropertiesPath(final File self) { + return self.absolutePath.replace("\\", "\\\\") + } +} diff --git a/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy new file mode 100644 index 000000000..69119dcc2 --- /dev/null +++ b/test-utils/src/main/groovy/net/neoforged/gradle/utils/test/extensions/RuntimeBuilderExtensions.groovy @@ -0,0 +1,24 @@ +package net.neoforged.gradle.utils.test.extensions + +import groovy.transform.CompileStatic +import net.neoforged.gradle.common.caching.CentralCacheService +import net.neoforged.trainingwheels.gradle.functional.builder.Runtime + +/** + * Extensions for the {@link Runtime.Builder} class. + */ +class RuntimeBuilderExtensions { + + /** + * Sets the global cache directory to the given {@param testProjectDir}. + * + * @param testProjectDir the directory to use as the global cache directory + * @return the global cache directory + */ + static File withGlobalCacheDirectory(final Runtime.Builder self, final File testProjectDir) { + final File cacheDir = new File(testProjectDir, ".ng-cache") + self.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getPropertiesPath()) + + return cacheDir + } +} diff --git a/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule new file mode 100644 index 000000000..ab48055f1 --- /dev/null +++ b/test-utils/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule @@ -0,0 +1,3 @@ +moduleName = neogradle-test-utils-module +moduleVersion = 1.0 +extensionClasses = net.neoforged.gradle.utils.test.extensions.FileExtensions,net.neoforged.gradle.utils.test.extensions.RuntimeBuilderExtensions \ No newline at end of file diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy index 8bb131c55..13115fb6e 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy @@ -41,7 +41,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -82,7 +82,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -125,7 +125,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -169,7 +169,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -213,7 +213,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy index 360c8df0b..325740d57 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/CentralCacheTests.groovy @@ -47,6 +47,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { def "clean_cache_listens_to_project_property_for_size"() { given: + File cacheDir; def project = create("build_supports_configuration_cache_build", { it.build(""" java { @@ -60,10 +61,14 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + cacheDir = it.withGlobalCacheDirectory(tempDir) it.property(CentralCacheService.MAX_CACHE_SIZE_PROPERTY, "4") }) + if (cacheDir == null) { + throw new IllegalStateException("Cache directory was not set") + } + when: def run = project.run { it.tasks('build') @@ -71,18 +76,17 @@ class CentralCacheTests extends BuilderBasedTestSpecification { then: run.task(':build').outcome == TaskOutcome.SUCCESS - new File(tempDir, ".caches-global").listFiles().size() > 4 + cacheDir.listFiles().size() > 4 when: def cleanRun = project.run { it.tasks('clean') - it.debug() } then: cleanRun.task(':clean').outcome == TaskOutcome.SUCCESS cleanRun.task(':cleanCache').outcome == TaskOutcome.SUCCESS - new File(tempDir, ".caches-global").listFiles().size() == 4 + cacheDir.listFiles().size() == 4 } def "cache_supports_running_gradle_in_parallel"() { @@ -134,7 +138,7 @@ class CentralCacheTests extends BuilderBasedTestSpecification { def "cache_supports_cleanup_and_take_over_of_failed_lock"() { given: - def cacheDir = new File(tempDir, ".caches-global") + File cacheDir; def project = create("cache_supports_cleanup_and_take_over_of_failed_lock", { it.build(""" java { @@ -148,10 +152,14 @@ class CentralCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, cacheDir.getAbsolutePath()) + cacheDir = it.withGlobalCacheDirectory(tempDir) it.property(CentralCacheService.LOG_CACHE_HITS_PROPERTY, "true") }) + if (cacheDir == null) { + throw new IllegalStateException("Cache directory was not set") + } + when: project.run { it.tasks('build') diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy index 7cdec4d30..3b9bdb96f 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationCacheTests.groovy @@ -32,7 +32,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() it.enableConfigurationCache() it.enableBuildScan() @@ -73,7 +73,7 @@ class ConfigurationCacheTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.enableLocalBuildCache() it.enableConfigurationCache() }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy index 582e97f86..3faeb29d1 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ConfigurationTests.groovy @@ -44,7 +44,7 @@ class ConfigurationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -54,12 +54,10 @@ class ConfigurationTests extends BuilderBasedTestSpecification { then: run.task(':dependencies').outcome == TaskOutcome.SUCCESS - run.output.contains( -''' -implementation - Implementation dependencies for the 'main' feature. (n) -No dependencies -''' - ) + def implementationStartLine = run.output.split(System.lineSeparator()).toList().indexOf('implementation - Implementation dependencies for the \'main\' feature. (n)') + implementationStartLine != -1 + def nextLine = run.output.split(System.lineSeparator()).toList().get(implementationStartLine + 1) + nextLine.contains("No dependencies") } def "a mod with userdev in the implementation configuration does not leak it via publishing"() { @@ -103,7 +101,7 @@ No dependencies } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy index f01d05a31..061d623ce 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/DepreciationTests.groovy @@ -28,7 +28,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -71,7 +71,7 @@ class DepreciationTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy index 178f647dd..17b5716e0 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/FunctionalTests.groovy @@ -28,7 +28,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -66,7 +66,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -110,7 +110,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -149,7 +149,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -188,7 +188,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -226,7 +226,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -267,7 +267,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -326,7 +326,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { """) it.withToolchains() it.enableLocalBuildCache() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -395,7 +395,7 @@ class FunctionalTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy index 6c8cb71d2..ffec9f665 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/MultiProjectTests.groovy @@ -23,7 +23,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) def apiProject = create(rootProject, "api", { @@ -50,7 +50,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -87,7 +87,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -116,7 +116,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } } """) - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.withToolchains() }) @@ -144,7 +144,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -181,7 +181,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) @@ -207,7 +207,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) def apiProject = create(rootProject, "api", { @@ -231,7 +231,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin("java-library") }) @@ -268,7 +268,7 @@ class MultiProjectTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) it.plugin(this.pluginUnderTest) }) diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy index 21478d158..2b3339039 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/RunTests.groovy @@ -48,7 +48,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -91,7 +91,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -133,7 +133,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -152,7 +152,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.graalvm.polyglot/polyglot") + classpathFile.text.contains("org.graalvm.polyglot${File.separator}polyglot") !classpathFile.text.contains(".pom") } @@ -185,7 +185,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -204,7 +204,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "userdev supports custom run dependencies from configuration"() { @@ -241,7 +241,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -260,7 +260,7 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "userdev supports custom run dependencies from catalog"() { @@ -302,7 +302,7 @@ class RunTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -321,6 +321,6 @@ class RunTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } } diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy index 100764cb7..06c69ca1c 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/IDEAIDEConventionTests.groovy @@ -35,7 +35,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -71,7 +71,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -107,7 +107,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -143,7 +143,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -178,7 +178,7 @@ class IDEAIDEConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy index 1c951e718..8f83f4771 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/RunConventionTests.groovy @@ -40,7 +40,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -79,7 +79,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -118,7 +118,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -158,7 +158,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -195,7 +195,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -228,7 +228,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -265,7 +265,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -302,7 +302,7 @@ class RunConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy index ca2f893b5..2c9701ff9 100644 --- a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/convention/SourceSetConventionTests.groovy @@ -32,7 +32,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -65,7 +65,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -98,7 +98,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -131,7 +131,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -164,7 +164,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -197,7 +197,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -238,7 +238,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -247,7 +247,6 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") } @@ -279,7 +278,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -288,7 +287,6 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") } @@ -320,7 +318,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -329,7 +327,6 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } then: - run.task(':dependencies').outcome == TaskOutcome.SUCCESS run.output.contains("Run sources: []") } @@ -360,7 +357,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -398,7 +395,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -418,7 +415,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { classpathFile.exists() - !classpathFile.text.contains("org.jgrapht/jgrapht-core") + !classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "enabling sourceset local run runtime registration conventions registers localRunRuntime"() { @@ -445,7 +442,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -465,7 +462,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { classpathFile.exists() - classpathFile.text.contains("org.jgrapht/jgrapht-core") + classpathFile.text.contains("org.jgrapht${File.separator}jgrapht-core") } def "using the local runtime convention configuration does not put the dependency on the runtime config"() { @@ -492,7 +489,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: @@ -529,7 +526,7 @@ class SourceSetConventionTests extends BuilderBasedTestSpecification { } """) it.withToolchains() - it.property(CentralCacheService.CACHE_DIRECTORY_PROPERTY, new File(tempDir, ".caches-global").getAbsolutePath()) + it.withGlobalCacheDirectory(tempDir) }) when: diff --git a/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java b/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java index 45c3bfb23..29b4f02a8 100644 --- a/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java +++ b/userdev/src/main/java/net/neoforged/gradle/userdev/dependency/UserDevDependencyManager.java @@ -29,12 +29,10 @@ public void apply(final Project project) { return Optional.empty(); } - if (!(context.getDependency() instanceof ExternalModuleDependency)) { + if (!(context.getDependency() instanceof ExternalModuleDependency externalModuleDependency)) { return Optional.empty(); } - - final ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) context.getDependency(); - + final UserDevRuntimeDefinition runtimeDefinition = buildForgeUserDevRuntimeFrom(project, externalModuleDependency); final Configuration additionalDependenciesConfiguration = ConfigurationUtils.temporaryConfiguration( diff --git a/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy b/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy index ed17ae466..ab04bced9 100644 --- a/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy +++ b/vanilla/src/functionalTest/groovy/net/neoforged/gradle/vanilla/AccessTransformerTests.groovy @@ -45,7 +45,7 @@ class AccessTransformerTests extends BuilderBasedTestSpecification { when: def initialRun = project.run { it.tasks('build') - it.debug() + it.stacktrace() } then: diff --git a/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java b/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java index 39558d892..6cb1b799c 100644 --- a/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java +++ b/vanilla/src/main/java/net/neoforged/gradle/vanilla/VanillaProjectPlugin.java @@ -13,7 +13,7 @@ public class VanillaProjectPlugin implements Plugin { public void apply(Project project) { project.getPlugins().apply(CommonPlugin.class); - VanillaRuntimeExtension runtimeExtension = project.getExtensions().create("vanillaRuntimes", VanillaRuntimeExtension.class, project); + project.getExtensions().create("vanillaRuntimes", VanillaRuntimeExtension.class, project); //Setup handling of the dependencies VanillaDependencyManager.getInstance().apply(project);