From c66d4cb2d4f08f8c1627415d0d280e0a95ebf86a Mon Sep 17 00:00:00 2001 From: EnderProyects Date: Mon, 6 Mar 2023 01:50:15 +0100 Subject: [PATCH] updated buildscript --- .editorconfig | 22 + .gitattributes | 44 ++ .github/scripts/update_version | 12 + .github/workflows/build-and-test.yml | 13 + .github/workflows/buildscript-maintenance.yml | 39 ++ .github/workflows/release-packages.yml | 86 ++++ .github/workflows/release-tags.yml | 14 + .gitignore | 45 ++- build.gradle | 8 +- dependencies.gradle | 33 +- docs/FAQ.md | 9 + docs/migration.md | 22 + docs/porting.md | 56 +++ gradle.properties | 143 +++++++ gradlew.bat | 92 +++++ gtnhShared/spotless.eclipseformat.xml | 380 ++++++++++++++++++ gtnhShared/spotless.gradle | 40 ++ gtnhShared/spotless.importorder | 7 + settings.gradle | 28 ++ 19 files changed, 1044 insertions(+), 49 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/scripts/update_version create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/buildscript-maintenance.yml create mode 100644 .github/workflows/release-packages.yml create mode 100644 .github/workflows/release-tags.yml create mode 100644 docs/FAQ.md create mode 100644 docs/migration.md create mode 100644 docs/porting.md create mode 100644 gradle.properties create mode 100644 gradlew.bat create mode 100644 gtnhShared/spotless.eclipseformat.xml create mode 100644 gtnhShared/spotless.gradle create mode 100644 gtnhShared/spotless.importorder create mode 100644 settings.gradle diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4ffbd90 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# This is the universal Text Editor Configuration +# for all GTNewHorizons projects +# See: https://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{bat,ini}] +end_of_line = crlf + +[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}] +indent_size = 2 + +[*.lang] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fd2792b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,44 @@ +* text eol=lf + +*.[jJ][aA][rR] binary + +*.[pP][nN][gG] binary +*.[jJ][pP][gG] binary +*.[jJ][pP][eE][gG] binary +*.[gG][iI][fF] binary +*.[tT][iI][fF] binary +*.[tT][iI][fF][fF] binary +*.[iI][cC][oO] binary +*.[sS][vV][gG] text +*.[eE][pP][sS] binary +*.[xX][cC][fF] binary + +*.[kK][aA][rR] binary +*.[mM]4[aA] binary +*.[mM][iI][dD] binary +*.[mM][iI][dD][iI] binary +*.[mM][pP]3 binary +*.[oO][gG][gG] binary +*.[rR][aA] binary + +*.7[zZ] binary +*.[gG][zZ] binary +*.[tT][aA][rR] binary +*.[tT][gG][zZ] binary +*.[zZ][iI][pP] binary + +*.[tT][cC][nN] binary +*.[sS][oO] binary +*.[dD][lL][lL] binary +*.[dD][yY][lL][iI][bB] binary +*.[pP][sS][dD] binary +*.[tT][tT][fF] binary +*.[oO][tT][fF] binary + +*.[pP][aA][tT][cC][hH] -text + +*.[bB][aA][tT] text eol=crlf +*.[cC][mM][dD] text eol=crlf +*.[pP][sS]1 text eol=crlf + +*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary diff --git a/.github/scripts/update_version b/.github/scripts/update_version new file mode 100644 index 0000000..3e5f752 --- /dev/null +++ b/.github/scripts/update_version @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if ! git diff --name-only HEAD HEAD~1 | grep -qF 'build.gradle'; then + new_version="$(date +%s)" + sed --in-place "s!^//version:.*!//version: $new_version!g" build.gradle + git add build.gradle + git commit -m "[ci skip] update build script version to $new_version" + git push + printf 'Updated buildscript version to %s\n' "$new_version" +else + printf 'Ignored buildscript version update: no changes detected\n' +fi diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..3ee2f68 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,13 @@ + +name: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master + secrets: inherit diff --git a/.github/workflows/buildscript-maintenance.yml b/.github/workflows/buildscript-maintenance.yml new file mode 100644 index 0000000..a9d5486 --- /dev/null +++ b/.github/workflows/buildscript-maintenance.yml @@ -0,0 +1,39 @@ +# This workflow only meant for the source mod you shouldn't bring it into your own project + +name: Buildscript maintenance + +on: + push: + branches: [ master, main ] + paths: + - build.gradle + workflow_dispatch: { } + +jobs: + buildscript-maintenance: + runs-on: ubuntu-latest + # Avoid running this workflow on forks + if: github.repository == 'GTNewHorizons/ExampleMod1.7.10' + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Ensure build script version is up to date + id: update-buildscript + run: | + new_version="$(date +%s)" + sed --in-place "1s!^//version:.*!//version: $new_version!g" build.gradle + echo "::set-output name=new_version::$new_version" + + - name: Create Pull Request + id: create-pull-request + uses: peter-evans/create-pull-request@v4 + with: + add-paths: build.gradle + commit-message: '[ci skip] update build script version to ${{ steps.update-buildscript.outputs.new_version }}' + branch: buildscript-maintenance + title: Update build script version to ${{ steps.update-buildscript.outputs.new_version }} + body: This pull request is created by the buildscript-maintenance workflow diff --git a/.github/workflows/release-packages.yml b/.github/workflows/release-packages.yml new file mode 100644 index 0000000..e66a04e --- /dev/null +++ b/.github/workflows/release-packages.yml @@ -0,0 +1,86 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release latest starter and migration packages + +on: + push: + branches: [ master, main ] + tags: [ '*' ] + +jobs: + zip-and-release-packages: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Prepare release folder + run: | + mkdir packages + + - name: Zip starter + uses: montudor/action-zip@v1 + with: + args: > + zip -r packages/starter.zip . \ + \ + -x "*.git/*" \ + \ + -x ".github/scripts/update-version.sh" \ + -x ".github/workflows/buildscript-maintenance.yml" \ + -x ".github/workflows/release-packages.yml" \ + \ + -x "*docs/*" \ + -x "README.md" \ + -x "LICENSE" \ + -x "gtnhShared/*" \ + \ + -x "packages/" \ + -x "packages/starter.zip" \ + -x "packages/migration.zip" + + - name: Zip migration + uses: montudor/action-zip@v1 + with: + args: > + zip -r packages/migration.zip . \ + \ + -x "*.git/*" \ + \ + -x ".github/scripts/update-version.sh" \ + -x ".github/workflows/buildscript-maintenance.yml" \ + -x ".github/workflows/release-packages.yml" \ + \ + -x "*docs/*" \ + -x "*src/*" \ + -x "LICENSE" \ + -x "README.md" \ + -x "gtnhShared/*" \ + \ + -x "packages/" \ + -x "packages/starter.zip" \ + -x "packages/migration.zip" + + - name: Update latest tag + uses: "marvinpinto/action-automatic-releases@latest" + if: ${{ (github.ref == 'master' || github.ref == 'main') }} + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "latest-packages" + prerelease: true + title: "Latest starter and migration packages" + files: packages/* + + - name: Release named version + if: ${{ !(github.ref == 'master' || github.ref == 'main') }} + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.RELEASE_VERSION }}-packages" + prerelease: false + title: "${{ env.RELEASE_VERSION }} starter and migration packages" + files: packages/* diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 0000000..e4c0be6 --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,14 @@ + +name: Release tagged build + +on: + push: + tags: [ '*' ] + +permissions: + contents: write + +jobs: + release-tags: + uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master + secrets: inherit diff --git a/.gitignore b/.gitignore index 7e1d585..34ac734 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,32 @@ -# These are some examples of commonly ignored file patterns. -# You should customize this list as applicable to your project. -# Learn more about .gitignore: -# https://www.atlassian.com/git/tutorials/saving-changes/gitignore - -# eclipse -bin -*.launch +.gradle .settings -.metadata +/.idea/ +/.vscode/ +/run/ +/build/ +/eclipse/ .classpath .project - -# gradle -build -.gradle - -# other -eclipse -run +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +/out/ +*.iml +*.ipr +*.iws +src/main/resources/mixins.*([!.]).json *.bat +*.DS_Store +!gradlew.bat diff --git a/build.gradle b/build.gradle index d7927a6..927ed20 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1677938302 +//version: 1678003329 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -73,7 +73,7 @@ plugins { id 'com.diffplug.spotless' version '6.7.2' apply false id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.2.2' + id 'com.gtnewhorizons.retrofuturagradle' version '1.2.3' } boolean settingsupdated = verifySettingsGradle() settingsupdated = verifyGitAttributes() || settingsupdated @@ -153,7 +153,7 @@ java { } else { languageVersion.set(projectJavaVersion) } - vendor.set(JvmVendorSpec.ADOPTIUM) + vendor.set(JvmVendorSpec.AZUL) } if (!noPublishedSources) { withSourcesJar() @@ -222,7 +222,7 @@ if (enableModernJavaSyntax.toBoolean()) { javaCompiler.set(javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(17)) - vendor.set(JvmVendorSpec.ADOPTIUM) + vendor.set(JvmVendorSpec.AZUL) }) } } diff --git a/dependencies.gradle b/dependencies.gradle index 53ccadc..8748ef8 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,32 +1,9 @@ /* * Add your dependencies here. Supported configurations: - * - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod - * Available at runtime and compiletime for mods depending on this mod - * - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API - * Available at runtime but not compiletime for mods depending on this mod - * - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods - * Not available at all for mods depending on this mod, only visible at compiletime for this mod - * - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod - * Available at compiletime but not runtime for mods depending on this mod - * - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency - * Not available at all for mods depending on this mod, only visible at runtime for this mod - * - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime - * Available at runtime for mods depending on this mod - * - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry - * - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main - * - * - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name - * Requires you to enable usesShadowedDependencies in gradle.properties - * - * - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient) - * - * You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed, - * but use this sparingly as it can break using your mod as another mod's dependency if you're not careful. - * - * Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not. - * The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published. - * - * For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph - */ + dependencies { + compile('com.github.GTNewHorizons:Botania:1.9.2-GTNH:dev') + compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev') + compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.254:dev') + } diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 0000000..ea8362d --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,9 @@ +# Things we cannot protect you from (yet) + +### Select an mcp conf dir for the deobfuscator + +You may or may not run into this popup. For now, the only solution is to point the deopfuscator into the right direction. + +![](http://i.imgur.com/gzBMLrr.png) + +Solution: Point it to `~/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/unpacked/conf`. On Windows, please use `%USERPROFILE%/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/unpacked/conf`. diff --git a/docs/migration.md b/docs/migration.md new file mode 100644 index 0000000..aab0102 --- /dev/null +++ b/docs/migration.md @@ -0,0 +1,22 @@ +# Migration guides + +## Generic migration +Migration for the typical mod which doesn't use anything special but Minecraft forge and some library dependencies. +For core plugin, Mixins, shadowing, access transformers, ASM or etc. you'll need to do some extra steps. +If they are missing in this document - we will gladly receive your suggestions/contribution. + +1. Copy and replace all files from [template](https://github.com/GTNewHorizons/ExampleMod1.7.10/releases/download/latest-packages/migration.zip) to your repository, but `build.gradle` +2. Copy all repositories from your `build.gradle(.kts)` to `repositories.gradle` +3. Copy all dependencies from your `build.gradle(.kts)` to `dependecies.gradle` +4. replace your `build.gradle(.kts)` with `build.gradle` from template. In case you have written some custom tasks/configurations not present in the template - move them into `addon.gradle`. It will automatically be integrated if present. +5. Adapt `gradle.properties` to your mod +6. Ensure `src/main/resources/mcmod.info` contains `${modId}`, `${modName}`. `${modVersion}` and `${minecraftVersion}` +7. Re-import the project to your IDE (e.g. restart with clean caches in IntelliJ IDEA) +8. Run `./gradlew clean setupDecompWorkspace` + +## Mixin configuration +For the reference checkout the [example mixin configuration branch](https://github.com/GTNewHorizons/ExampleMod1.7.10/tree/example-mixins) of the template. + +1. Extract mixins package and plugin configuration from `mixins.yourModId.json` to `gradle.properties` +2. Implement MixinPlugin according to example from the reference +3. Remove mixins.mymodid.json diff --git a/docs/porting.md b/docs/porting.md new file mode 100644 index 0000000..4d63968 --- /dev/null +++ b/docs/porting.md @@ -0,0 +1,56 @@ +# Porting guidelines + +This is a list of steps which should help you on your probably not so easy journey of porting some mod: + +### 1. Setting up repository and build system +1. Checkout any information in mod REAMDE/Wiki/Docs to find out if there are any special tasks/configs that need to be applied to the build +2. Fork original repository to preserve commit history +3. Apply build migration as explained in [migration guidelines](migration.md) on your fork + +### 2. Refining the fork +Try to get rid of dependencies on concrete jars (usually in the `lib` folder) if any present. This way it will be much easier to change (upgrade/downgrade) your project dependencies, when needed. + +Check if they are in maven repository (usually authors put such information in the project readme), if it isn't accessible but project is open source with permissive enough license (e.g., MIT) - you still can publish them yourselves: + 1. Fork the repository + 2. Drop `jitpack.yml` and `.github/workflows/gradle.yml` in project root. You can find this file in this repository root. + 3. Make sure everything builds from console by running `./gradlew clean setupCIWorkspace` + 4. If all is fine/after fixing the errors - make a tag on Github or using console, this should trigger Github build hook and generate a release + 4. Lookup forked repository on `https://jitpack.io/` + 5. Find your release and click "Get it", which should scroll you down to the example of how to add the dependency (make sure you have jitpack repository in mod you are porting) + 6. Checkout build log beside button you clicked to make sure it succeeds + +Now when you are sure dependency is available in maven repository - just add it as a normal gradle dependency in `dependencies.gradle`. + +If there is not online dependency available, you may upload it as a jar to jitpack, see [jitpack single file publishing thread](https://gist.github.com/jitpack-io/f928a858aa5da08ad9d9662f982da983). Please ensure, that you have the rights to do so! + +There may also be a case where mods depend on another mods - then you'll need to port any dependencies first. (Yay, dependency hell! :D) + +### 3. Preparing for porting +Try to build the project and see check what types of errors are you getting. Generally, there should be 2 types of errors you encounter: + - Missing references to packages/classes/methods/fields/parameters. Things get renamed, moved, restructured, removed or even not yet exist. That's the straightforward part - you'll need to adjust references and way things are invoked. + In case of missing things, you'll either need to implement something that's imitates missing parts or resign from some functionality + - Build related errors (e.g., something that is a part of the mod in never versions previously was an external library - you'll need to add it as a dependencies) + +Fix all build related errors (so build system won't get in your way) + +### 4. Porting the mod +After all these preparations nothing should be in the way of porting the mod, the only thing left is the actual code to change, which probably is a most tedious part of this process. + +Good approach is to start working with smaller things first, building up your confidence in how the mod works and gradually approaching more complex stuff, here is a general algorithm: + 1. Begin with fixing moved/renamed things by deleting all bad imports and with help of the IDE re-import equivalents if present. + Intelij IDEA has settings for unambiguous auto-import and import optimization on the fly, which can greatly speedup the process. Just pay attention to what is actually imported. + 2. Remove all nonworking code which is not easily fixable (e.g., class only introduced in newer forge) and provide stubs in its place. + For example, replace reference to method of non existing class with your method in your class, it can have an empty body and mocked return so the code can compile and run without issues. + Do not forget to track all things you've stubbed, if you are working on port alone - TODOs should be sufficient (most IDEs have a built in TODO browser). + 3. Build the project and attempt to run it + 4. If there were any critical errors which cause Minecraft to crash or mod to not work - try fixing them first, so you can test your changes + 5. Start fixing small things, ones that you think you have most chances to fix and work your way up + 6. If any there is any feature that is not worth it's time or you simply don't know how to do it - consider dropping it entirely and open an issue in your repository where you'll explain your findings and blockers. + Maybe somebody with greater knowledge/more time/motivation will try to take bite at it. +9. Fix bugs you've introduced when porting. + It is uncommon for mods to have lots of workarounds and hidden connections. + You'll need to test things and check if they work as intended (gl;hf ;p) + +### 5. Final words + +If after reading this, you are not discouraged and still want to port it - good luck porting it! You'll definitively need it. diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..a32fb1d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,143 @@ +modName = Advanded Botany + +# This is a case-sensitive string to identify your mod. Convention is to use lower case. +modId = ab + +modGroup = com.myname.ab + +# WHY is there no version field? +# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the +# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/ + +# Will update your build.gradle automatically whenever an update is available +autoUpdateBuildScript = false + +minecraftVersion = 1.7.10 +forgeVersion = 10.13.4.1614 + +# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task. +channel = stable +mappingsVersion = 12 + +# Define other MCP mappings for dependency deobfuscation +remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/ + +# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you +# restart Minecraft in development. Choose this dependent on your mod: +# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name +# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty +developmentEnvironmentUserName = Developer + +# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8. +# See https://github.com/bsideup/jabel for details on how this works. +enableModernJavaSyntax = true + +# Enables injecting missing generics into the decompiled source code for a better coding experience +# Turns most publically visible List, Map, etc. into proper List, Map types +enableGenericInjection = false + +# Generate a class with String fields for the mod id, name, version and group name named with the fields below +generateGradleTokenClass = com.myname.mymodid.Tags +gradleTokenModId = MODID +gradleTokenModName = MODNAME +gradleTokenVersion = VERSION +gradleTokenGroupName = GROUPNAME +# [DEPRECATED] +# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]) +# Leave these properties empty to skip individual token replacements +replaceGradleTokenInFile = + +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can +# leave this property empty. +# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api +apiPackage = + +# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ +# There can be multiple files in a comma-separated list. +# Example value: mymodid_at.cfg,nei_at.cfg +accessTransformersFile = + +# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! +usesMixins = false +# Adds some debug arguments like verbose output and export +usesMixinDebug = false +# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. +mixinPlugin = +# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! +mixinsPackage = +# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! +# This parameter is for legacy compatibility only +# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin +coreModClass = +# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class +# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! +containsMixinsAndOrCoreModOnly = false + +# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins. +forceEnableMixins = false + +# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your +# responsibility check the licence and request permission for distribution, if required. +usesShadowedDependencies = false +# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access +# their own classes, making the minimization unreliable. +minimizeShadowedDependencies = true +# If disabled, won't rename the shadowed classes. +relocateShadowedDependencies = true + +# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories +includeWellKnownRepositories = true + +# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token. + +# The project's ID on Modrinth. Can be either the slug or the ID. +# Leave this empty if you don't want to publish on Modrinth. +modrinthProjectId = + +# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth. +# Syntax: scope1-type1:name1;scope2-type2:name2;... +# Where scope can be one of [required, optional, incompatible, embedded], +# type can be one of [project, version], +# and the name is the Modrinth project or version slug/id of the other mod. +# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech +# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true +modrinthRelations = + + +# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens. + +# The project's numeric ID on CurseForge. You can find this in the About Project box. +# Leave this empty if you don't want to publish on CurseForge. +curseForgeProjectId = + +# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge. +# Syntax: type1:name1;type2:name2;... +# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], +# and the name is the CurseForge project slug of the other mod. +# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft +# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true +curseForgeRelations = + + +# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older +# projects. New projects should not use this parameter. +# customArchiveBaseName = + +# Optional parameter to prevent the source code from being published +# noPublishedSources = + +# Uncomment this to disable spotless checks +# This should only be uncommented to keep it easier to sync with upstream/other forks. +# That is, if there is no other active fork/upstream, NEVER change this. +# disableSpotless = true + +# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle" +# (force use delegated build). +# This is meant to be set in $HOME/.gradle/gradle.properties. +# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build. +# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want! +# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you. +# ideaOverrideBuildType = idea diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/gtnhShared/spotless.eclipseformat.xml b/gtnhShared/spotless.eclipseformat.xml new file mode 100644 index 0000000..e8eb89c --- /dev/null +++ b/gtnhShared/spotless.eclipseformat.xml @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gtnhShared/spotless.gradle b/gtnhShared/spotless.gradle new file mode 100644 index 0000000..ed56cb7 --- /dev/null +++ b/gtnhShared/spotless.gradle @@ -0,0 +1,40 @@ + +apply plugin: 'com.diffplug.spotless' + +// Spotless autoformatter +// See https://github.com/diffplug/spotless/tree/main/plugin-gradle +// Can be locally toggled via spotless:off/spotless:on comments +spotless { + encoding 'UTF-8' + + format 'misc', { + target '.gitignore' + + trimTrailingWhitespace() + indentWithSpaces(4) + endWithNewline() + } + java { + target 'src/*/java/**/*.java', 'src/*/scala/**/*.java' + + toggleOffOn() + importOrderFile(Blowdryer.file('spotless.importorder')) + removeUnusedImports() + eclipse('4.19.0').configFile(Blowdryer.file('spotless.eclipseformat.xml')) + } + kotlin { + target 'src/*/kotlin/**/*.kt' + + toggleOffOn() + ktfmt('0.39') + + trimTrailingWhitespace() + indentWithSpaces(4) + endWithNewline() + } + scala { + target 'src/*/scala/**/*.scala' + + scalafmt('3.7.1') + } +} diff --git a/gtnhShared/spotless.importorder b/gtnhShared/spotless.importorder new file mode 100644 index 0000000..ce4fe27 --- /dev/null +++ b/gtnhShared/spotless.importorder @@ -0,0 +1,7 @@ +#Organize Import Order +#Sat Jan 28 17:57:48 GMT 2023 +0=java +1=javax +2=net +3=org +4=com diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..01ea5f1 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,28 @@ + +pluginManagement { + repositories { + maven { + // RetroFuturaGradle + name "GTNH Maven" + url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/" + allowInsecureProtocol = true + mavenContent { + includeGroup("com.gtnewhorizons.retrofuturagradle") + } + } + gradlePluginPortal() + mavenCentral() + mavenLocal() + } +} + +plugins { + id 'com.diffplug.blowdryerSetup' version '1.6.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains +} + +blowdryerSetup { + repoSubfolder 'gtnhShared' + github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0') + //devLocal '.' // Use this when testing config updates locally +}