Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
amadornes committed Jul 29, 2021
1 parent b2a4a5f commit 8aee775
Show file tree
Hide file tree
Showing 26 changed files with 788 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 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
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "runenv"]
path = runenv
url = https://github.com/amadornes/fg-multiproject-runenv.git
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
# fg-multiproject-template
Multiproject template for ForgeGradle development environments
# ForgeGradle Multiproject Template

This repository provides a template for multiproject development environments using ForgeGradle.

It builds upon the [runenv template](https://github.com/amadornes/fg-multiproject-runenv) repo to provide the binding
logic that makes the multiproject environment work.

## 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 belong to the *runenv template*.
You must run that project's `setup<IDE>Runs` task and use its classpath at runtime.

For datagen, you may still use each project's individual runs.

## Known issues and currently untested features
Please check the [runenv template](https://github.com/amadornes/fg-multiproject-runenv) repository, as that will contain
the latest information regarding compatibility. Further updates will most likely be pushed there.

## Contributions
Pull requests adding extended feature support and bugfixes are welcome.
Please keep them simple if possible.
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
subprojects {
configurations.all {
if (it.name.startsWith("_")) {
exclude group: "com.example", module: "examplelib"
return
}

resolutionStrategy.dependencySubstitution {
substitute module("com.example:examplelib") using project(":examplelib")
}
}
}

project('runenv') {
ext {
mcversion = '1.17.1'
forgeversion = '37.0.13'
}
repositories {
}
dependencies {
// This is where any additional runtime dependencies for your dev environment go
}
}


5 changes: 5 additions & 0 deletions examplelib/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 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
25 changes: 25 additions & 0 deletions examplelib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
105 changes: 105 additions & 0 deletions examplelib/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
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(16)

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"
}
}
}
3 changes: 3 additions & 0 deletions examplelib/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_version=0.0.1
_mcversion=1.17.1
_forgeversion=37.0.13
25 changes: 25 additions & 0 deletions examplelib/src/main/java/com/example/examplelib/ExampleLib.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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!");
}
}
25 changes: 25 additions & 0 deletions examplelib/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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"
7 changes: 7 additions & 0 deletions examplelib/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"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."
}
}
5 changes: 5 additions & 0 deletions examplemod/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 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
25 changes: 25 additions & 0 deletions examplemod/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
Loading

0 comments on commit 8aee775

Please sign in to comment.