From 28b0bc8ac6d75ff8a57aba76e02acffb07eba85f Mon Sep 17 00:00:00 2001 From: shedaniel Date: Thu, 21 Apr 2022 16:11:49 +0800 Subject: [PATCH] Add double underscore ignore, list inheritance, quilt support --- body.md | 44 ++ body.txt | 10 - build.gradle | 2 +- generator.config.json | 710 +++++++++++------- .../templates/GenerateTemplates.kt | 59 +- templates/architectury/common/build.gradle | 16 +- templates/architectury/forge/build.gradle | 2 +- templates/architectury/gradle.properties | 10 +- templates/architectury/settings.gradle | 2 +- .../fabric/build.gradle | 2 +- .../fabric/ExampleExpectPlatformImpl.java | 0 .../examplemod/fabric/ExampleModFabric.java | 0 .../fabric/src/main/resources/fabric.mod.json | 2 +- .../fabric-like/build.gradle | 16 + .../fabriclike/ExampleModFabricLike.java | 9 + .../examplemod/fabric/ExampleModFabric.java | 11 + .../net/examplemod/quilt/ExampleModQuilt.java | 12 + .../architectury_quilt/quilt/build.gradle | 92 +++ .../quilt/gradle.properties | 1 + .../fabric/ExampleExpectPlatformImpl.java | 15 + .../net/examplemod/quilt/ExampleModQuilt.java | 12 + .../quilt/src/main/resources/quilt.mod.json | 41 + 22 files changed, 748 insertions(+), 320 deletions(-) create mode 100644 body.md delete mode 100644 body.txt rename templates/{architectury => architectury_fabric}/fabric/build.gradle (96%) rename templates/{architectury => architectury_fabric}/fabric/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java (100%) rename templates/{architectury => architectury_fabric}/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java (100%) rename templates/{architectury => architectury_fabric}/fabric/src/main/resources/fabric.mod.json (95%) create mode 100644 templates/architectury_fabric_like/fabric-like/build.gradle create mode 100644 templates/architectury_fabric_like/fabric-like/src/main/java/net/examplemod/fabriclike/ExampleModFabricLike.java create mode 100644 templates/architectury_fabric_like/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java create mode 100644 templates/architectury_fabric_like/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java create mode 100644 templates/architectury_quilt/quilt/build.gradle create mode 100644 templates/architectury_quilt/quilt/gradle.properties create mode 100644 templates/architectury_quilt/quilt/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java create mode 100644 templates/architectury_quilt/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java create mode 100644 templates/architectury_quilt/quilt/src/main/resources/quilt.mod.json diff --git a/body.md b/body.md new file mode 100644 index 0000000..edb0bdf --- /dev/null +++ b/body.md @@ -0,0 +1,44 @@ +Architectury Templates can be used for setting your own architectury projects, for converting your existing projects to architectury projects, please refer to [Architectury Example Mod](https://github.com/architectury/architectury-example-mod) instead. + +The following templates are offered in [Creative Commons Zero v1.0 Universal](https://github.com/architectury/architectury-example-mod/blob/1.17.1/LICENSE). + +Architectury API is added to the templates by default, there are instructions on how to remove them within the buildscripts, depending on the API is **not required** to use the Architectury toolchain. + +## How to choose a template + +#### Mixin or Not? + +Mixins is a base game modification system available on both Forge and Fabric, Forge modders may be less familiar with this as Forge itself usually provides everything you need. This is not the case with Fabric. A lot of the events and hooks are not available on Fabric (Architectury API does reimplement some), and most of the times you will need to hook it up yourselves. + +The Fabric Wiki's [Introduction to Mixins](https://fabricmc.net/wiki/tutorial:mixin_introduction) is a great resource to start out. However, you might not need Mixins if your mod is something simple like adding a few blocks and items, Fabric API provides the essentials for that. + +#### I want to mod for Quilt? + +There are currently three variants of the Architectury Templates: + +| Targets | Description | +| ------------------------ | ------------------------------------------------------------ | +| Forge | The Forge sub-project used to call Forge-specific code, and handles Forge mod init.
You will also run Forge on this sub-project. | +| Fabric-Like Intermediary | The Fabric-like binding project used to call Fabric APIs, this can be used to call code that is unspecific to both Fabric and Quilt, such as hooks that will apply to both Fabric and Quilt.
This sub-project is **not executable**. | +| Fabric | The Fabric sub-project used to call Fabric-specific code, and handles Fabric mod init.
You will also run Fabric on this sub-project. | +| Quilt | The Quilt sub-project used to call Quilt-specific code, and handled Quilt mod init.
You will also run Quilt on this sub-project. | + + + +| Variants | Forge | Fabric-Like Intermediary | Fabric | Quilt | +| :---------------------------------------- | :---: | :----------------------: | :----: | :---: | +| Forge | ✔ | N/A | ✖ | ✖ | +| Forge-Fabric | ✔ | N/A | ✔ | ✖ | +| Forge-Quilt | ✔ | N/A | ✖ | ✔ | +| Forge-Fabric-Quilt
(Not Recommended) | ✔ | ✖ | ✔ | ✔ | +| Forge-Fabric-Likes | ✔ | ✔ | ✔ | ✔ | + + + +## How to setup the template + +Please read this documentation: [https://docs.architectury.dev/docs/architectury_api/getting_started.html](https://docs.architectury.dev/docs/architectury_api/getting_started.html). + + + +**Discord:** [https://discord.gg/C2RdJDpRBP](https://discord.gg/C2RdJDpRBP) \ No newline at end of file diff --git a/body.txt b/body.txt deleted file mode 100644 index c1156a7..0000000 --- a/body.txt +++ /dev/null @@ -1,10 +0,0 @@ -Architectury Templates can be used for setting your own architectury projects, for converting your existing projects to architectury projects, please refer to [Architectury Example Mod](https://github.com/architectury/architectury-example-mod) instead. - -The following templates are offered in [Creative Commons Zero v1.0 Universal](https://github.com/architectury/architectury-example-mod/blob/1.17.1/LICENSE), TL;DR: You can do anything (except somethings) with these templates. - -Architectury API is added to the templates by default, there are instructions on how to remove them within the buildscripts, depending on the API is **not required** to use the Architectury toolchain. - -**Make sure** to do a find everywhere on `examplemod` and replace it with your own mod id. - -**Documentation:** [https://docs.architectury.dev/](https://docs.architectury.dev/) -**Discord:** [https://discord.gg/C2RdJDpRBP](https://discord.gg/C2RdJDpRBP) \ No newline at end of file diff --git a/build.gradle b/build.gradle index cd12706..50e8f4b 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ task run(type: JavaExec, dependsOn: jar) { mainClass = "dev.architectury.templates.GenerateTemplatesKt" environment "CONFIG_PATH", file("generator.config.json").absolutePath environment "OUTPUT_PATH", file("build/templates").absolutePath - environment "BODY_PATH", file("body.txt").absolutePath + environment "BODY_PATH", file("body.md").absolutePath environment "PUBLISH", "true" environment "GITHUB_TOKEN", System.getenv("GITHUB_TOKEN") environment "GITHUB_REPOSITORY", System.getenv("GITHUB_REPOSITORY") diff --git a/generator.config.json b/generator.config.json index e6927c5..c12d68b 100644 --- a/generator.config.json +++ b/generator.config.json @@ -1,307 +1,449 @@ { - "global_tokens": { - "COMPILE_JAVA_8": "\n // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too\n // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.\n // We'll use that if it's available, but otherwise we'll use the older option.\n def targetVersion = 8\n if (JavaVersion.current().isJava9Compatible()) {\n options.release = targetVersion\n }", - "COMPILE_JAVA_16": " options.release = 16", - "COMPILE_JAVA_17": " options.release = 17", - "COMPILE_JAVA_8_ARCH": "\n // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too\n // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.\n // We'll use that if it's available, but otherwise we'll use the older option.\n def targetVersion = 8\n if (JavaVersion.current().isJava9Compatible()) {\n options.release = targetVersion\n }", - "COMPILE_JAVA_16_ARCH": " options.release = 16", - "COMPILE_JAVA_17_ARCH": " options.release = 17", - "JAVA_8": "VERSION_1_8", - "JAVA_16": "VERSION_16", - "JAVA_17": "VERSION_17", - "FABRIC_LOADER": { - "filter": ".*", - "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml" - } - }, - "versions": { - "1.16-forge": { - "description": "1.16.5 Forge-Only Template", - "templates": [ - "templates/forge" - ], - "tokens": { - "MINECRAFT": "1.16.5", - "JAVA_VERSION": "#JAVA_8", - "COMPILE_JAVA": "#COMPILE_JAVA_8", - "MCMETA_FORMAT": "6", - "JEI_MAJOR": "7", - "YARN_MAPPINGS": { - "filter": "1\\.16\\.5\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" - }, - "FORGE": { - "filter": "1\\.16\\.5-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" - }, - "FORGE_LOADER_MAJOR": "36", - "MIXIN_COMPAT_LEVEL": "JAVA_8" - } - }, - "1.16-architectury": { - "description": "1.16.5 Multi-Loader Template", - "templates": [ - "templates/architectury", - "templates/api_old" - ], - "tokens": { - "MINECRAFT": "1.16.5", - "JAVA_VERSION": "#JAVA_8", - "COMPILE_JAVA": "#COMPILE_JAVA_8_ARCH", - "FABRIC_LOADER": "#FABRIC_LOADER", - "LOOM_FORGE_EXT": "", - "MCMETA_FORMAT": "6", - "ARCHITECTURY_GROUP": "me.shedaniel", - "ARCHITECTURY_PACKAGE": "me.shedaniel.architectury", - "ARCHITECTURY_API": { - "filter": "1\\..*", - "pom": "https://maven.architectury.dev/me/shedaniel/architectury/maven-metadata.xml" + "global_tokens": { + "COMPILE_JAVA_8": "\n // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too\n // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.\n // We'll use that if it's available, but otherwise we'll use the older option.\n def targetVersion = 8\n if (JavaVersion.current().isJava9Compatible()) {\n options.release = targetVersion\n }", + "COMPILE_JAVA_16": " options.release = 16", + "COMPILE_JAVA_17": " options.release = 17", + "COMPILE_JAVA_8_ARCH": "\n // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too\n // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.\n // We'll use that if it's available, but otherwise we'll use the older option.\n def targetVersion = 8\n if (JavaVersion.current().isJava9Compatible()) {\n options.release = targetVersion\n }", + "COMPILE_JAVA_16_ARCH": " options.release = 16", + "COMPILE_JAVA_17_ARCH": " options.release = 17", + "JAVA_8": "VERSION_1_8", + "JAVA_16": "VERSION_16", + "JAVA_17": "VERSION_17", + "FABRIC_LOADER_PROP": "fabric_loader_version=", + "FABRIC_LOADER": { + "filter": ".*", + "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml" }, - "YARN_MAPPINGS": { - "filter": "1\\.16\\.5\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "FABRIC_API_PROP": "fabric_api_version=", + "QUILT_LOADER_PROP": "quilt_loader_version=", + "QUILT_LOADER": { + "filter": ".*", + "pom": "https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml" }, - "FABRIC_API": { - "filter": ".*\\+1\\.16", - "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" - }, - "FORGE": { - "filter": "1\\.16\\.5-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" - }, - "FORGE_LOADER_MAJOR": "36", - "MIXIN_FABRIC_BLOCK": "" - } + "QUILT_QSL_PROP": "quilt_qsl_version=", + "QUILT_FABRIC_API_PROP": "quilt_fabric_api_version=", + "FABRIC_ADD_FABRICLIKE": "\n common(project(path: \":fabric-like\", configuration: \"namedElements\")) { transitive false }\n shadowCommon(project(path: \":fabric-like\", configuration: \"transformProductionFabric\")) { transitive false }", + "QUILT_ADD_FABRICLIKE": "\n common(project(path: \":fabric-like\", configuration: \"namedElements\")) { transitive false }\n shadowCommon(project(path: \":fabric-like\", configuration: \"transformProductionQuilt\")) { transitive false }" }, - "1.16-architectury-mixin": { - "description": "1.16.5 Multi-Loader Template with Mixins", - "templates": [ - "templates/architectury", - "templates/api_old", - "templates/mixin" - ], - "inherit_tokens": "1.16-architectury", - "tokens": { - "MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", - "MIXIN_COMPAT_LEVEL": "JAVA_8", - "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" - } - }, - "1.17-forge": { - "description": "1.17.1 Forge-Only Template", - "templates": [ - "templates/forge" - ], - "tokens": { - "MINECRAFT": "1.17.1", - "JAVA_VERSION": "#JAVA_16", - "COMPILE_JAVA": "#COMPILE_JAVA_16", - "MCMETA_FORMAT": "7", - "JEI_MAJOR": "8", - "YARN_MAPPINGS": { - "filter": "1\\.17\\.1\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" - }, - "FORGE": { - "filter": "1\\.17\\.1-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "versions": { + "1.16.5-forge": { + "description": "1.16.5 Forge Template", + "templates": [ + "templates/forge" + ], + "tokens": { + "MINECRAFT": "1.16.5", + "JAVA_VERSION": "#JAVA_8", + "COMPILE_JAVA": "#COMPILE_JAVA_8", + "MCMETA_FORMAT": "6", + "JEI_MAJOR": "7", + "YARN_MAPPINGS": { + "filter": "1\\.16\\.5\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "FORGE": { + "filter": "1\\.16\\.5-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "36", + "MIXIN_COMPAT_LEVEL": "JAVA_8" + } }, - "FORGE_LOADER_MAJOR": "37", - "MIXIN_COMPAT_LEVEL": "JAVA_16" - } - }, - "1.17-architectury": { - "description": "1.17.1 Multi-Loader Template", - "templates": [ - "templates/architectury", - "templates/api_new" - ], - "tokens": { - "MINECRAFT": "1.17.1", - "JAVA_VERSION": "#JAVA_16", - "COMPILE_JAVA": "#COMPILE_JAVA_16_ARCH", - "FABRIC_LOADER": "#FABRIC_LOADER", - "LOOM_FORGE_EXT": "", - "MCMETA_FORMAT": "7", - "ARCHITECTURY_GROUP": "dev.architectury", - "ARCHITECTURY_PACKAGE": "dev.architectury", - "ARCHITECTURY_API": { - "filter": "2\\..*", - "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + "1.16.5-forge-fabric": { + "description": "1.16.5 Forge-Fabric Template", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_old" + ], + "tokens": { + "MINECRAFT": "1.16.5", + "COMMON_MOD_LOADERS": "fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric\")", + "JAVA_VERSION": "#JAVA_8", + "COMPILE_JAVA": "#COMPILE_JAVA_8_ARCH", + "__FABRIC_LOADER": "#FABRIC_LOADER", + "__FABRIC_LOADER_PROP": "#FABRIC_LOADER_PROP", + "MCMETA_FORMAT": "6", + "ARCHITECTURY_GROUP": "me.shedaniel", + "ARCHITECTURY_PACKAGE": "me.shedaniel.architectury", + "ARCHITECTURY_API": { + "filter": "1\\..*", + "pom": "https://maven.architectury.dev/me/shedaniel/architectury/maven-metadata.xml" + }, + "YARN_MAPPINGS": { + "filter": "1\\.16\\.5\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "__FABRIC_API": { + "filter": ".*\\+1\\.16", + "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + }, + "__FABRIC_API_PROP": "#FABRIC_API_PROP", + "FORGE": { + "filter": "1\\.16\\.5-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "36" + } }, - "YARN_MAPPINGS": { - "filter": "1\\.17\\.1\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "1.16.5-forge-fabric-mixin": { + "description": "1.16.5 Forge-Fabric Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_old", + "templates/mixin" + ], + "inherit_tokens": ["1.16.5-forge-fabric"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_8", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "FABRIC_API": { - "filter": ".*\\+1\\.17", - "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + "1.17.1-forge": { + "description": "1.17.1 Forge-Only Template", + "templates": [ + "templates/forge" + ], + "tokens": { + "MINECRAFT": "1.17.1", + "JAVA_VERSION": "#JAVA_16", + "COMPILE_JAVA": "#COMPILE_JAVA_16", + "MCMETA_FORMAT": "7", + "JEI_MAJOR": "8", + "YARN_MAPPINGS": { + "filter": "1\\.17\\.1\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "FORGE": { + "filter": "1\\.17\\.1-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "37", + "MIXIN_COMPAT_LEVEL": "JAVA_16" + } }, - "FORGE": { - "filter": "1\\.17\\.1-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "1.17.1-forge-fabric": { + "description": "1.17.1 Forge-Fabric Template", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_new" + ], + "tokens": { + "MINECRAFT": "1.17.1", + "COMMON_MOD_LOADERS": "fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric\")", + "JAVA_VERSION": "#JAVA_16", + "COMPILE_JAVA": "#COMPILE_JAVA_16_ARCH", + "__FABRIC_LOADER": "#FABRIC_LOADER", + "__FABRIC_LOADER_PROP": "#FABRIC_LOADER_PROP", + "MCMETA_FORMAT": "7", + "ARCHITECTURY_GROUP": "dev.architectury", + "ARCHITECTURY_PACKAGE": "dev.architectury", + "ARCHITECTURY_API": { + "filter": "2\\..*", + "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + }, + "YARN_MAPPINGS": { + "filter": "1\\.17\\.1\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "__FABRIC_API": { + "filter": ".*\\+1\\.17", + "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + }, + "__FABRIC_API_PROP": "#FABRIC_API_PROP", + "FORGE": { + "filter": "1\\.17\\.1-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "37" + } }, - "FORGE_LOADER_MAJOR": "37", - "MIXIN_FABRIC_BLOCK": "" - } - }, - "1.17-architectury-mixin": { - "description": "1.17.1 Multi-Loader Template with Mixins", - "templates": [ - "templates/architectury", - "templates/api_new", - "templates/mixin" - ], - "inherit_tokens": "1.17-architectury", - "tokens": { - "MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", - "MIXIN_COMPAT_LEVEL": "JAVA_16", - "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" - } - }, - "1.18-forge": { - "description": "1.18.1 Forge-Only Template", - "templates": [ - "templates/forge" - ], - "tokens": { - "MINECRAFT": "1.18.1", - "JAVA_VERSION": "#JAVA_17", - "COMPILE_JAVA": "#COMPILE_JAVA_17", - "MCMETA_FORMAT": "8", - "JEI_MAJOR": "9", - "YARN_MAPPINGS": { - "filter": "1\\.18\\.1\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "1.17.1-forge-fabric-mixin": { + "description": "1.17.1 Forge-Fabric Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.17.1-forge-fabric"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "FORGE": { - "filter": "1\\.18\\.1-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "1.18.1-forge": { + "description": "1.18.1 Forge Template", + "templates": [ + "templates/forge" + ], + "tokens": { + "MINECRAFT": "1.18.1", + "JAVA_VERSION": "#JAVA_17", + "COMPILE_JAVA": "#COMPILE_JAVA_17", + "MCMETA_FORMAT": "8", + "JEI_MAJOR": "9", + "YARN_MAPPINGS": { + "filter": "1\\.18\\.1\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "FORGE": { + "filter": "1\\.18\\.1-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "39", + "MIXIN_COMPAT_LEVEL": "JAVA_16" + } }, - "FORGE_LOADER_MAJOR": "39", - "MIXIN_COMPAT_LEVEL": "JAVA_16" - } - }, - "1.18-architectury": { - "description": "1.18.1 Multi-Loader Template", - "templates": [ - "templates/architectury", - "templates/api_new" - ], - "tokens": { - "MINECRAFT": "1.18.1", - "JAVA_VERSION": "#JAVA_17", - "COMPILE_JAVA": "#COMPILE_JAVA_17_ARCH", - "FABRIC_LOADER": "#FABRIC_LOADER", - "LOOM_FORGE_EXT": "", - "MCMETA_FORMAT": "8", - "ARCHITECTURY_GROUP": "dev.architectury", - "ARCHITECTURY_PACKAGE": "dev.architectury", - "ARCHITECTURY_API": { - "filter": "3\\..*", - "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + "1.18.1-forge-fabric": { + "description": "1.18.1 Forge-Fabric Template", + "templates": [ + "templates/architectury", + "templates/api_new" + ], + "tokens": { + "MINECRAFT": "1.18.1", + "COMMON_MOD_LOADERS": "fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric\")", + "JAVA_VERSION": "#JAVA_17", + "COMPILE_JAVA": "#COMPILE_JAVA_17_ARCH", + "__FABRIC_LOADER": "#FABRIC_LOADER", + "__FABRIC_LOADER_PROP": "#FABRIC_LOADER_PROP", + "MCMETA_FORMAT": "8", + "ARCHITECTURY_GROUP": "dev.architectury", + "ARCHITECTURY_PACKAGE": "dev.architectury", + "ARCHITECTURY_API": { + "filter": "3\\..*", + "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + }, + "YARN_MAPPINGS": { + "filter": "1\\.18\\.1\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "__FABRIC_API": { + "filter": ".*\\+1\\.18", + "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + }, + "__FABRIC_API_PROP": "#FABRIC_API_PROP", + "FORGE": { + "filter": "1\\.18\\.1-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "39" + } }, - "YARN_MAPPINGS": { - "filter": "1\\.18\\.1\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "1.18.1-forge-fabric-mixin": { + "description": "1.18.1 Forge-Fabric Template with Mixins", + "templates": [ + "templates/architectury", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.18.1-forge-fabric"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "FABRIC_API": { - "filter": ".*\\+1\\.18", - "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + "1.18.2-forge": { + "description": "1.18.2 Forge Template", + "templates": [ + "templates/forge" + ], + "tokens": { + "MINECRAFT": "1.18.2", + "JAVA_VERSION": "#JAVA_17", + "COMPILE_JAVA": "#COMPILE_JAVA_17", + "MCMETA_FORMAT": "8", + "JEI_MAJOR": "9", + "YARN_MAPPINGS": { + "filter": "1\\.18\\.2\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "FORGE": { + "filter": "1\\.18\\.2-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "40", + "MIXIN_COMPAT_LEVEL": "JAVA_16" + } }, - "FORGE": { - "filter": "1\\.18\\.1-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "1.18.2-forge-fabric": { + "description": "1.18.2 Forge-Fabric Template", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_new" + ], + "tokens": { + "MINECRAFT": "1.18.2", + "COMMON_MOD_LOADERS": "fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric\")", + "JAVA_VERSION": "#JAVA_17", + "COMPILE_JAVA": "#COMPILE_JAVA_17_ARCH", + "__FABRIC_LOADER": "#FABRIC_LOADER", + "__FABRIC_LOADER_PROP": "#FABRIC_LOADER_PROP", + "MCMETA_FORMAT": "8", + "ARCHITECTURY_GROUP": "dev.architectury", + "ARCHITECTURY_PACKAGE": "dev.architectury", + "ARCHITECTURY_API": { + "filter": "4\\..*", + "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + }, + "YARN_MAPPINGS": { + "filter": "1\\.18\\.2\\+build\\..*", + "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + }, + "__FABRIC_API": { + "filter": ".*\\+1\\.18\\.2", + "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + }, + "__FABRIC_API_PROP": "#FABRIC_API_PROP", + "FORGE": { + "filter": "1\\.18\\.2-.*", + "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + }, + "FORGE_LOADER_MAJOR": "40" + } }, - "FORGE_LOADER_MAJOR": "39", - "MIXIN_FABRIC_BLOCK": "" - } - }, - "1.18-architectury-mixin": { - "description": "1.18.1 Multi-Loader Template with Mixins", - "templates": [ - "templates/architectury", - "templates/api_new", - "templates/mixin" - ], - "inherit_tokens": "1.18-architectury", - "tokens": { - "MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", - "MIXIN_COMPAT_LEVEL": "JAVA_16", - "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" - } - }, - "1.18.2-forge": { - "description": "1.18.2 Forge-Only Template", - "templates": [ - "templates/forge" - ], - "tokens": { - "MINECRAFT": "1.18.2", - "JAVA_VERSION": "#JAVA_17", - "COMPILE_JAVA": "#COMPILE_JAVA_17", - "MCMETA_FORMAT": "8", - "JEI_MAJOR": "9", - "YARN_MAPPINGS": { - "filter": "1\\.18\\.2\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "1.18.2-forge-fabric-mixin": { + "description": "1.18.2 Forge-Fabric Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.18.2-forge-fabric"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "FORGE": { - "filter": "1\\.18\\.2-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "1.18.2-forge-quilt": { + "description": "1.18.2 Forge-Quilt Template", + "templates": [ + "templates/architectury", + "templates/architectury_quilt", + "templates/api_new" + ], + "inherit_tokens": ["1.18.2-forge-fabric"], + "tokens": { + "COMMON_MOD_LOADERS": "quilt,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"quilt\")", + "__FABRIC_LOADER_PROP": "", + "__FABRIC_LOADER": "", + "__FABRIC_API_PROP": "", + "__FABRIC_API": "", + "__QUILT_LOADER_PROP": "#QUILT_LOADER_PROP", + "__QUILT_LOADER": "#QUILT_LOADER", + "__QUILT_FABRIC_API_PROP": "#QUILT_FABRIC_API_PROP", + "__QUILT_FABRIC_API": { + "filter": ".*\\-1\\.18\\.2", + "pom": "https://maven.quiltmc.org/repository/release/org/quiltmc/quilted-fabric-api/quilted-fabric-api/maven-metadata.xml" + } + } }, - "FORGE_LOADER_MAJOR": "40", - "MIXIN_COMPAT_LEVEL": "JAVA_16" - } - }, - "1.18.2-architectury": { - "description": "1.18.2 Multi-Loader Template", - "templates": [ - "templates/architectury", - "templates/api_new" - ], - "tokens": { - "MINECRAFT": "1.18.2", - "JAVA_VERSION": "#JAVA_17", - "COMPILE_JAVA": "#COMPILE_JAVA_17_ARCH", - "FABRIC_LOADER": "#FABRIC_LOADER", - "LOOM_FORGE_EXT": "", - "MCMETA_FORMAT": "8", - "ARCHITECTURY_GROUP": "dev.architectury", - "ARCHITECTURY_PACKAGE": "dev.architectury", - "ARCHITECTURY_API": { - "filter": "4\\..*", - "pom": "https://maven.architectury.dev/dev/architectury/architectury/maven-metadata.xml" + "1.18.2-forge-quilt-mixin": { + "description": "1.18.2 Forge-Quilt Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_quilt", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.18.2-forge-quilt"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "YARN_MAPPINGS": { - "filter": "1\\.18\\.2\\+build\\..*", - "pom": "https://maven.fabricmc.net/net/fabricmc/yarn/maven-metadata.xml" + "1.18.2-forge-fabric-quilt": { + "description": "1.18.2 Forge-Fabric-Quilt Template", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/architectury_quilt", + "templates/api_new" + ], + "inherit_tokens": ["1.18.2-forge-fabric"], + "tokens": { + "COMMON_MOD_LOADERS": "quilt,fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric\")\ninclude(\"quilt\")", + "__QUILT_LOADER_PROP": "#QUILT_LOADER_PROP", + "__QUILT_LOADER": "#QUILT_LOADER", + "__QUILT_FABRIC_API_PROP": "#QUILT_FABRIC_API_PROP", + "__QUILT_FABRIC_API": { + "filter": ".*\\-1\\.18\\.2", + "pom": "https://maven.quiltmc.org/repository/release/org/quiltmc/quilted-fabric-api/quilted-fabric-api/maven-metadata.xml" + } + } }, - "FABRIC_API": { - "filter": ".*\\+1\\.18\\.2", - "pom": "https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/maven-metadata.xml" + "1.18.2-forge-fabric-quilt-mixin": { + "description": "1.18.2 Forge-Fabric-Quilt Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/architectury_quilt", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.18.2-forge-fabric-quilt"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } }, - "FORGE": { - "filter": "1\\.18\\.2-.*", - "pom": "https://maven.minecraftforge.net/net/minecraftforge/forge/maven-metadata.xml" + "1.18.2-forge-fabric-like": { + "description": "1.18.2 Forge-Fabric-Like Template", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/architectury_quilt", + "templates/architectury_fabric_like", + "templates/api_new" + ], + "inherit_tokens": ["1.18.2-forge-fabric"], + "tokens": { + "COMMON_MOD_LOADERS": "quilt,fabric,forge", + "INCLUDE_FABRIC_OR_QUILT": "include(\"fabric-like\")\ninclude(\"fabric\")\ninclude(\"quilt\")", + "__FABRIC_ADD_FABRICLIKE": "#FABRIC_ADD_FABRICLIKE", + "__QUILT_ADD_FABRICLIKE": "#QUILT_ADD_FABRICLIKE", + "__QUILT_LOADER_PROP": "#QUILT_LOADER_PROP", + "__QUILT_LOADER": "#QUILT_LOADER", + "__QUILT_FABRIC_API_PROP": "#QUILT_FABRIC_API_PROP", + "__QUILT_FABRIC_API": { + "filter": ".*\\-1\\.18\\.2", + "pom": "https://maven.quiltmc.org/repository/release/org/quiltmc/quilted-fabric-api/quilted-fabric-api/maven-metadata.xml" + } + } }, - "FORGE_LOADER_MAJOR": "40", - "MIXIN_FABRIC_BLOCK": "" - } - }, - "1.18.2-architectury-mixin": { - "description": "1.18.2 Multi-Loader Template with Mixins", - "templates": [ - "templates/architectury", - "templates/api_new", - "templates/mixin" - ], - "inherit_tokens": "1.18.2-architectury", - "tokens": { - "MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", - "MIXIN_COMPAT_LEVEL": "JAVA_16", - "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" - } + "1.18.2-forge-fabric-like-mixin": { + "description": "1.18.2 Forge-Fabric-Like Template with Mixins", + "templates": [ + "templates/architectury", + "templates/architectury_fabric", + "templates/architectury_quilt", + "templates/architectury_fabric_like", + "templates/api_new", + "templates/mixin" + ], + "inherit_tokens": ["1.18.2-forge-fabric-like"], + "tokens": { + "__MIXIN_FABRIC_BLOCK": "\n \"mixins\": [\n \"examplemod.mixins.json\",\n \"examplemod-common.mixins.json\"\n ],", + "MIXIN_COMPAT_LEVEL": "JAVA_16", + "LOOM_FORGE_EXT": "loom {\n forge {\n mixinConfig \"examplemod-common.mixins.json\"\n mixinConfig \"examplemod.mixins.json\"\n }\n}\n" + } + } } - } } diff --git a/src/main/kotlin/dev/architectury/templates/GenerateTemplates.kt b/src/main/kotlin/dev/architectury/templates/GenerateTemplates.kt index 067197c..1f8661e 100644 --- a/src/main/kotlin/dev/architectury/templates/GenerateTemplates.kt +++ b/src/main/kotlin/dev/architectury/templates/GenerateTemplates.kt @@ -44,6 +44,11 @@ fun main() { } config.versions.forEach { (id, entry) -> val outputZip = outputPath.resolve("$id.zip") + val outputFolder = outputPath.resolve(id) + outputFolder.toFile().deleteRecursively() + println() + println() + println("Handling $id") val toTransform = transformTokens(config, entry, cache) ZipOutputStream(Files.newOutputStream(outputZip)).use { zipOutputStream -> val entries = mutableMapOf() @@ -51,11 +56,28 @@ fun main() { Files.walk(templateDirPath).filter { Files.isRegularFile(it) }.forEach { path -> val pathName = templateDirPath.relativize(path).toString() if (pathName.isTextFile) { - entries[pathName] = Files.readString(path).let { - var out = it + entries[pathName] = Files.readString(path).let { originalText -> + var out = originalText toTransform.forEach { (from, to) -> out = out.replace(from, to) } + val matchedNotReplaced = "@([A-Z_]+)@".toRegex().findAll(out).toMutableList() + matchedNotReplaced.removeIf { result -> + val (token) = result.destructured + if (token.startsWith("__")) { + println("Replacing ${result.value} with ") + out = out.replace(result.value, "") + true + } else { + false + } + } + if (matchedNotReplaced.isNotEmpty()) { + System.err.println("Not replaced: $pathName") + matchedNotReplaced.forEach { + System.err.println("\t${it.value}") + } + } out }.encodeToByteArray() } else { @@ -66,6 +88,13 @@ fun main() { entries.forEach { (path, bytes) -> zipOutputStream.putNextEntry(ZipEntry(path)) zipOutputStream.write(bytes) + val outsidePath = outputFolder.resolve(path) + + if (outsidePath.parent != null) { + Files.createDirectories(outsidePath.parent) + } + + Files.write(outsidePath, bytes) } } githubRelease?.uploadAsset(outputZip.toFile(), "application/zip") @@ -74,16 +103,26 @@ fun main() { fun transformTokens(config: TemplateConfig, entry: TemplateEntry, cache: MutableMap): Map { val map = mutableMapOf() - entry.inherit_tokens?.let { config.versions[it]!!.tokens }?.forEach { (token, element) -> - val replacement = element.findReplacement(config, cache) - println("Replacing @$token@ with $replacement") - map["@$token@"] = replacement + val inherited = mutableSetOf() + + fun inherit(inheritToken: String) { + if (inherited.add(inheritToken)) { + val inheritConfig = config.versions[inheritToken]!! + inheritConfig.tokens.forEach { (token, element) -> + val replacement = element.findReplacement(config, cache) + map.putIfAbsent("@$token@", replacement) + } + inheritConfig.inherit_tokens.forEach { inherit(it) } + } } + entry.inherit_tokens.forEach { inherit(it) } entry.tokens.forEach { (token, element) -> val replacement = element.findReplacement(config, cache) - println("Replacing @$token@ with $replacement") map["@$token@"] = replacement } + map.forEach { (from, to) -> + println("Replacing $from with $to") + } return map } @@ -125,7 +164,7 @@ data class TemplateConfig( data class TemplateEntry( val templates: List, val description: String, - val inherit_tokens: String? = null, + val inherit_tokens: List = emptyList(), val tokens: Map, ) @@ -144,7 +183,7 @@ val String.versionNonNull: Version @JvmInline value class Version(val version: String) : Comparable { init { - require(version.matches("(\\d+(?:\\.\\d+)*)-?((?:.*)?)\\+?((?:.*)?)".toRegex())) { "Invalid version format" } + require(version.matches("(\\d+(?:\\.\\d+)*)-?((?:[^+]*)?)(?:\\+(.*))?".toRegex())) { "Invalid version format" } } data class VersionParts( @@ -155,7 +194,7 @@ value class Version(val version: String) : Comparable { val parts: VersionParts get() { - return "(\\d+(?:\\.\\d+)*)-?((?:.*)?)\\+?((?:.*)?)".toRegex().matchEntire(version)!!.let { + return "(\\d+(?:\\.\\d+)*)-?((?:[^+]*)?)(?:\\+(.*))?".toRegex().matchEntire(version)!!.let { val (version, snapshot, metadata) = it.destructured VersionParts(version, snapshot, metadata) } diff --git a/templates/architectury/common/build.gradle b/templates/architectury/common/build.gradle index 90c86a5..5cda834 100644 --- a/templates/architectury/common/build.gradle +++ b/templates/architectury/common/build.gradle @@ -1,3 +1,11 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = file("src/main/resources/examplemod.accesswidener") +} + dependencies { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader @@ -6,14 +14,6 @@ dependencies { modApi "@ARCHITECTURY_GROUP@:architectury:${rootProject.architectury_version}" } -architectury { - common() -} - -loom { - accessWidenerPath = file("src/main/resources/examplemod.accesswidener") -} - publishing { publications { mavenCommon(MavenPublication) { diff --git a/templates/architectury/forge/build.gradle b/templates/architectury/forge/build.gradle index 8522187..1447730 100644 --- a/templates/architectury/forge/build.gradle +++ b/templates/architectury/forge/build.gradle @@ -1,7 +1,7 @@ plugins { id "com.github.johnrengelman.shadow" version "7.1.2" } -@LOOM_FORGE_EXT@ +@__LOOM_FORGE_EXT@ architectury { platformSetupLoomIde() forge() diff --git a/templates/architectury/gradle.properties b/templates/architectury/gradle.properties index 904db82..6131011 100644 --- a/templates/architectury/gradle.properties +++ b/templates/architectury/gradle.properties @@ -1,6 +1,7 @@ org.gradle.jvmargs=-Xmx2048M - +@__KOTLIN_DISABLE_STDLIB@ minecraft_version=@MINECRAFT@ +enabled_platforms=@COMMON_MOD_LOADERS@ archives_base_name=examplemod mod_version=1.0.0 @@ -8,7 +9,10 @@ maven_group=net.examplemod architectury_version=@ARCHITECTURY_API@ -fabric_loader_version=@FABRIC_LOADER@ -fabric_api_version=@FABRIC_API@ +@__FABRIC_LOADER_PROP@@__FABRIC_LOADER@ +@__FABRIC_API_PROP@@__FABRIC_API@ forge_version=@FORGE@ + +@__QUILT_LOADER_PROP@@__QUILT_LOADER@ +@__QUILT_FABRIC_API_PROP@@__QUILT_FABRIC_API@ diff --git a/templates/architectury/settings.gradle b/templates/architectury/settings.gradle index ef13d26..9d14100 100644 --- a/templates/architectury/settings.gradle +++ b/templates/architectury/settings.gradle @@ -8,7 +8,7 @@ pluginManagement { } include("common") -include("fabric") +@INCLUDE_FABRIC_OR_QUILT@ include("forge") rootProject.name = "architectury-example-mod" diff --git a/templates/architectury/fabric/build.gradle b/templates/architectury_fabric/fabric/build.gradle similarity index 96% rename from templates/architectury/fabric/build.gradle rename to templates/architectury_fabric/fabric/build.gradle index 8b7f2e9..ee7092d 100644 --- a/templates/architectury/fabric/build.gradle +++ b/templates/architectury_fabric/fabric/build.gradle @@ -26,7 +26,7 @@ dependencies { modApi "@ARCHITECTURY_GROUP@:architectury-fabric:${rootProject.architectury_version}" common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }@__FABRIC_ADD_FABRICLIKE@ } processResources { diff --git a/templates/architectury/fabric/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java b/templates/architectury_fabric/fabric/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java similarity index 100% rename from templates/architectury/fabric/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java rename to templates/architectury_fabric/fabric/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java diff --git a/templates/architectury/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java b/templates/architectury_fabric/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java similarity index 100% rename from templates/architectury/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java rename to templates/architectury_fabric/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java diff --git a/templates/architectury/fabric/src/main/resources/fabric.mod.json b/templates/architectury_fabric/fabric/src/main/resources/fabric.mod.json similarity index 95% rename from templates/architectury/fabric/src/main/resources/fabric.mod.json rename to templates/architectury_fabric/fabric/src/main/resources/fabric.mod.json index edd98f7..f20c8dc 100644 --- a/templates/architectury/fabric/src/main/resources/fabric.mod.json +++ b/templates/architectury_fabric/fabric/src/main/resources/fabric.mod.json @@ -18,7 +18,7 @@ "main": [ "net.examplemod.fabric.ExampleModFabric" ] - },@MIXIN_FABRIC_BLOCK@ + },@__MIXIN_FABRIC_BLOCK@ "depends": { "fabric": "*", "minecraft": ">=@MINECRAFT@", diff --git a/templates/architectury_fabric_like/fabric-like/build.gradle b/templates/architectury_fabric_like/fabric-like/build.gradle new file mode 100644 index 0000000..44e373f --- /dev/null +++ b/templates/architectury_fabric_like/fabric-like/build.gradle @@ -0,0 +1,16 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + // Remove the next line if you don't want to depend on the API + modApi "@ARCHITECTURY_GROUP@:architectury-fabric:${rootProject.architectury_version}" + + compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false } +} diff --git a/templates/architectury_fabric_like/fabric-like/src/main/java/net/examplemod/fabriclike/ExampleModFabricLike.java b/templates/architectury_fabric_like/fabric-like/src/main/java/net/examplemod/fabriclike/ExampleModFabricLike.java new file mode 100644 index 0000000..d69a851 --- /dev/null +++ b/templates/architectury_fabric_like/fabric-like/src/main/java/net/examplemod/fabriclike/ExampleModFabricLike.java @@ -0,0 +1,9 @@ +package net.examplemod.fabriclike; + +import net.examplemod.ExampleMod; + +public class ExampleModFabricLike { + public static void init() { + ExampleMod.init(); + } +} diff --git a/templates/architectury_fabric_like/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java b/templates/architectury_fabric_like/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java new file mode 100644 index 0000000..674f1cd --- /dev/null +++ b/templates/architectury_fabric_like/fabric/src/main/java/net/examplemod/fabric/ExampleModFabric.java @@ -0,0 +1,11 @@ +package net.examplemod.fabric; + +import net.examplemod.fabriclike.ExampleModFabricLike; +import net.fabricmc.api.ModInitializer; + +public class ExampleModFabric implements ModInitializer { + @Override + public void onInitialize() { + ExampleModFabricLike.init(); + } +} diff --git a/templates/architectury_fabric_like/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java b/templates/architectury_fabric_like/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java new file mode 100644 index 0000000..10e2153 --- /dev/null +++ b/templates/architectury_fabric_like/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java @@ -0,0 +1,12 @@ +package net.examplemod.quilt; + +import net.examplemod.fabriclike.ExampleModFabricLike; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; + +public class ExampleModQuilt implements ModInitializer { + @Override + public void onInitialize(ModContainer mod) { + ExampleModFabricLike.init(); + } +} diff --git a/templates/architectury_quilt/quilt/build.gradle b/templates/architectury_quilt/quilt/build.gradle new file mode 100644 index 0000000..48a716c --- /dev/null +++ b/templates/architectury_quilt/quilt/build.gradle @@ -0,0 +1,92 @@ +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +repositories { + maven { url "https://maven.quiltmc.org/repository/release/" } +} + +architectury { + platformSetupLoomIde() + loader("quilt") +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentQuilt.extendsFrom common +} + +dependencies { + modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" + modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" + // Remove the next few lines if you don't want to depend on the API + modApi("@ARCHITECTURY_GROUP@:architectury-fabric:${rootProject.architectury_version}") { + // We must not pull Fabric Loader from Architectury Fabric + exclude group: "net.fabricmc" + exclude group: "net.fabricmc.fabric-api" + } + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }@__QUILT_ADD_FABRICLIKE@ +} + +processResources { + inputs.property "group", rootProject.maven_group + inputs.property "version", project.version + + filesMatching("quilt.mod.json") { + expand "group": rootProject.maven_group, + "version": project.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + classifier "dev-shadow" +} + +remapJar { + injectAccessWidener = true + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenQuilt(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + 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. + } +} diff --git a/templates/architectury_quilt/quilt/gradle.properties b/templates/architectury_quilt/quilt/gradle.properties new file mode 100644 index 0000000..96758ce --- /dev/null +++ b/templates/architectury_quilt/quilt/gradle.properties @@ -0,0 +1 @@ +loom.platform=quilt \ No newline at end of file diff --git a/templates/architectury_quilt/quilt/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java b/templates/architectury_quilt/quilt/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java new file mode 100644 index 0000000..7aaae48 --- /dev/null +++ b/templates/architectury_quilt/quilt/src/main/java/net/examplemod/fabric/ExampleExpectPlatformImpl.java @@ -0,0 +1,15 @@ +package net.examplemod.fabric; + +import net.examplemod.ExampleExpectPlatform; +import org.quiltmc.loader.api.QuiltLoader; + +import java.nio.file.Path; + +public class ExampleExpectPlatformImpl { + /** + * This is our actual method to {@link ExampleExpectPlatform#getConfigDirectory()}. + */ + public static Path getConfigDirectory() { + return QuiltLoader.getConfigDir(); + } +} diff --git a/templates/architectury_quilt/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java b/templates/architectury_quilt/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java new file mode 100644 index 0000000..8bb87ae --- /dev/null +++ b/templates/architectury_quilt/quilt/src/main/java/net/examplemod/quilt/ExampleModQuilt.java @@ -0,0 +1,12 @@ +package net.examplemod.quilt; + +import net.examplemod.ExampleMod; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; + +public class ExampleModQuilt implements ModInitializer { + @Override + public void onInitialize(ModContainer mod) { + ExampleMod.init(); + } +} diff --git a/templates/architectury_quilt/quilt/src/main/resources/quilt.mod.json b/templates/architectury_quilt/quilt/src/main/resources/quilt.mod.json new file mode 100644 index 0000000..4b14b74 --- /dev/null +++ b/templates/architectury_quilt/quilt/src/main/resources/quilt.mod.json @@ -0,0 +1,41 @@ +{ + "schema_version": 1,@__MIXIN_FABRIC_BLOCK@ + "quilt_loader": { + "group": "${group}", + "id": "examplemod", + "version": "${version}", + "name": "Example Mod", + "description": "This is an example description! Tell everyone what your mod is about!", + "authors": ["Me!"], + "contact": { + "sources": "https://github.com/architectury/architectury-templates" + }, + "license": "Insert License Here", + "icon": "assets/examplemod/icon.png", + "intermediate_mappings": "net.fabricmc:intermediary", + "environment": "*", + "entrypoints": { + "init": [ + "net.examplemod.quilt.ExampleModQuilt" + ] + }, + "depends": [ + { + "id": "quilt_loader", + "version": "*" + }, + { + "id": "quilt_base", + "version": "*" + }, + { + "id": "minecraft", + "version": ">=@MINECRAFT@" + }, + { + "id": "architectury", + "version": ">=@ARCHITECTURY_API@" + } + ] + } +} \ No newline at end of file