diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2021-10-30 00:26:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 22:26:59 +0100 |
commit | 587db4abae792ef4467c889cabc9a699723e6785 (patch) | |
tree | 9e1aa3f597670a1fb8d29783545666374ec79a0b /src/test/resources/projects/localRuntime | |
parent | e409f13b8c0f24d9b324741169c7e889256c26fc (diff) | |
download | architectury-loom-587db4abae792ef4467c889cabc9a699723e6785.tar.gz architectury-loom-587db4abae792ef4467c889cabc9a699723e6785.tar.bz2 architectury-loom-587db4abae792ef4467c889cabc9a699723e6785.zip |
Add localRuntime and modLocalRuntime configurations (#526)
Closes #481.
Co-authored-by: modmuss50 <modmuss50@gmail.com>
Diffstat (limited to 'src/test/resources/projects/localRuntime')
8 files changed, 187 insertions, 0 deletions
diff --git a/src/test/resources/projects/localRuntime/build.gradle b/src/test/resources/projects/localRuntime/build.gradle new file mode 100644 index 00000000..18f4f0db --- /dev/null +++ b/src/test/resources/projects/localRuntime/build.gradle @@ -0,0 +1,79 @@ +plugins { + id 'fabric-loom' + id 'maven-publish' +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +archivesBaseName = project.archives_base_name +version = loom.modVersion +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. + modLocalRuntime "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + localRuntime "cuchaz:enigma:1.4.7" // an example non-mod local dependency + + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. + // You may need to force-disable transitiveness on them. +} + +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) { + from components.java + } + } + + // 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. + } +} diff --git a/src/test/resources/projects/localRuntime/gradle.properties b/src/test/resources/projects/localRuntime/gradle.properties new file mode 100644 index 00000000..845c3560 --- /dev/null +++ b/src/test/resources/projects/localRuntime/gradle.properties @@ -0,0 +1,16 @@ +# 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 + 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 diff --git a/src/test/resources/projects/localRuntime/settings.gradle b/src/test/resources/projects/localRuntime/settings.gradle new file mode 100644 index 00000000..c162c363 --- /dev/null +++ b/src/test/resources/projects/localRuntime/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = "fabric-example-mod" + diff --git a/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/ExampleMod.java b/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/ExampleMod.java new file mode 100644 index 00000000..e6985491 --- /dev/null +++ b/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/ExampleMod.java @@ -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 simple Fabric mod"); + } +} diff --git a/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java b/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java new file mode 100644 index 00000000..83ee1a89 --- /dev/null +++ b/src/test/resources/projects/localRuntime/src/main/java/net/fabricmc/example/mixin/ExampleMixin.java @@ -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!"); + } +} diff --git a/src/test/resources/projects/localRuntime/src/main/resources/fabric.mod.json b/src/test/resources/projects/localRuntime/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..d3f14830 --- /dev/null +++ b/src/test/resources/projects/localRuntime/src/main/resources/fabric.mod.json @@ -0,0 +1,35 @@ +{ + "schemaVersion": 1, + "id": "modid", + "version": "1.0.0", + + "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", + "minecraft": "1.16.x" + }, + "suggests": { + "another-mod": "*" + } +} diff --git a/src/test/resources/projects/localRuntime/src/main/resources/modid.mixins.json b/src/test/resources/projects/localRuntime/src/main/resources/modid.mixins.json new file mode 100644 index 00000000..21fe73a4 --- /dev/null +++ b/src/test/resources/projects/localRuntime/src/main/resources/modid.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.fabricmc.example.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + ], + "client": [ + "ExampleMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/src/test/resources/projects/localRuntime/src/test/java/net/fabricmc/example/test/ExampleMod.java b/src/test/resources/projects/localRuntime/src/test/java/net/fabricmc/example/test/ExampleMod.java new file mode 100644 index 00000000..ae0a3108 --- /dev/null +++ b/src/test/resources/projects/localRuntime/src/test/java/net/fabricmc/example/test/ExampleMod.java @@ -0,0 +1,12 @@ +package net.fabricmc.example.test; + +import net.fabricmc.api.ModInitializer; +import net.minecraft.client.gui.screen.TitleScreen; + +// Just a simple class to ensure the tests can compile against loader and minecraft +public class ExampleMod implements ModInitializer { + @Override + public void onInitialize() { + TitleScreen screen = null; + } +} |