diff --git a/.github/workflows/test-push.yml b/.github/workflows/test-push.yml new file mode 100644 index 0000000..d00b034 --- /dev/null +++ b/.github/workflows/test-push.yml @@ -0,0 +1,30 @@ +name: Run Tests +on: [push, pull_request] +jobs: + gradle: + strategy: + matrix: + os: [ubuntu-20.04, windows-latest] + gradle-version: [4.9, 4.10.2, 5.6.4, 6.5] + java-version: [1.8, 11, 14] + exclude: # Dont run older gradle versions on newer java + - java-version: 14 + gradle-version: 4.9 + - java-version: 14 + gradle-version: 4.10.2 + - java-version: 14 + gradle-version: 5.6.4 + - java-version: 11 + gradle-version: 4.9 + - java-version: 11 + gradle-version: 4.10.2 + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java-version }} + - uses: eskatos/gradle-command-action@v1 + with: + gradle-version: ${{ matrix.gradle-version }} + arguments: build check test --stacktrace \ No newline at end of file diff --git a/.gitignore b/.gitignore index beb2556..af5b65f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # Folders !/gradle !/src +!/.github # Files !/.gitattributes @@ -18,5 +19,4 @@ !/README.md !/settings.gradle !/Jenkinsfile -!/.travis.yml !/checkstyle.xml \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ad00567..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: java -install: true - -jdk: - - openjdk8 - -script: - - chmod +x gradlew - - ./gradlew check build test --stacktrace - -notifications: - email: false \ No newline at end of file diff --git a/build.gradle b/build.gradle index a081ccd..3611a4f 100644 --- a/build.gradle +++ b/build.gradle @@ -47,9 +47,8 @@ dependencies { } // tinyfile management - implementation ('net.fabricmc:tiny-remapper:0.3.0.70') { - transitive = false - } + implementation ('net.fabricmc:tiny-remapper:0.3.0.70') + implementation ('net.fabricmc:tiny-mappings-parser:0.2.2.14') implementation ('net.fabricmc:lorenz-tiny:2.0.0+build.2') { transitive = false @@ -67,12 +66,8 @@ dependencies { // Testing testImplementation(gradleTestKit()) - testImplementation("org.spockframework:spock-core:1.3-groovy-2.4") -} - -configurations.all { - resolutionStrategy { - force 'org.codehaus.groovy:groovy-all:2.4.12' + testImplementation("org.spockframework:spock-core:1.3-groovy-2.4") { + exclude module: 'groovy-all' } } @@ -177,9 +172,4 @@ publishing { } } } -} -configurations.all { - resolutionStrategy { - force 'org.codehaus.groovy:groovy-all:2.4.12' - } -} +} \ No newline at end of file diff --git a/src/main/java/net/fabricmc/loom/task/AbstractLoomTask.java b/src/main/java/net/fabricmc/loom/task/AbstractLoomTask.java index e62173d..9dada30 100644 --- a/src/main/java/net/fabricmc/loom/task/AbstractLoomTask.java +++ b/src/main/java/net/fabricmc/loom/task/AbstractLoomTask.java @@ -25,6 +25,7 @@ package net.fabricmc.loom.task; import org.gradle.api.DefaultTask; +import org.gradle.api.tasks.Internal; import net.fabricmc.loom.LoomGradleExtension; @@ -33,6 +34,7 @@ public abstract class AbstractLoomTask extends DefaultTask { setGroup("fabric"); } + @Internal protected LoomGradleExtension getExtension() { return getProject().getExtensions().getByType(LoomGradleExtension.class); } diff --git a/src/main/java/net/fabricmc/loom/util/GradleSupport.java b/src/main/java/net/fabricmc/loom/util/GradleSupport.java index f205209..caf35ce 100644 --- a/src/main/java/net/fabricmc/loom/util/GradleSupport.java +++ b/src/main/java/net/fabricmc/loom/util/GradleSupport.java @@ -24,12 +24,10 @@ package net.fabricmc.loom.util; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.gradle.api.Project; import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.model.ObjectFactory; //This is used to bridge the gap over large gradle api changes. public class GradleSupport { @@ -41,17 +39,24 @@ public class GradleSupport { //Nope } - return getfilePropertyLegacy(project); + try { + return getfilePropertyLegacy(project); + } catch (Exception e) { + throw new RuntimeException("Failed to find file property", e); + } } - private static RegularFileProperty getfilePropertyModern(Project project) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - ObjectFactory objectFactory = project.getObjects(); - Method method = objectFactory.getClass().getDeclaredMethod("fileProperty"); + private static RegularFileProperty getfilePropertyModern(Project project) throws Exception { + return getfilePropertyLegacyFromObject(project.getObjects()); + } + + private static RegularFileProperty getfilePropertyLegacy(Project project) throws Exception { + return getfilePropertyLegacyFromObject(project.getLayout()); + } + + private static RegularFileProperty getfilePropertyLegacyFromObject(Object object) throws Exception { + Method method = object.getClass().getDeclaredMethod("fileProperty"); method.setAccessible(true); - return (RegularFileProperty) method.invoke(objectFactory); - } - - private static RegularFileProperty getfilePropertyLegacy(Project project) { - return project.getLayout().fileProperty(); + return (RegularFileProperty) method.invoke(object); } } diff --git a/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy index e42ee12..8a722cd 100644 --- a/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy @@ -37,7 +37,7 @@ class EmptyBuildFunctionalTest extends Specification { .withProjectDir(testProjectDir.root) .withArguments('build',"--stacktrace") .withPluginClasspath() - .withGradleVersion("4.9") + .forwardOutput() .build() then: diff --git a/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy index bc737fb..4041919 100644 --- a/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy @@ -62,7 +62,7 @@ class MixinBuildFunctionalTest extends Specification { .withProjectDir(testProjectDir.root) .withArguments('build') .withPluginClasspath() - .withGradleVersion("4.9") + .forwardOutput() .build() then: diff --git a/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy index 9706e7e..784a2de 100644 --- a/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy @@ -47,7 +47,7 @@ class SimpleBuildFunctionalTest extends Specification { .withProjectDir(testProjectDir.root) .withArguments('build',"--stacktrace") .withPluginClasspath() - .withGradleVersion("4.9") + .forwardOutput() .withDebug(true) .build()