From 4dcf8528b2dfdba46e6b704492da8145b54a3706 Mon Sep 17 00:00:00 2001 From: Keridos <2742845+Keridos@users.noreply.github.com> Date: Sun, 24 Sep 2023 22:13:24 +0200 Subject: [PATCH] first working version for multiproject gradle --- .gitmodules | 6 + OMLib | 1 + OpenModularTurrets | 1 + README.md | 45 +------- build.gradle | 11 +- examplelib/.gitattributes | 5 - examplelib/.gitignore | 25 ---- examplelib/build.gradle | 105 ----------------- examplelib/gradle.properties | 3 - .../com/example/examplelib/ExampleLib.java | 25 ---- .../src/main/resources/META-INF/mods.toml | 25 ---- examplelib/src/main/resources/pack.mcmeta | 7 -- examplemod/.gitattributes | 5 - examplemod/.gitignore | 25 ---- examplemod/build.gradle | 107 ------------------ examplemod/gradle.properties | 5 - .../com/example/examplemod/ExampleMod.java | 23 ---- .../src/main/resources/META-INF/mods.toml | 31 ----- examplemod/src/main/resources/pack.mcmeta | 7 -- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 14 ++- 21 files changed, 28 insertions(+), 450 deletions(-) create mode 160000 OMLib create mode 160000 OpenModularTurrets delete mode 100644 examplelib/.gitattributes delete mode 100644 examplelib/.gitignore delete mode 100644 examplelib/build.gradle delete mode 100644 examplelib/gradle.properties delete mode 100644 examplelib/src/main/java/com/example/examplelib/ExampleLib.java delete mode 100644 examplelib/src/main/resources/META-INF/mods.toml delete mode 100644 examplelib/src/main/resources/pack.mcmeta delete mode 100644 examplemod/.gitattributes delete mode 100644 examplemod/.gitignore delete mode 100644 examplemod/build.gradle delete mode 100644 examplemod/gradle.properties delete mode 100644 examplemod/src/main/java/com/example/examplemod/ExampleMod.java delete mode 100644 examplemod/src/main/resources/META-INF/mods.toml delete mode 100644 examplemod/src/main/resources/pack.mcmeta diff --git a/.gitmodules b/.gitmodules index 94c6738..f98327b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "runenv"] path = runenv url = https://github.com/amadornes/fg-multiproject-runenv.git +[submodule "OMLib"] + path = OMLib + url = git@github.com:OpenModularTurretsTeam/OMLib.git +[submodule "OpenModularTurrets"] + path = OpenModularTurrets + url = git@github.com:OpenModularTurretsTeam/OpenModularTurrets.git diff --git a/OMLib b/OMLib new file mode 160000 index 0000000..74168f5 --- /dev/null +++ b/OMLib @@ -0,0 +1 @@ +Subproject commit 74168f5a67b10ce36ba3943ddcba0aa23514c350 diff --git a/OpenModularTurrets b/OpenModularTurrets new file mode 160000 index 0000000..e949892 --- /dev/null +++ b/OpenModularTurrets @@ -0,0 +1 @@ +Subproject commit e949892708c0f10fa131f4db9af2a58dcff3f5f3 diff --git a/README.md b/README.md index df8026f..8b1e192 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,3 @@ -# ForgeGradle Multiproject Template +# OpenModularMods Multiproject Repo -This repository provides a template for multiproject development environments using ForgeGradle. - -## Project structure -This template builds upon the [runenv template](https://github.com/amadornes/fg-multiproject-runenv) repo to provide the -binding logic that makes the multiproject environment work. - -The built-in `examplelib` and `examplemod` projects are standard Forge MDK projects, heavily trimmed down for the sake -of simplicity, and are unaware that they exist within a multiproject environment. - -## Setup -To set up a multiproject development environment, just clone this repository. -Optionally, you may delete the `.git` directory and initialize your own git repo in its place. -It is advised to keep the *runenv template* as a submodule, which allows you to easily pull new versions down the line. - -## Customization -The most basic form of customization comes in the form of adding new projects to `settings.gradle`. -Just add new `include 'YourProjectName'` lines in the same place you find the predefined ones. - -If you are authoring several mods that depend on each other, but you still want to be able to compile them on their own, -this template also allows it. -For example, if one of your projects depends on `fg.deobf("com.example:examplelib:1.2.3")`, you can define a -substitution in the root level buildscript: `substitute module("com.example:examplelib") using project(":examplelib")`. -This will make it so whatever depended on that artifact will now depend on the project in your dev environment instead. -Make sure to also define an exclusion for the same module in the `if` statement above it. That will ensure that -ForgeGradle doesn't try to unnecessarily resolve the artifact. - -Further customization can be done by either modifying the *runenv template*, or the `project('runenv')` closure in the -root level buildscript. - -## Generating runs -The run configurations for your multiproject environment should point to the *runenv template*. -You must run that project's `genRuns` task and use its classpath at runtime for all the projects to load. - -For datagen, you may still use each project's individual runs. - -## Known issues -Please check the [runenv template](https://github.com/amadornes/fg-multiproject-runenv) repository, as that will contain -the latest information regarding compatibility. - -## Contributions -Pull requests adding extended feature support and bugfixes are welcome. -Please keep them simple if possible. +This repository provides a multiproject environment for our mods. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 931f4f5..ea21c41 100644 --- a/build.gradle +++ b/build.gradle @@ -6,13 +6,14 @@ subprojects { configurations.all { if (it.name.startsWith("_")) { // You must exclude the same modules you substitute here, because ForgeGradle - exclude group: "com.example", module: "examplelib" + exclude group: "com.ommods", module: "omlib" return } resolutionStrategy.dependencySubstitution { // Apply substitutions for modules your projects depend on, replacing them with another project - substitute module("com.example:examplelib") using project(":examplelib") + logger.info("substituted omlib") + substitute module("com.ommods:omlib") using project(":OMLib") } // Uncomment the following line if you are running into issues with dependency resolution. @@ -26,10 +27,10 @@ subprojects { project('runenv') { ext { - mcversion = '1.19' - forgeversion = '41.1.0' + mcversion = '1.19.2' + forgeversion = '43.3.0' // javaversion = 17 // Defaults to 17 already - // mappings = channel: 'official', version: '1.18.2' // Defaults to mojmap for the specified MC version + // mappings = "channel: 'parchment', version: '2022.11.27-1.19.2'" // Defaults to mojmap for the specified MC version // runArgs = [ ] // Arguments applied to all runs // runProps = [ name: value ] // Properties applied to all runs } diff --git a/examplelib/.gitattributes b/examplelib/.gitattributes deleted file mode 100644 index f811f6a..0000000 --- a/examplelib/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -# Disable autocrlf on generated files, they always generate with LF -# Add any extra files or paths here to make git stop saying they -# are changed when only line endings change. -src/generated/**/.cache/cache text eol=lf -src/generated/**/*.json text eol=lf diff --git a/examplelib/.gitignore b/examplelib/.gitignore deleted file mode 100644 index 12f8644..0000000 --- a/examplelib/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# eclipse -bin -*.launch -.settings -.metadata -.classpath -.project - -# idea -out -*.ipr -*.iws -*.iml -.idea - -# gradle -build -.gradle - -# other -eclipse -run - -# Files from Forge MDK -forge*changelog.txt diff --git a/examplelib/build.gradle b/examplelib/build.gradle deleted file mode 100644 index 9a52fa0..0000000 --- a/examplelib/build.gradle +++ /dev/null @@ -1,105 +0,0 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } -} -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' - -version = _version -group = 'com.example' -archivesBaseName = 'ExampleLib' - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -minecraft { - mappings channel: 'official', version: _mcversion - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { - client { - workingDirectory project.file('run/client') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - mods { - examplelib { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run/server') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - mods { - examplelib { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run/data') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - args '--mod', 'examplelib', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - examplelib { - source sourceSets.main - } - } - } - } -} - -sourceSets.main.resources { srcDir 'src/generated/resources' } - -repositories { -} - -dependencies { - minecraft "net.minecraftforge:forge:${_mcversion}-${_forgeversion}" -} - -jar { - manifest { - attributes([ - "Specification-Title" : "examplelib", - "Specification-Vendor" : "exampleauthor", - "Specification-Version" : "1", - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "exampleauthor", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - url "file://${rootProject.projectDir}/mcmodsrepo" - } - } -} diff --git a/examplelib/gradle.properties b/examplelib/gradle.properties deleted file mode 100644 index a28f336..0000000 --- a/examplelib/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -_version=0.0.1 -_mcversion=1.19 -_forgeversion=41.1.0 diff --git a/examplelib/src/main/java/com/example/examplelib/ExampleLib.java b/examplelib/src/main/java/com/example/examplelib/ExampleLib.java deleted file mode 100644 index b588f1e..0000000 --- a/examplelib/src/main/java/com/example/examplelib/ExampleLib.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.examplelib; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@Mod("examplelib") -public class ExampleLib -{ - private static final Logger LOGGER = LogManager.getLogger(); - - public ExampleLib() { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); - } - - private void setup(final FMLCommonSetupEvent event) { - LOGGER.info("Hello from the library's preinit"); - } - - public static void printTheThing() { - LOGGER.info("I'm the library and I was asked to print the thing!"); - } -} diff --git a/examplelib/src/main/resources/META-INF/mods.toml b/examplelib/src/main/resources/META-INF/mods.toml deleted file mode 100644 index ae04eba..0000000 --- a/examplelib/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,25 +0,0 @@ -modLoader="javafml" -loaderVersion="[37,)" -license="MIT" - -[[mods]] -modId="examplelib" -version="${file.jarVersion}" -displayName="Example Lib" -authors="Example Author" -description=''' -This is an example library -''' - -[[dependencies.examplelib]] - modId="forge" - mandatory=true - versionRange="[37,)" - ordering="NONE" - side="BOTH" -[[dependencies.examplelib]] - modId="minecraft" - mandatory=true - versionRange="[1.17.1,1.18)" - ordering="NONE" - side="BOTH" diff --git a/examplelib/src/main/resources/pack.mcmeta b/examplelib/src/main/resources/pack.mcmeta deleted file mode 100644 index c536b8d..0000000 --- a/examplelib/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pack": { - "description": "examplelib resources", - "pack_format": 6, - "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." - } -} diff --git a/examplemod/.gitattributes b/examplemod/.gitattributes deleted file mode 100644 index f811f6a..0000000 --- a/examplemod/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -# Disable autocrlf on generated files, they always generate with LF -# Add any extra files or paths here to make git stop saying they -# are changed when only line endings change. -src/generated/**/.cache/cache text eol=lf -src/generated/**/*.json text eol=lf diff --git a/examplemod/.gitignore b/examplemod/.gitignore deleted file mode 100644 index 12f8644..0000000 --- a/examplemod/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# eclipse -bin -*.launch -.settings -.metadata -.classpath -.project - -# idea -out -*.ipr -*.iws -*.iml -.idea - -# gradle -build -.gradle - -# other -eclipse -run - -# Files from Forge MDK -forge*changelog.txt diff --git a/examplemod/build.gradle b/examplemod/build.gradle deleted file mode 100644 index 96c195a..0000000 --- a/examplemod/build.gradle +++ /dev/null @@ -1,107 +0,0 @@ -buildscript { - repositories { - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } -} -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'maven-publish' - -version = _version -group = 'com.example' -archivesBaseName = 'ExampleMod' - -java.toolchain.languageVersion = JavaLanguageVersion.of(17) - -minecraft { - mappings channel: 'official', version: _mcversion - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - - runs { - client { - workingDirectory project.file('run/client') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - mods { - examplemod { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run/server') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - mods { - examplemod { - source sourceSets.main - } - } - } - - data { - workingDirectory project.file('run/data') - - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - - args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - - mods { - examplemod { - source sourceSets.main - } - } - } - } -} - -sourceSets.main.resources { srcDir 'src/generated/resources' } - -repositories { -} - -dependencies { - minecraft "net.minecraftforge:forge:${_mcversion}-${_forgeversion}" - - implementation fg.deobf("com.example:examplelib:${_libversion}") -} - -jar { - manifest { - attributes([ - "Specification-Title" : "examplemod", - "Specification-Vendor" : "exampleauthor", - "Specification-Version" : "1", - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "exampleauthor", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} - -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - url "file://${rootProject.projectDir}/mcmodsrepo" - } - } -} diff --git a/examplemod/gradle.properties b/examplemod/gradle.properties deleted file mode 100644 index 1008f89..0000000 --- a/examplemod/gradle.properties +++ /dev/null @@ -1,5 +0,0 @@ -_version=0.0.1 -_mcversion=1.19 -_forgeversion=41.1.0 - -_libversion=1.2.3 diff --git a/examplemod/src/main/java/com/example/examplemod/ExampleMod.java b/examplemod/src/main/java/com/example/examplemod/ExampleMod.java deleted file mode 100644 index c46dfcd..0000000 --- a/examplemod/src/main/java/com/example/examplemod/ExampleMod.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.example.examplemod; - -import com.example.examplelib.ExampleLib; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@Mod("examplemod") -public class ExampleMod -{ - private static final Logger LOGGER = LogManager.getLogger(); - - public ExampleMod() { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); - } - - private void setup(final FMLCommonSetupEvent event) { - LOGGER.info("Hello from the mod's preinit"); - ExampleLib.printTheThing(); - } -} diff --git a/examplemod/src/main/resources/META-INF/mods.toml b/examplemod/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 4039865..0000000 --- a/examplemod/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,31 +0,0 @@ -modLoader="javafml" -loaderVersion="[37,)" -license="MIT" - -[[mods]] -modId="examplemod" -version="${file.jarVersion}" -displayName="Example Mod" -authors="Example Author" -description=''' -This is an example mod -''' - -[[dependencies.examplemod]] - modId="examplelib" - mandatory=true - versionRange="[0,)" - ordering="NONE" - side="BOTH" -[[dependencies.examplemod]] - modId="forge" - mandatory=true - versionRange="[37,)" - ordering="NONE" - side="BOTH" -[[dependencies.examplemod]] - modId="minecraft" - mandatory=true - versionRange="[1.17.1,1.18)" - ordering="NONE" - side="BOTH" diff --git a/examplemod/src/main/resources/pack.mcmeta b/examplemod/src/main/resources/pack.mcmeta deleted file mode 100644 index c536b8d..0000000 --- a/examplemod/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pack": { - "description": "examplelib resources", - "pack_format": 6, - "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0595cf7..15e783f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.2-20210702220150+0000-bin.zip +distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.6.2-20230701051823+0000-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 1c37609..7e2cec1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,17 @@ -rootProject.name = 'Multiproject' // Optionally set a custom name for the root +pluginManagement { + repositories { + gradlePluginPortal() + maven { url = 'https://maven.minecraftforge.net/' } + maven { url = 'https://maven.parchmentmc.org' } // Add this line + } +} + +rootProject.name = 'OpenModularMods' // Optionally set a custom name for the root // This is where all the projects in this environment are registered // Use the relative path to the directory where their buildscript is in your includes -include 'examplelib' -include 'examplemod' +include 'OMLib' +include 'OpenModularTurrets' // This must always be here include 'runenv'