-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of multiple AccessTransformers in the same project (#155)
- Loading branch information
1 parent
08369c9
commit f4baaba
Showing
4 changed files
with
233 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
222 changes: 222 additions & 0 deletions
222
userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/AccessTransformerTests.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
package net.neoforged.gradle.userdev | ||
|
||
import net.neoforged.trainingwheels.gradle.functional.BuilderBasedTestSpecification | ||
import org.gradle.testkit.runner.TaskOutcome | ||
|
||
class AccessTransformerTests extends BuilderBasedTestSpecification { | ||
|
||
@Override | ||
protected void configurePluginUnderTest() { | ||
pluginUnderTest = "net.neoforged.gradle.userdev"; | ||
injectIntoAllProject = true; | ||
} | ||
|
||
def "the userdev runtime supports loading ats from a file"() { | ||
given: | ||
def project = create("userdev_supports_ats_from_file", { | ||
it.build(""" | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') | ||
dependencies { | ||
implementation 'net.neoforged:neoforge:+' | ||
} | ||
""") | ||
it.file("src/main/resources/META-INF/accesstransformer.cfg", """public-f net.minecraft.client.Minecraft fixerUpper # fixerUpper""") | ||
it.file("src/main/java/net/neoforged/gradle/userdev/FunctionalTests.java", """ | ||
package net.neoforged.gradle.userdev; | ||
import net.minecraft.client.Minecraft; | ||
public class FunctionalTests { | ||
public static void main(String[] args) { | ||
System.out.println(Minecraft.getInstance().fixerUpper.getClass().toString()); | ||
} | ||
} | ||
""") | ||
it.withToolchains() | ||
}) | ||
|
||
when: | ||
def initialRun = project.run { | ||
it.tasks('build') | ||
} | ||
|
||
then: | ||
initialRun.task(":neoFormRecompile").outcome == TaskOutcome.SUCCESS | ||
initialRun.task(":build").outcome == TaskOutcome.SUCCESS | ||
} | ||
|
||
def "the userdev runtime supports loading ats from the script"() { | ||
given: | ||
def project = create("userdev_supports_ats_in_scripts", { | ||
it.build(""" | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
minecraft.accessTransformers.entry 'public-f net.minecraft.client.Minecraft fixerUpper # fixerUpper' | ||
dependencies { | ||
implementation 'net.neoforged:neoforge:+' | ||
} | ||
""") | ||
it.file("src/main/java/net/neoforged/gradle/userdev/FunctionalTests.java", """ | ||
package net.neoforged.gradle.userdev; | ||
import net.minecraft.client.Minecraft; | ||
public class FunctionalTests { | ||
public static void main(String[] args) { | ||
System.out.println(Minecraft.getInstance().fixerUpper.getClass().toString()); | ||
} | ||
} | ||
""") | ||
it.withToolchains() | ||
}) | ||
|
||
when: | ||
def initialRun = project.run { | ||
it.tasks('build') | ||
} | ||
|
||
then: | ||
initialRun.task(":neoFormRecompile").outcome == TaskOutcome.SUCCESS | ||
initialRun.task(":build").outcome == TaskOutcome.SUCCESS | ||
} | ||
|
||
def "the userdev runtime supports loading ats from the script and the file"() { | ||
given: | ||
def project = create("userdev_supports_ats_in_script_and_file", { | ||
it.build(""" | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') | ||
minecraft.accessTransformers.entry 'public-f net.minecraft.client.Minecraft LOGGER # LOGGER' | ||
dependencies { | ||
implementation 'net.neoforged:neoforge:+' | ||
} | ||
""") | ||
it.file("src/main/resources/META-INF/accesstransformer.cfg", """public-f net.minecraft.client.Minecraft fixerUpper # fixerUpper""") | ||
it.file("src/main/java/net/neoforged/gradle/userdev/FunctionalTests.java", """ | ||
package net.neoforged.gradle.userdev; | ||
import net.minecraft.client.Minecraft; | ||
public class FunctionalTests { | ||
public static void main(String[] args) { | ||
System.out.println(Minecraft.getInstance().fixerUpper.getClass().toString()); | ||
System.out.println(Minecraft.LOGGER.getClass().toString()); | ||
} | ||
} | ||
""") | ||
it.withToolchains() | ||
}) | ||
|
||
when: | ||
def initialRun = project.run { | ||
it.tasks('build') | ||
} | ||
|
||
then: | ||
initialRun.task(":neoFormRecompile").outcome == TaskOutcome.SUCCESS | ||
initialRun.task(":build").outcome == TaskOutcome.SUCCESS | ||
} | ||
|
||
def "the userdev runtime supports loading ats from multiple files"() { | ||
given: | ||
def project = create("userdev_supports_ats_in_multiple_distinctly_named_files", { | ||
it.build(""" | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer2.cfg') | ||
dependencies { | ||
implementation 'net.neoforged:neoforge:+' | ||
} | ||
""") | ||
it.file("src/main/resources/META-INF/accesstransformer.cfg", """public-f net.minecraft.client.Minecraft fixerUpper # fixerUpper""") | ||
it.file("src/main/resources/META-INF/accesstransformer2.cfg", """public-f net.minecraft.client.Minecraft LOGGER # LOGGER""") | ||
it.file("src/main/java/net/neoforged/gradle/userdev/FunctionalTests.java", """ | ||
package net.neoforged.gradle.userdev; | ||
import net.minecraft.client.Minecraft; | ||
public class FunctionalTests { | ||
public static void main(String[] args) { | ||
System.out.println(Minecraft.getInstance().fixerUpper.getClass().toString()); | ||
System.out.println(Minecraft.LOGGER.getClass().toString()); | ||
} | ||
} | ||
""") | ||
it.withToolchains() | ||
}) | ||
|
||
when: | ||
def initialRun = project.run { | ||
it.tasks('build') | ||
} | ||
|
||
then: | ||
initialRun.task(":neoFormRecompile").outcome == TaskOutcome.SUCCESS | ||
initialRun.task(":build").outcome == TaskOutcome.SUCCESS | ||
} | ||
|
||
def "the userdev runtime supports loading ats from multiple files named the same in different directories"() { | ||
given: | ||
def project = create("userdev_supports_ats_in_files_named_the_same", { | ||
it.build(""" | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg') | ||
minecraft.accessTransformers.file rootProject.file('src/main/resources/accesstransformer.cfg') | ||
dependencies { | ||
implementation 'net.neoforged:neoforge:+' | ||
} | ||
""") | ||
it.file("src/main/resources/META-INF/accesstransformer.cfg", """public-f net.minecraft.client.Minecraft fixerUpper # fixerUpper""") | ||
it.file("src/main/resources/accesstransformer.cfg", """public-f net.minecraft.client.Minecraft LOGGER # LOGGER""") | ||
it.file("src/main/java/net/neoforged/gradle/userdev/FunctionalTests.java", """ | ||
package net.neoforged.gradle.userdev; | ||
import net.minecraft.client.Minecraft; | ||
public class FunctionalTests { | ||
public static void main(String[] args) { | ||
System.out.println(Minecraft.getInstance().fixerUpper.getClass().toString()); | ||
System.out.println(Minecraft.LOGGER.getClass().toString()); | ||
} | ||
} | ||
""") | ||
it.withToolchains() | ||
}) | ||
|
||
when: | ||
def initialRun = project.run { | ||
it.tasks('build') | ||
} | ||
|
||
then: | ||
initialRun.task(":neoFormRecompile").outcome == TaskOutcome.SUCCESS | ||
initialRun.task(":build").outcome == TaskOutcome.SUCCESS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters