Rewrite tests to be easier to write and maintain (#361)
This commit is contained in:
		
							parent
							
								
									679026ef31
								
							
						
					
					
						commit
						87f3743b24
					
				
					 55 changed files with 1536 additions and 452 deletions
				
			
		
							
								
								
									
										55
									
								
								.github/workflows/test-push.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										55
									
								
								.github/workflows/test-push.yml
									
									
									
									
										vendored
									
									
								
							|  | @ -1,10 +1,11 @@ | |||
| name: Run Tests | ||||
| on: [push, pull_request] | ||||
| jobs: | ||||
|   gradle: | ||||
|   build: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         gradle: [4.9, 4.10.2, 6.8.2] | ||||
|         gradle: [4.9, 4.10.2, 6.8.3] | ||||
|         java: [jdk8, jdk11, jdk15] | ||||
|         exclude: # Dont run older gradle versions on newer java | ||||
|           - java: jdk15 | ||||
|  | @ -20,18 +21,52 @@ jobs: | |||
|       image: gradle:${{ matrix.gradle }}-${{ matrix.java }} | ||||
|       options: --user root | ||||
|     steps: | ||||
|       - uses: actions/checkout@v1 | ||||
|       - uses: actions/checkout@v2 | ||||
|       - uses: gradle/wrapper-validation-action@v1 | ||||
|       - run: gradle build check test --stacktrace | ||||
|       - run: gradle build check -x test --stacktrace | ||||
| 
 | ||||
|   # This job is used to feed the test matrix of next job to allow the tests to run in parallel | ||||
|   prepare_test_matrix: | ||||
|     # Lets wait to ensure it builds before going running tests | ||||
|     needs: build | ||||
| 
 | ||||
|   gradle_pre_release: | ||||
|     runs-on: ubuntu-20.04 | ||||
|     container: | ||||
|       image: openjdk:8-jdk | ||||
|       image: gradle:6.8.3-jdk15 | ||||
|       options: --user root | ||||
| 
 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v1 | ||||
|       - run: ./gradlew wrapper --gradle-version=7.0-milestone-1 | ||||
|       - run: ./gradlew build check test --stacktrace --warning-mode fail | ||||
|       - uses: actions/checkout@v2 | ||||
|       - run: gradle writeActionsTestMatrix --stacktrace | ||||
|       - | ||||
|         id: set-matrix | ||||
|         run: echo "::set-output name=matrix::$(cat build/test_matrix.json)" | ||||
| 
 | ||||
|     outputs: | ||||
|       matrix: ${{ steps.set-matrix.outputs.matrix }} | ||||
| 
 | ||||
|   run_tests: | ||||
|     needs: prepare_test_matrix | ||||
| 
 | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         java: [jdk8, jdk11, jdk15] | ||||
|         test: ${{ fromJson(needs.prepare_test_matrix.outputs.matrix) }} | ||||
| 
 | ||||
|     runs-on: ubuntu-20.04 | ||||
|     container: | ||||
|       image: gradle:6.8.3-${{ matrix.java }} | ||||
|       options: --user root | ||||
| 
 | ||||
|     steps: | ||||
|       - uses: actions/checkout@v2 | ||||
|       - run: gradle test --tests *${{ matrix.test }} --stacktrace | ||||
|         env: | ||||
|           TEST_WARNING_MODE: fail | ||||
|           TEST_WARNING_MODE: fail | ||||
| 
 | ||||
|       - uses: actions/upload-artifact@v2 | ||||
|         if: ${{ always() }} | ||||
|         with: | ||||
|           name: ${{ matrix.test }} (${{ matrix.java }}) Results | ||||
|           path: build/reports/ | ||||
							
								
								
									
										39
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								build.gradle
									
									
									
									
									
								
							|  | @ -6,6 +6,7 @@ plugins { | |||
| 	id 'eclipse' | ||||
| 	id 'groovy' | ||||
| 	id 'checkstyle' | ||||
| 	id 'jacoco' | ||||
| 	id "org.cadixdev.licenser" version "0.5.0" | ||||
| } | ||||
| 
 | ||||
|  | @ -78,7 +79,6 @@ dependencies { | |||
| 	} | ||||
| 
 | ||||
| 	compileOnly 'org.jetbrains:annotations:20.1.0' | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
|  | @ -100,7 +100,9 @@ task javadocJar(type: Jar, dependsOn: javadoc) { | |||
| license { | ||||
| 	header rootProject.file("HEADER") | ||||
| 	include "**/*.java" | ||||
| 	include "**/*.groovy" | ||||
| 	exclude '**/loom/util/DownloadUtil.java' | ||||
| 	exclude '**/projects' | ||||
| } | ||||
| 
 | ||||
| checkstyle { | ||||
|  | @ -117,6 +119,20 @@ gradlePlugin { | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| jacoco { | ||||
| 	toolVersion = "0.8.6" | ||||
| } | ||||
| 
 | ||||
| // Run to get test coverage. | ||||
| jacocoTestReport { | ||||
| 	dependsOn test | ||||
| 	reports { | ||||
| 		xml.enabled false | ||||
| 		csv.enabled false | ||||
| 		html.destination file("${buildDir}/jacocoHtml") | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| import org.w3c.dom.Document | ||||
| import org.w3c.dom.Element | ||||
| import org.w3c.dom.Node | ||||
|  | @ -178,4 +194,25 @@ publishing { | |||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // A task to output a json file with a list of all the test to run | ||||
| task writeActionsTestMatrix() { | ||||
| 	doLast { | ||||
| 		def testMatrix = [] | ||||
| 		file('src/test/groovy/net/fabricmc/loom').eachFile { | ||||
| 			if (it.name.endsWith("Test.groovy")) { | ||||
| 				if (it.text.contains("@Ignore")) { | ||||
| 					// A quick hack to disable currently broken tests. | ||||
| 					return | ||||
| 				} | ||||
| 
 | ||||
| 				testMatrix.add(it.name.replace(".groovy", "")) | ||||
| 			} | ||||
| 		} | ||||
| 		def json = groovy.json.JsonOutput.toJson(testMatrix) | ||||
| 		def output = file("build/test_matrix.json") | ||||
| 		output.parentFile.mkdir() | ||||
| 		output.text = json | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										56
									
								
								src/test/groovy/net/fabricmc/loom/AccessWidenerTest.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/test/groovy/net/fabricmc/loom/AccessWidenerTest.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,56 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ArchiveAssertionsTrait | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| class AccessWidenerTest extends Specification implements ProjectTestTrait, ArchiveAssertionsTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"accesswidener" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "accesswidener (gradle #gradle)"() { | ||||
| 		when: | ||||
| 			def result = create("build", gradle) | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 			getArchiveEntry("fabric-example-mod-1.0.0.jar", "modid.accesswidener") == expected() | ||||
| 		where: | ||||
| 			gradle 				| _ | ||||
| 			'6.8.3' 			| _ | ||||
| 			'7.0-milestone-2'	| _ | ||||
| 	} | ||||
| 
 | ||||
| 	String expected() { | ||||
| 		new File("src/test/resources/accesswidener/expected.accesswidener").text | ||||
| 	} | ||||
| } | ||||
|  | @ -1,209 +0,0 @@ | |||
| package net.fabricmc.loom | ||||
| 
 | ||||
| /** | ||||
|  * Created by Mitchell Skaggs on 6/12/2019. | ||||
|  */ | ||||
| static String genBuildFile(String mappingsDep = "\"net.fabricmc:yarn:\${project.yarn_mappings}\"") { | ||||
| 	""" | ||||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| 	id 'maven-publish' | ||||
| } | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| 
 | ||||
| minecraft { | ||||
| } | ||||
| 
 | ||||
| dependencies { | ||||
| 	//to change the versions see the gradle.properties file | ||||
| 	minecraft "com.mojang:minecraft:\${project.minecraft_version}" | ||||
| 	mappings ${mappingsDep} | ||||
| 	modImplementation "net.fabricmc:fabric-loader:\${project.loader_version}" | ||||
| 
 | ||||
| 	// Fabric API. This is technically optional, but you probably want it anyway. | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:\${project.fabric_version}" | ||||
| 
 | ||||
| 	// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. | ||||
| 	// You may need to force-disable transitiveness on them. | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	filesMatching("fabric.mod.json") { | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // ensure that the encoding is set to UTF-8, no matter what the system default is | ||||
| // this fixes some edge cases with special characters not displaying correctly | ||||
| // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html | ||||
| tasks.withType(JavaCompile) { | ||||
| 	options.encoding = "UTF-8" | ||||
| } | ||||
| 
 | ||||
| // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task | ||||
| // if it is present. | ||||
| // If you remove this task, sources will not be generated. | ||||
| task sourcesJar(type: Jar, dependsOn: classes) { | ||||
| 	classifier = "sources" | ||||
| 	from sourceSets.main.allSource | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from "LICENSE" | ||||
| } | ||||
| 
 | ||||
| // configure the maven publication | ||||
| publishing { | ||||
| 	publications { | ||||
| 		mavenJava(MavenPublication) { | ||||
| 			// add all the jars that should be included when publishing to maven | ||||
| 			artifact(jar) { | ||||
| 				builtBy remapJar | ||||
| 			} | ||||
| 			artifact(sourcesJar) { | ||||
| 				builtBy remapSourcesJar | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	// select the repositories you want to publish to | ||||
| 	repositories { | ||||
| 		// uncomment to publish to the local maven | ||||
| 		// mavenLocal() | ||||
| 	} | ||||
| } | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genPropsFile(String mcVersion, String yarnVersion, String loaderVersion, String fabricVersion, boolean caching = true, boolean parallel = true) { | ||||
| 	""" | ||||
| org.gradle.caching=$caching | ||||
| org.gradle.parallel=$parallel | ||||
| 
 | ||||
| # Fabric Properties | ||||
| # check these on https://fabricmc.net/use | ||||
| minecraft_version=$mcVersion | ||||
| yarn_mappings=$yarnVersion | ||||
| loader_version=$loaderVersion | ||||
| 
 | ||||
| # Mod Properties | ||||
| mod_version = 1.0.0 | ||||
| maven_group = net.fabricmc | ||||
| archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric | ||||
| fabric_version=$fabricVersion | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genSettingsFile(String name) { | ||||
| 	""" | ||||
| rootProject.name = '$name' | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genModJsonFile() { | ||||
| 	""" | ||||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "\${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "modid.mixins.json" | ||||
|   ], | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.4.0", | ||||
|     "fabric": "*" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "flamingo": "*" | ||||
|   } | ||||
| } | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genModJavaFile() { | ||||
| 	""" | ||||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genModMixinsJsonFile() { | ||||
| 	""" | ||||
| { | ||||
|   "required": true, | ||||
|   "package": "net.fabricmc.example.mixin", | ||||
|   "compatibilityLevel": "JAVA_8", | ||||
|   "mixins": [ | ||||
|   ], | ||||
|   "client": [ | ||||
|     "ExampleMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
| """ | ||||
| } | ||||
| 
 | ||||
| static String genModMixinsJavaFile() { | ||||
| 	""" | ||||
| package net.fabricmc.example.mixin; | ||||
| 
 | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| @Mixin(MinecraftClient.class) | ||||
| public class ExampleMixin { | ||||
| 	@Inject(at = @At("HEAD"), method = "init()V") | ||||
| 	private void init(CallbackInfo info) { | ||||
| 		System.out.println("This line is printed by an example mod mixin!"); | ||||
| 	} | ||||
| } | ||||
| """ | ||||
| } | ||||
							
								
								
									
										54
									
								
								src/test/groovy/net/fabricmc/loom/DecompileTest.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/test/groovy/net/fabricmc/loom/DecompileTest.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,54 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Ignore | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| @Ignore // TODO this fails due to the plugin classpath being setup differently. We need to explore other ways to do this. | ||||
| class DecompileTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"simple" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "#decompiler decompile"() { | ||||
| 		when: | ||||
| 			def result = create(task) | ||||
| 
 | ||||
| 		then: | ||||
| 			result.task(":${task}").outcome == SUCCESS | ||||
| 
 | ||||
| 		where: | ||||
| 			decompiler 		| task | ||||
| 			'fernflower'	| "genSources" | ||||
| 			'cfr' 			| "genSourcesWithExperimentalCfr" | ||||
| 	} | ||||
| } | ||||
|  | @ -1,51 +0,0 @@ | |||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import org.gradle.testkit.runner.GradleRunner | ||||
| import org.junit.Rule | ||||
| import org.junit.rules.TemporaryFolder | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static net.fabricmc.loom.BuildUtils.* | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| /** | ||||
|  * Created by Mitchell Skaggs on 6/10/2019. | ||||
|  */ | ||||
| class EmptyBuildFunctionalTest extends Specification { | ||||
| 	@Rule | ||||
| 	TemporaryFolder testProjectDir = new TemporaryFolder() | ||||
| 	File settingsFile | ||||
| 	File buildFile | ||||
| 	File propsFile | ||||
| 
 | ||||
| 	def setup() { | ||||
| 		settingsFile = testProjectDir.newFile('settings.gradle') | ||||
| 		buildFile = testProjectDir.newFile('build.gradle') | ||||
| 		propsFile = testProjectDir.newFile('gradle.properties') | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "empty build succeeds using Minecraft #mcVersion"() { | ||||
| 		given: | ||||
| 		settingsFile << genSettingsFile("empty-build-functional-test") | ||||
| 		propsFile << genPropsFile(mcVersion, yarnVersion, loaderVersion, fabricVersion) | ||||
| 		buildFile << genBuildFile() | ||||
| 
 | ||||
| 		when: | ||||
| 		def result = GradleRunner.create() | ||||
| 				.withProjectDir(testProjectDir.root) | ||||
| 				.withArguments('build',"--stacktrace", "--warning-mode", System.getenv().TEST_WARNING_MODE ?: 'all') | ||||
| 				.withPluginClasspath() | ||||
| 				.forwardOutput() | ||||
| 				.build() | ||||
| 
 | ||||
| 		then: | ||||
| 		result.task(":build").outcome == SUCCESS | ||||
| 
 | ||||
| 		where: | ||||
| 		mcVersion | yarnVersion       		| loaderVersion     | fabricVersion | ||||
| 		'1.14'    | '1.14+build.21'   		| '0.4.8+build.155' | '0.3.0+build.183' | ||||
| 		'1.16.2'  | '1.16.2+build.26:v2' 	| '0.9.2+build.206' | '0.19.0+build.398-1.16' | ||||
| 	} | ||||
| } | ||||
|  | @ -1,50 +0,0 @@ | |||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import org.gradle.testkit.runner.GradleRunner | ||||
| import org.junit.Rule | ||||
| import org.junit.rules.TemporaryFolder | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static net.fabricmc.loom.BuildUtils.* | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| /** | ||||
|  * Created by Mitchell Skaggs on 6/10/2019. | ||||
|  */ | ||||
| class EmptyBuildMojangFunctionalTest extends Specification { | ||||
| 	@Rule | ||||
| 	TemporaryFolder testProjectDir = new TemporaryFolder() | ||||
| 	File settingsFile | ||||
| 	File buildFile | ||||
| 	File propsFile | ||||
| 
 | ||||
| 	def setup() { | ||||
| 		settingsFile = testProjectDir.newFile('settings.gradle') | ||||
| 		buildFile = testProjectDir.newFile('build.gradle') | ||||
| 		propsFile = testProjectDir.newFile('gradle.properties') | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "empty build succeeds using Minecraft #mcVersion"() { | ||||
| 		given: | ||||
| 		settingsFile << genSettingsFile("empty-build-functional-test") | ||||
| 		propsFile << genPropsFile(mcVersion, "nope", loaderVersion, fabricVersion) | ||||
| 		buildFile << genBuildFile("minecraft.officialMojangMappings()") | ||||
| 
 | ||||
| 		when: | ||||
| 		def result = GradleRunner.create() | ||||
| 				.withProjectDir(testProjectDir.root) | ||||
| 				.withArguments('build',"--stacktrace", "--warning-mode", System.getenv().TEST_WARNING_MODE ?: 'all') | ||||
| 				.withPluginClasspath() | ||||
| 				.forwardOutput() | ||||
| 				.build() | ||||
| 
 | ||||
| 		then: | ||||
| 		result.task(":build").outcome == SUCCESS | ||||
| 
 | ||||
| 		where: | ||||
| 		mcVersion	| loaderVersion     | fabricVersion | ||||
| 		'1.16.2'	| '0.9.2+build.206' | '0.19.0+build.398-1.16' | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										50
									
								
								src/test/groovy/net/fabricmc/loom/KotlinTest.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								src/test/groovy/net/fabricmc/loom/KotlinTest.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| class KotlinTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"kotlin" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "kotlin build (gradle #gradle)"() { | ||||
| 		when: | ||||
| 			def result = create("build", gradle) | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 		where: | ||||
| 			gradle 				| _ | ||||
| 			'6.8.3' 			| _ | ||||
| 			'7.0-milestone-2'	| _ | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										53
									
								
								src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/test/groovy/net/fabricmc/loom/LegacyProjectTest.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,53 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| // This test uses gradle 4.9 and 1.14.4 v1 mappings | ||||
| class LegacyProjectTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"legacy" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "build"() { | ||||
| 		when: | ||||
| 			def result = create("build", "4.9") | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	String warningMode() { | ||||
| 		// Gradle 4.9 doesnt support fail, and well this is a legacy test so deprecations are expected | ||||
| 		'all' | ||||
| 	} | ||||
| } | ||||
|  | @ -1,69 +0,0 @@ | |||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import org.gradle.testkit.runner.GradleRunner | ||||
| import org.junit.Rule | ||||
| import org.junit.rules.TemporaryFolder | ||||
| import spock.lang.Ignore | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static net.fabricmc.loom.BuildUtils.* | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| /** | ||||
|  * Created by Mitchell Skaggs on 6/10/2019. | ||||
|  */ | ||||
| class MixinBuildFunctionalTest extends Specification { | ||||
| 	@Rule | ||||
| 	TemporaryFolder testProjectDir = new TemporaryFolder() | ||||
| 	File settingsFile | ||||
| 	File buildFile | ||||
| 	File propsFile | ||||
| 	File modJsonFile | ||||
| 	File modJavaFile | ||||
| 	File modMixinsJsonFile | ||||
| 	File modMixinsJavaFile | ||||
| 
 | ||||
| 	def setup() { | ||||
| 		settingsFile = testProjectDir.newFile('settings.gradle') | ||||
| 		buildFile = testProjectDir.newFile('build.gradle') | ||||
| 		propsFile = testProjectDir.newFile('gradle.properties') | ||||
| 
 | ||||
| 		testProjectDir.newFolder("src", "main", "resources") | ||||
| 		modJsonFile = testProjectDir.newFile('src/main/resources/fabric.mod.json') | ||||
| 		modMixinsJsonFile = testProjectDir.newFile('src/main/resources/modid.mixins.json') | ||||
| 
 | ||||
| 		testProjectDir.newFolder("src", "main", "java", "net", "fabricmc", "example") | ||||
| 		modJavaFile = testProjectDir.newFile("src/main/java/net/fabricmc/example/ExampleMod.java") | ||||
| 
 | ||||
| 		testProjectDir.newFolder("src", "main", "java", "net", "fabricmc", "example", "mixin") | ||||
| 		modMixinsJavaFile = testProjectDir.newFile("src/main/java/net/fabricmc/example/mixin/ExampleMixin.java") | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "mixin build succeeds using Minecraft #mcVersion"() { | ||||
| 		given: | ||||
| 		settingsFile << genSettingsFile("mixin-build-functional-test") | ||||
| 		propsFile << genPropsFile(mcVersion, yarnVersion, loaderVersion, fabricVersion) | ||||
| 		buildFile << genBuildFile() | ||||
| 		modJsonFile << genModJsonFile() | ||||
| 		modJavaFile << genModJavaFile() | ||||
| 		modMixinsJsonFile << genModMixinsJsonFile() | ||||
| 		modMixinsJavaFile << genModMixinsJavaFile() | ||||
| 
 | ||||
| 		when: | ||||
| 		def result = GradleRunner.create() | ||||
| 				.withProjectDir(testProjectDir.root) | ||||
| 				.withArguments('build','--stacktrace', "--warning-mode", System.getenv().TEST_WARNING_MODE ?: 'all') | ||||
| 				.withPluginClasspath() | ||||
| 				.forwardOutput() | ||||
| 				.build() | ||||
| 
 | ||||
| 		then: | ||||
| 		result.task(":build").outcome == SUCCESS | ||||
| 
 | ||||
| 		where: | ||||
| 		mcVersion | yarnVersion       	| loaderVersion     | fabricVersion | ||||
| 		'1.14'    | '1.14+build.21'   	| '0.4.8+build.155' | '0.3.0+build.184' | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,50 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| class MojangMappingsProjectTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"mojangMappings" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "build (gradle #gradle)"() { | ||||
| 		when: | ||||
| 			def result = create("build", gradle) | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 		where: | ||||
| 			gradle 				| _ | ||||
| 			'6.8.3' 			| _ | ||||
| 			'7.0-milestone-2'	| _ | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,70 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Ignore | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import java.security.DigestInputStream | ||||
| import java.security.MessageDigest | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| @Ignore //TODO this is currently failing! | ||||
| class ReproducibleBuildTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"reproducible" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "build (gradle #gradle)"() { | ||||
| 		when: | ||||
| 			def result = create("build", gradle) | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 			getOutputHash("fabric-example-mod-1.0.0.jar") == modHash | ||||
| 			getOutputHash("fabric-example-mod-1.0.0-sources.jar") == sourceHash | ||||
| 		where: | ||||
| 			gradle 				| modHash								| sourceHash | ||||
| 			'6.8.3' 			| "e1beb19574f3446800e0a5e289121365"	| "123" | ||||
| 			'7.0-milestone-2'	| "9759775e1f5440a18667c41cf1961908"	| "123" | ||||
| 	} | ||||
| 
 | ||||
| 	String getOutputHash(String name) { | ||||
| 		generateMD5(getOutputFile(name)) | ||||
| 	} | ||||
| 
 | ||||
| 	String generateMD5(File file) { | ||||
| 		file.withInputStream { | ||||
| 			new DigestInputStream(it, MessageDigest.getInstance('MD5')).withStream { | ||||
| 				it.eachByte {} | ||||
| 				it.messageDigest.digest().encodeHex() as String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | @ -1,62 +0,0 @@ | |||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import org.gradle.testkit.runner.GradleRunner | ||||
| import org.junit.Rule | ||||
| import org.junit.rules.TemporaryFolder | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static net.fabricmc.loom.BuildUtils.* | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| /** | ||||
|  * Created by Mitchell Skaggs on 6/10/2019. | ||||
|  */ | ||||
| class SimpleBuildFunctionalTest extends Specification { | ||||
| 	@Rule | ||||
| 	TemporaryFolder testProjectDir = new TemporaryFolder() | ||||
| 	File settingsFile | ||||
| 	File buildFile | ||||
| 	File propsFile | ||||
| 	File modJsonFile | ||||
| 	File modExampleFile | ||||
| 
 | ||||
| 	def setup() { | ||||
| 		settingsFile = testProjectDir.newFile('settings.gradle') | ||||
| 		buildFile = testProjectDir.newFile('build.gradle') | ||||
| 		propsFile = testProjectDir.newFile('gradle.properties') | ||||
| 
 | ||||
| 		testProjectDir.newFolder("src", "main", "resources") | ||||
| 		modJsonFile = testProjectDir.newFile('src/main/resources/fabric.mod.json') | ||||
| 
 | ||||
| 		testProjectDir.newFolder("src", "main", "java", "net", "fabricmc", "example") | ||||
| 		modExampleFile = testProjectDir.newFile("src/main/java/net/fabricmc/example/ExampleMod.java") | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "simple build succeeds using Minecraft #mcVersion"() { | ||||
| 		given: | ||||
| 		settingsFile << genSettingsFile("simple-build-functional-test") | ||||
| 		propsFile << genPropsFile(mcVersion, yarnVersion, loaderVersion, fabricVersion) | ||||
| 		buildFile << genBuildFile() | ||||
| 		modJsonFile << genModJsonFile() | ||||
| 		modExampleFile << genModJavaFile() | ||||
| 
 | ||||
| 		when: | ||||
| 		def result = GradleRunner.create() | ||||
| 				.withProjectDir(testProjectDir.root) | ||||
| 				.withArguments('build',"--stacktrace", "--warning-mode", System.getenv().TEST_WARNING_MODE ?: 'all') | ||||
| 				.withPluginClasspath() | ||||
| 				.forwardOutput() | ||||
| 				.withDebug(true) | ||||
| 				.build() | ||||
| 
 | ||||
| 		then: | ||||
| 		result.task(":build").outcome == SUCCESS | ||||
| 
 | ||||
| 		where: | ||||
| 		mcVersion | yarnVersion       | loaderVersion     | fabricVersion | ||||
| 		'19w45a'  | '19w45a+build.2:v2'   | '0.6.2+build.166' | '0.4.9+build.258-1.15' | ||||
| 		'1.14'    | '1.14+build.21'   | '0.4.8+build.155' | '0.3.0+build.184' | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										63
									
								
								src/test/groovy/net/fabricmc/loom/SimpleProjectTest.groovy
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/test/groovy/net/fabricmc/loom/SimpleProjectTest.groovy
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,63 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom | ||||
| 
 | ||||
| import net.fabricmc.loom.util.ProjectTestTrait | ||||
| import spock.lang.Specification | ||||
| import spock.lang.Unroll | ||||
| 
 | ||||
| import static org.gradle.testkit.runner.TaskOutcome.SUCCESS | ||||
| 
 | ||||
| class SimpleProjectTest extends Specification implements ProjectTestTrait { | ||||
| 	@Override | ||||
| 	String name() { | ||||
| 		"simple" | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "build (gradle #gradle)"() { | ||||
| 		when: | ||||
| 			def result = create("build", gradle) | ||||
| 		then: | ||||
| 			result.task(":build").outcome == SUCCESS | ||||
| 		where: | ||||
| 			gradle 				| _ | ||||
| 			'6.8.3' 			| _ | ||||
| 			'7.0-milestone-2'	| _ | ||||
| 	} | ||||
| 
 | ||||
| 	@Unroll | ||||
| 	def "#ide config generation"() { | ||||
| 		when: | ||||
| 			def result = create(ide) | ||||
| 		then: | ||||
| 			result.task(":${ide}").outcome == SUCCESS | ||||
| 		where: | ||||
| 			ide 		| _ | ||||
| 			'idea' 		| _ | ||||
| 			'eclipse'	| _ | ||||
| 			'vscode'	| _ | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,41 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom.util | ||||
| 
 | ||||
| import org.zeroturnaround.zip.ZipUtil | ||||
| 
 | ||||
| trait ArchiveAssertionsTrait extends ProjectTestTrait { | ||||
| 	String getArchiveEntry(String name, String entry) { | ||||
| 		def file = getOutputFile(name) | ||||
| 
 | ||||
| 		def bytes = ZipUtil.unpackEntry(file, entry) | ||||
| 
 | ||||
| 		if (bytes == null) { | ||||
| 			throw new FileNotFoundException("Could not find ${entry} in ${name}") | ||||
| 		} | ||||
| 
 | ||||
| 		new String(bytes as byte[]) | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,97 @@ | |||
| /* | ||||
|  * This file is part of fabric-loom, licensed under the MIT License (MIT). | ||||
|  * | ||||
|  * Copyright (c) 2016, 2017, 2018 FabricMC | ||||
|  * | ||||
|  * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  * of this software and associated documentation files (the "Software"), to deal | ||||
|  * in the Software without restriction, including without limitation the rights | ||||
|  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  * copies of the Software, and to permit persons to whom the Software is | ||||
|  * furnished to do so, subject to the following conditions: | ||||
|  * | ||||
|  * The above copyright notice and this permission notice shall be included in all | ||||
|  * copies or substantial portions of the Software. | ||||
|  * | ||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|  * SOFTWARE. | ||||
|  */ | ||||
| 
 | ||||
| package net.fabricmc.loom.util | ||||
| 
 | ||||
| import org.gradle.testkit.runner.BuildResult | ||||
| import org.gradle.testkit.runner.GradleRunner | ||||
| import spock.lang.Shared | ||||
| 
 | ||||
| trait ProjectTestTrait { | ||||
| 	static File gradleHome = File.createTempDir() | ||||
| 
 | ||||
| 	File testProjectDir = File.createTempDir() | ||||
| 
 | ||||
| 	abstract String name() | ||||
| 
 | ||||
| 	@SuppressWarnings('unused') | ||||
| 	def setup() { | ||||
| 		def baseProjectDir = new File("src/test/resources/projects/" + name()) | ||||
| 
 | ||||
| 		if (!baseProjectDir.exists()) { | ||||
| 			throw new FileNotFoundException("Failed to find project directory at:" + baseProjectDir.absolutePath) | ||||
| 		} | ||||
| 
 | ||||
| 		baseProjectDir.eachFileRecurse {file -> | ||||
| 			if (file.isDirectory()) { | ||||
| 				return | ||||
| 			} | ||||
| 
 | ||||
| 			def path = file.path.replace(baseProjectDir.path, "") | ||||
| 
 | ||||
| 			File tempFile = new File(testProjectDir, path) | ||||
| 			tempFile.parentFile.mkdirs() | ||||
| 			tempFile << file.text | ||||
| 		} | ||||
| 
 | ||||
| 		// Disable the CI checks to ensure nothing is skipped | ||||
| 		System.setProperty("fabric.loom.ci", "false") | ||||
| 	} | ||||
| 
 | ||||
| 	@SuppressWarnings('unused') | ||||
| 	def cleanupSpec() { | ||||
| 		testProjectDir.deleteDir() | ||||
| 		gradleHome.deleteDir() | ||||
| 	} | ||||
| 
 | ||||
| 	BuildResult create(String task, String gradleVersion = "6.8.3") { | ||||
| 		GradleRunner.create() | ||||
| 			.withProjectDir(testProjectDir) | ||||
| 			.withArguments(task, "--stacktrace", "--warning-mode", warningMode(), "--gradle-user-home", gradleHomeDirectory(gradleVersion)) | ||||
| 			.withPluginClasspath() | ||||
| 			.withGradleVersion(gradleVersion) | ||||
| 			.forwardOutput() | ||||
| 			.withDebug(true) | ||||
| 			.build() | ||||
| 	} | ||||
| 
 | ||||
| 	String warningMode() { | ||||
| 		System.getenv().TEST_WARNING_MODE ?: 'all' | ||||
| 	} | ||||
| 
 | ||||
| 	String gradleHomeDirectory(String gradleVersion) { | ||||
| 		// Each gradle version gets its own dir to run on, to ensure that a full run is done. | ||||
| 		new File(gradleHome, gradleVersion).absolutePath | ||||
| 	} | ||||
| 
 | ||||
| 	File getOutputFile(String name) { | ||||
| 		def file = new File(testProjectDir, "build/libs/" + name) | ||||
| 
 | ||||
| 		if (!file.exists()) { | ||||
| 			throw new FileNotFoundException("Could not find ${name} at ${file.absolutePath}") | ||||
| 		} | ||||
| 
 | ||||
| 		return file | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										7
									
								
								src/test/resources/accesswidener/expected.accesswidener
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/test/resources/accesswidener/expected.accesswidener
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | |||
| accessWidener	v1	intermediary | ||||
| accessible	class	net/minecraft/class_1928$class_5199 | ||||
| accessible	class	net/minecraft/class_1928$class_4314 | ||||
| extendable	class	net/minecraft/class_1928$class_4314 | ||||
| accessible	class	net/minecraft/class_5235$class_5238 | ||||
| accessible	method	net/minecraft/class_1928$class_4314	<init>	(Ljava/util/function/Supplier;Ljava/util/function/Function;Ljava/util/function/BiConsumer;Lnet/minecraft/class_1928$class_5199;)V | ||||
| extendable	method	net/minecraft/class_1928$class_4314	<init>	(Ljava/util/function/Supplier;Ljava/util/function/Function;Ljava/util/function/BiConsumer;Lnet/minecraft/class_1928$class_5199;)V | ||||
							
								
								
									
										96
									
								
								src/test/resources/projects/accesswidener/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								src/test/resources/projects/accesswidener/build.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,96 @@ | |||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| 	id 'maven-publish' | ||||
| } | ||||
| 
 | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| repositories { | ||||
|     // Add repositories to retrieve artifacts from in here. | ||||
|     // You should only use this when depending on other mods because | ||||
|     // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. | ||||
|     // See https://docs.gradle.org/current/userguide/declaring_repositories.html | ||||
|     // for more information about repositories. | ||||
| } | ||||
| 
 | ||||
| loom { | ||||
| 	accessWidener = file("src/main/resources/modid.accesswidener") | ||||
| } | ||||
| 
 | ||||
| dependencies { | ||||
| 	// To change the versions see the gradle.properties file | ||||
| 	minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||||
| 	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||||
| 	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||||
| 
 | ||||
| 	// Fabric API. This is technically optional, but you probably want it anyway. | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||||
| 
 | ||||
| 	// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. | ||||
| 	// You may need to force-disable transitiveness on them. | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	filesMatching("fabric.mod.json") { | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| tasks.withType(JavaCompile).configureEach { | ||||
| 	// ensure that the encoding is set to UTF-8, no matter what the system default is | ||||
| 	// this fixes some edge cases with special characters not displaying correctly | ||||
| 	// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html | ||||
| 	// If Javadoc is generated, this must be specified in that task too. | ||||
| 	it.options.encoding = "UTF-8" | ||||
| 
 | ||||
| 	// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too | ||||
| 	// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. | ||||
| 	// We'll use that if it's available, but otherwise we'll use the older option. | ||||
| 	def targetVersion = 8 | ||||
| 	if (JavaVersion.current().isJava9Compatible()) { | ||||
| 		 it.options.release = targetVersion | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| java { | ||||
| 	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task | ||||
| 	// if it is present. | ||||
| 	// If you remove this line, sources will not be generated. | ||||
| 	withSourcesJar() | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from("LICENSE") { | ||||
| 		rename { "${it}_${project.archivesBaseName}"} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // configure the maven publication | ||||
| publishing { | ||||
| 	publications { | ||||
| 		mavenJava(MavenPublication) { | ||||
| 			// add all the jars that should be included when publishing to maven | ||||
| 			artifact(remapJar) { | ||||
| 				builtBy remapJar | ||||
| 			} | ||||
| 			artifact(sourcesJar) { | ||||
| 				builtBy remapSourcesJar | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|      | ||||
|     // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||||
|     repositories { | ||||
|         // Add repositories to publish to here. | ||||
|         // Notice: This block does NOT have the same function as the block in the top level. | ||||
|         // The repositories here will be used for publishing your artifact, not for | ||||
|         // retrieving dependencies. | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/test/resources/projects/accesswidener/gradle.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/projects/accesswidener/gradle.properties
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| # Fabric Properties | ||||
| 	# check these on https://fabricmc.net/use | ||||
| 	minecraft_version=1.16.5 | ||||
| 	yarn_mappings=1.16.5+build.5 | ||||
| 	loader_version=0.11.2 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.0.0 | ||||
| 	maven_group = com.example | ||||
| 	archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api | ||||
| 	fabric_version=0.31.0+1.16 | ||||
|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,15 @@ | |||
| package net.fabricmc.example.mixin; | ||||
| 
 | ||||
| import net.minecraft.client.gui.screen.TitleScreen; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| @Mixin(TitleScreen.class) | ||||
| public class ExampleMixin { | ||||
| 	@Inject(at = @At("HEAD"), method = "init()V") | ||||
| 	private void init(CallbackInfo info) { | ||||
| 		System.out.println("This line is printed by an example mod mixin!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,37 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "modid.mixins.json" | ||||
|   ], | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   }, | ||||
|   "accessWidener" : "modid.accesswidener" | ||||
| } | ||||
|  | @ -0,0 +1,7 @@ | |||
| accessWidener	v1	named | ||||
| 
 | ||||
| accessible  method  net/minecraft/world/GameRules$Type <init>  (Ljava/util/function/Supplier;Ljava/util/function/Function;Ljava/util/function/BiConsumer;Lnet/minecraft/world/GameRules$Acceptor;)V | ||||
| extendable  method  net/minecraft/world/GameRules$Type <init>  (Ljava/util/function/Supplier;Ljava/util/function/Function;Ljava/util/function/BiConsumer;Lnet/minecraft/world/GameRules$Acceptor;)V | ||||
| 
 | ||||
| accessible  class   net/minecraft/world/GameRules$Acceptor | ||||
| accessible  class   net/minecraft/client/gui/screen/world/EditGameRulesScreen$RuleWidgetFactory | ||||
|  | @ -0,0 +1,14 @@ | |||
| { | ||||
|   "required": true, | ||||
|   "minVersion": "0.8", | ||||
|   "package": "net.fabricmc.example.mixin", | ||||
|   "compatibilityLevel": "JAVA_8", | ||||
|   "mixins": [ | ||||
|   ], | ||||
|   "client": [ | ||||
|     "ExampleMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
							
								
								
									
										20
									
								
								src/test/resources/projects/kotlin/build.gradle.kts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/test/resources/projects/kotlin/build.gradle.kts
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| import java.util.Properties | ||||
| 
 | ||||
| plugins { | ||||
| 	kotlin("jvm") version "1.4.31" | ||||
| 	id("fabric-loom") | ||||
| } | ||||
| 
 | ||||
| java { | ||||
| 	sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| 	targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| } | ||||
| 
 | ||||
| version = "0.0.1" | ||||
| 
 | ||||
| dependencies { | ||||
| 	minecraft(group = "com.mojang", name = "minecraft", version = "1.16.5") | ||||
| 	mappings(group = "net.fabricmc", name = "yarn", version = "1.16.5+build.5", classifier = "v2") | ||||
| 	modImplementation("net.fabricmc:fabric-loader:0.11.2") | ||||
| 	modImplementation(group = "net.fabricmc", name = "fabric-language-kotlin", version = "1.5.0+kotlin.1.4.31") | ||||
| } | ||||
							
								
								
									
										2
									
								
								src/test/resources/projects/kotlin/settings.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/test/resources/projects/kotlin/settings.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,15 @@ | |||
| package net.fabricmc.language.kotlin | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer | ||||
| import org.apache.logging.log4j.LogManager | ||||
| 
 | ||||
| class TestModClass : ModInitializer { | ||||
| 
 | ||||
|     val logger = LogManager.getFormatterLogger("KotlinLanguageTest") | ||||
| 
 | ||||
|     override fun onInitialize() { | ||||
|         logger.info("**************************") | ||||
|         logger.info("Hello from Kotlin TestModClass") | ||||
|         logger.info("**************************") | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,33 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.language.kotlin.TestModClass" | ||||
|     ] | ||||
|   }, | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										45
									
								
								src/test/resources/projects/legacy/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src/test/resources/projects/legacy/build.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,45 @@ | |||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| } | ||||
| 
 | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| dependencies { | ||||
| 	minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||||
| 	mappings "net.fabricmc:yarn:${project.yarn_mappings}" | ||||
| 	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	from(sourceSets.main.resources.srcDirs) { | ||||
| 		include "fabric.mod.json" | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| 
 | ||||
| 	from(sourceSets.main.resources.srcDirs) { | ||||
| 		exclude "fabric.mod.json" | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| tasks.withType(JavaCompile) { | ||||
| 	options.encoding = "UTF-8" | ||||
| } | ||||
| 
 | ||||
| task sourcesJar(type: Jar, dependsOn: classes) { | ||||
| 	classifier = "sources" | ||||
| 	from sourceSets.main.allSource | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from("LICENSE") { | ||||
| 		rename { "${it}_${project.archivesBaseName}"} | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/test/resources/projects/legacy/gradle.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/projects/legacy/gradle.properties
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| # Fabric Properties | ||||
| 	# check these on https://fabricmc.net/use | ||||
| 	minecraft_version=1.14.4 | ||||
| 	yarn_mappings=1.14.4+build.18 | ||||
| 	loader_version=0.11.2 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.0.0 | ||||
| 	maven_group = com.example | ||||
| 	archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api | ||||
| 	fabric_version=0.28.5+1.14 | ||||
							
								
								
									
										2
									
								
								src/test/resources/projects/legacy/settings.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/test/resources/projects/legacy/settings.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,15 @@ | |||
| package net.fabricmc.example.mixin; | ||||
| 
 | ||||
| import net.minecraft.client.MinecraftClient; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| @Mixin(MinecraftClient.class) | ||||
| public class ExampleMixin { | ||||
| 	@Inject(at = @At("HEAD"), method = "init()V") | ||||
| 	private void init(CallbackInfo info) { | ||||
| 		System.out.println("This line is printed by an example mod mixin!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,36 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "modid.mixins.json" | ||||
|   ], | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   } | ||||
| } | ||||
|  | @ -0,0 +1,14 @@ | |||
| { | ||||
|   "required": true, | ||||
|   "minVersion": "0.8", | ||||
|   "package": "net.fabricmc.example.mixin", | ||||
|   "compatibilityLevel": "JAVA_8", | ||||
|   "mixins": [ | ||||
|   ], | ||||
|   "client": [ | ||||
|     "ExampleMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
							
								
								
									
										92
									
								
								src/test/resources/projects/mojangMappings/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								src/test/resources/projects/mojangMappings/build.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,92 @@ | |||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| 	id 'maven-publish' | ||||
| } | ||||
| 
 | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| repositories { | ||||
|     // Add repositories to retrieve artifacts from in here. | ||||
|     // You should only use this when depending on other mods because | ||||
|     // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. | ||||
|     // See https://docs.gradle.org/current/userguide/declaring_repositories.html | ||||
|     // for more information about repositories. | ||||
| } | ||||
| 
 | ||||
| dependencies { | ||||
| 	// To change the versions see the gradle.properties file | ||||
| 	minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||||
| 	mappings loom.officialMojangMappings() | ||||
| 	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||||
| 
 | ||||
| 	// Fabric API. This is technically optional, but you probably want it anyway. | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||||
| 
 | ||||
| 	// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. | ||||
| 	// You may need to force-disable transitiveness on them. | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	filesMatching("fabric.mod.json") { | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| tasks.withType(JavaCompile).configureEach { | ||||
| 	// ensure that the encoding is set to UTF-8, no matter what the system default is | ||||
| 	// this fixes some edge cases with special characters not displaying correctly | ||||
| 	// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html | ||||
| 	// If Javadoc is generated, this must be specified in that task too. | ||||
| 	it.options.encoding = "UTF-8" | ||||
| 
 | ||||
| 	// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too | ||||
| 	// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. | ||||
| 	// We'll use that if it's available, but otherwise we'll use the older option. | ||||
| 	def targetVersion = 8 | ||||
| 	if (JavaVersion.current().isJava9Compatible()) { | ||||
| 		 it.options.release = targetVersion | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| java { | ||||
| 	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task | ||||
| 	// if it is present. | ||||
| 	// If you remove this line, sources will not be generated. | ||||
| 	withSourcesJar() | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from("LICENSE") { | ||||
| 		rename { "${it}_${project.archivesBaseName}"} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // configure the maven publication | ||||
| publishing { | ||||
| 	publications { | ||||
| 		mavenJava(MavenPublication) { | ||||
| 			// add all the jars that should be included when publishing to maven | ||||
| 			artifact(remapJar) { | ||||
| 				builtBy remapJar | ||||
| 			} | ||||
| 			artifact(sourcesJar) { | ||||
| 				builtBy remapSourcesJar | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|      | ||||
|     // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||||
|     repositories { | ||||
|         // Add repositories to publish to here. | ||||
|         // Notice: This block does NOT have the same function as the block in the top level. | ||||
|         // The repositories here will be used for publishing your artifact, not for | ||||
|         // retrieving dependencies. | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/test/resources/projects/mojangMappings/gradle.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/projects/mojangMappings/gradle.properties
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| # Fabric Properties | ||||
| 	# check these on https://fabricmc.net/use | ||||
| 	minecraft_version=1.16.5 | ||||
| 	yarn_mappings=1.16.5+build.5 | ||||
| 	loader_version=0.11.2 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.0.0 | ||||
| 	maven_group = com.example | ||||
| 	archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api | ||||
| 	fabric_version=0.31.0+1.16 | ||||
|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,33 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										51
									
								
								src/test/resources/projects/reproducible/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/test/resources/projects/reproducible/build.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,51 @@ | |||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| 	id 'maven-publish' | ||||
| } | ||||
| 
 | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| dependencies { | ||||
| 	minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||||
| 	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||||
| 	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	filesMatching("fabric.mod.json") { | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| tasks.withType(JavaCompile).configureEach { | ||||
| 	it.options.encoding = "UTF-8" | ||||
| 
 | ||||
| 	def targetVersion = 8 | ||||
| 	if (JavaVersion.current().isJava9Compatible()) { | ||||
| 		 it.options.release = targetVersion | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| java { | ||||
| 	withSourcesJar() | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from("LICENSE") { | ||||
| 		rename { "${it}_${project.archivesBaseName}"} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // Make Jars Reproducible | ||||
| tasks.withType(AbstractArchiveTask) { | ||||
| 	preserveFileTimestamps = false | ||||
| 	reproducibleFileOrder = true | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/test/resources/projects/reproducible/gradle.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/projects/reproducible/gradle.properties
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| # Fabric Properties | ||||
| 	# check these on https://fabricmc.net/use | ||||
| 	minecraft_version=1.16.5 | ||||
| 	yarn_mappings=1.16.5+build.5 | ||||
| 	loader_version=0.11.2 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.0.0 | ||||
| 	maven_group = com.example | ||||
| 	archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api | ||||
| 	fabric_version=0.31.0+1.16 | ||||
							
								
								
									
										2
									
								
								src/test/resources/projects/reproducible/settings.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/test/resources/projects/reproducible/settings.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,15 @@ | |||
| package net.fabricmc.example.mixin; | ||||
| 
 | ||||
| import net.minecraft.client.gui.screen.TitleScreen; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| @Mixin(TitleScreen.class) | ||||
| public class ExampleMixin { | ||||
| 	@Inject(at = @At("HEAD"), method = "init()V") | ||||
| 	private void init(CallbackInfo info) { | ||||
| 		System.out.println("This line is printed by an example mod mixin!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,36 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "modid.mixins.json" | ||||
|   ], | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   } | ||||
| } | ||||
|  | @ -0,0 +1,14 @@ | |||
| { | ||||
|   "required": true, | ||||
|   "minVersion": "0.8", | ||||
|   "package": "net.fabricmc.example.mixin", | ||||
|   "compatibilityLevel": "JAVA_8", | ||||
|   "mixins": [ | ||||
|   ], | ||||
|   "client": [ | ||||
|     "ExampleMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
							
								
								
									
										92
									
								
								src/test/resources/projects/simple/build.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								src/test/resources/projects/simple/build.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,92 @@ | |||
| plugins { | ||||
| 	id 'fabric-loom' | ||||
| 	id 'maven-publish' | ||||
| } | ||||
| 
 | ||||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||||
| 
 | ||||
| archivesBaseName = project.archives_base_name | ||||
| version = project.mod_version | ||||
| group = project.maven_group | ||||
| 
 | ||||
| repositories { | ||||
|     // Add repositories to retrieve artifacts from in here. | ||||
|     // You should only use this when depending on other mods because | ||||
|     // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. | ||||
|     // See https://docs.gradle.org/current/userguide/declaring_repositories.html | ||||
|     // for more information about repositories. | ||||
| } | ||||
| 
 | ||||
| dependencies { | ||||
| 	// To change the versions see the gradle.properties file | ||||
| 	minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||||
| 	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||||
| 	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||||
| 
 | ||||
| 	// Fabric API. This is technically optional, but you probably want it anyway. | ||||
| 	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||||
| 
 | ||||
| 	// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. | ||||
| 	// You may need to force-disable transitiveness on them. | ||||
| } | ||||
| 
 | ||||
| processResources { | ||||
| 	inputs.property "version", project.version | ||||
| 
 | ||||
| 	filesMatching("fabric.mod.json") { | ||||
| 		expand "version": project.version | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| tasks.withType(JavaCompile).configureEach { | ||||
| 	// ensure that the encoding is set to UTF-8, no matter what the system default is | ||||
| 	// this fixes some edge cases with special characters not displaying correctly | ||||
| 	// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html | ||||
| 	// If Javadoc is generated, this must be specified in that task too. | ||||
| 	it.options.encoding = "UTF-8" | ||||
| 
 | ||||
| 	// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too | ||||
| 	// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. | ||||
| 	// We'll use that if it's available, but otherwise we'll use the older option. | ||||
| 	def targetVersion = 8 | ||||
| 	if (JavaVersion.current().isJava9Compatible()) { | ||||
| 		 it.options.release = targetVersion | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| java { | ||||
| 	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task | ||||
| 	// if it is present. | ||||
| 	// If you remove this line, sources will not be generated. | ||||
| 	withSourcesJar() | ||||
| } | ||||
| 
 | ||||
| jar { | ||||
| 	from("LICENSE") { | ||||
| 		rename { "${it}_${project.archivesBaseName}"} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // configure the maven publication | ||||
| publishing { | ||||
| 	publications { | ||||
| 		mavenJava(MavenPublication) { | ||||
| 			// add all the jars that should be included when publishing to maven | ||||
| 			artifact(remapJar) { | ||||
| 				builtBy remapJar | ||||
| 			} | ||||
| 			artifact(sourcesJar) { | ||||
| 				builtBy remapSourcesJar | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|      | ||||
|     // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||||
|     repositories { | ||||
|         // Add repositories to publish to here. | ||||
|         // Notice: This block does NOT have the same function as the block in the top level. | ||||
|         // The repositories here will be used for publishing your artifact, not for | ||||
|         // retrieving dependencies. | ||||
|     } | ||||
| } | ||||
							
								
								
									
										17
									
								
								src/test/resources/projects/simple/gradle.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/test/resources/projects/simple/gradle.properties
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | |||
| # Done to increase the memory available to gradle. | ||||
| org.gradle.jvmargs=-Xmx1G | ||||
| 
 | ||||
| # Fabric Properties | ||||
| 	# check these on https://fabricmc.net/use | ||||
| 	minecraft_version=1.16.5 | ||||
| 	yarn_mappings=1.16.5+build.5 | ||||
| 	loader_version=0.11.2 | ||||
| 
 | ||||
| # Mod Properties | ||||
| 	mod_version = 1.0.0 | ||||
| 	maven_group = com.example | ||||
| 	archives_base_name = fabric-example-mod | ||||
| 
 | ||||
| # Dependencies | ||||
| 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api | ||||
| 	fabric_version=0.31.0+1.16 | ||||
							
								
								
									
										2
									
								
								src/test/resources/projects/simple/settings.gradle
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								src/test/resources/projects/simple/settings.gradle
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| rootProject.name = "fabric-example-mod" | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| package net.fabricmc.example; | ||||
| 
 | ||||
| import net.fabricmc.api.ModInitializer; | ||||
| 
 | ||||
| public class ExampleMod implements ModInitializer { | ||||
| 	@Override | ||||
| 	public void onInitialize() { | ||||
| 		// This code runs as soon as Minecraft is in a mod-load-ready state. | ||||
| 		// However, some things (like resources) may still be uninitialized. | ||||
| 		// Proceed with mild caution. | ||||
| 
 | ||||
| 		System.out.println("Hello Fabric world!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,15 @@ | |||
| package net.fabricmc.example.mixin; | ||||
| 
 | ||||
| import net.minecraft.client.gui.screen.TitleScreen; | ||||
| import org.spongepowered.asm.mixin.Mixin; | ||||
| import org.spongepowered.asm.mixin.injection.At; | ||||
| import org.spongepowered.asm.mixin.injection.Inject; | ||||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||||
| 
 | ||||
| @Mixin(TitleScreen.class) | ||||
| public class ExampleMixin { | ||||
| 	@Inject(at = @At("HEAD"), method = "init()V") | ||||
| 	private void init(CallbackInfo info) { | ||||
| 		System.out.println("This line is printed by an example mod mixin!"); | ||||
| 	} | ||||
| } | ||||
|  | @ -0,0 +1,36 @@ | |||
| { | ||||
|   "schemaVersion": 1, | ||||
|   "id": "modid", | ||||
|   "version": "${version}", | ||||
| 
 | ||||
|   "name": "Example Mod", | ||||
|   "description": "This is an example description! Tell everyone what your mod is about!", | ||||
|   "authors": [ | ||||
|     "Me!" | ||||
|   ], | ||||
|   "contact": { | ||||
|     "homepage": "https://fabricmc.net/", | ||||
|     "sources": "https://github.com/FabricMC/fabric-example-mod" | ||||
|   }, | ||||
| 
 | ||||
|   "license": "CC0-1.0", | ||||
| 
 | ||||
|   "environment": "*", | ||||
|   "entrypoints": { | ||||
|     "main": [ | ||||
|       "net.fabricmc.example.ExampleMod" | ||||
|     ] | ||||
|   }, | ||||
|   "mixins": [ | ||||
|     "modid.mixins.json" | ||||
|   ], | ||||
| 
 | ||||
|   "depends": { | ||||
|     "fabricloader": ">=0.7.4", | ||||
|     "fabric": "*", | ||||
|     "minecraft": "1.16.x" | ||||
|   }, | ||||
|   "suggests": { | ||||
|     "another-mod": "*" | ||||
|   } | ||||
| } | ||||
|  | @ -0,0 +1,14 @@ | |||
| { | ||||
|   "required": true, | ||||
|   "minVersion": "0.8", | ||||
|   "package": "net.fabricmc.example.mixin", | ||||
|   "compatibilityLevel": "JAVA_8", | ||||
|   "mixins": [ | ||||
|   ], | ||||
|   "client": [ | ||||
|     "ExampleMixin" | ||||
|   ], | ||||
|   "injectors": { | ||||
|     "defaultRequire": 1 | ||||
|   } | ||||
| } | ||||
		Loading…
	
		Reference in a new issue