Refactor forge and example run configs based on MinecraftForge/ForgeGradle#546

- Updated run config formats based on the refactored setup
- Removed old 'runclient' and 'runserver' JavaExec tasks, replacing them by creating the run configs using the refactored setup.
- Set 'assetIndex' environment variable from FG
- Updated MDK for new run config setup
This commit is contained in:
Jack Taylor 2019-02-19 08:39:05 +13:00 committed by tterrag
parent 3fa507d6d1
commit 2e2c57dbd1
4 changed files with 138 additions and 135 deletions

View file

@ -64,20 +64,35 @@ project(':clean') {
repositories { repositories {
mavenCentral() mavenCentral()
} }
patcher { patcher {
parent = project(':mcp') parent = project(':mcp')
patchedSrc = file('src/main/java')
mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
mcVersion = MC_VERSION mcVersion = MC_VERSION
} patchedSrc = file('src/main/java')
task runclient(type: JavaExec) {
doFirst { mappings channel: MAPPING_CHANNEL, version: MAPPING_VERSION
mkdir 'runclient'
runs {
clean_client {
taskName 'clean_client'
main 'net.minecraft.client.main.Main'
workingDirectory project.file('run')
args '--gameDir', '.'
args '--version', MC_VERSION
args '--assetsDir', downloadAssets.output
args '--assetIndex', '{asset_index}'
args '--accessToken', '0'
}
clean_server {
taskName 'clean_server'
main 'net.minecraft.server.MinecraftServer'
workingDirectory project.file('run')
}
} }
classpath sourceSets.main.runtimeClasspath
args = ['--accessToken', '0', '--version', MC_VERSION]
main 'net.minecraft.client.main.Main'
workingDir 'runclient'
} }
} }
@ -166,46 +181,49 @@ project(':forge') {
version = getVersion() version = getVersion()
patcher { patcher {
exc = file("$rootDir/src/main/resources/forge.exc")
parent = project(':clean') parent = project(':clean')
patches = file("$rootDir/patches/minecraft") patches = file("$rootDir/patches/minecraft")
patchedSrc = file('src/main/java') patchedSrc = file('src/main/java')
accessTransformer = file("$rootDir/src/main/resources/META-INF/accesstransformer.cfg")
exc = file("$rootDir/src/main/resources/forge.exc")
srgPatches = true srgPatches = true
accessTransformer = file("$rootDir/src/main/resources/META-INF/accesstransformer.cfg")
runs { runs {
forge_client = { forge_client {
taskName 'forge_client'
main 'net.minecraftforge.fml.LaunchTesting' main 'net.minecraftforge.fml.LaunchTesting'
environment = [ workingDirectory project.file('run')
target: 'fmldevclient',
assetDirectory: downloadAssets.output, environment 'target', 'fmldevclient'
nativesDirectory: extractNatives.output environment 'assetIndex', '{asset_index}'
] environment 'assetDirectory', downloadAssets.output
properties = [ environment 'nativesDirectory', extractNatives.output
// 'org.lwjgl.util.Debug': 'true',
// 'org.lwjgl.util.DebugLoader': 'true', property 'mc.version', MC_VERSION
'org.lwjgl.system.SharedLibraryExtractDirectory': 'lwjgl_dll', property 'forge.spec', SPEC_VERSION
'mc.version': MC_VERSION, property 'mcp.version', MCP_VERSION
'mcp.version': MCP_VERSION, property 'forge.group', project.group
'forge.version': project.version.substring(MC_VERSION.length() + 1), property 'forge.version', project.version.substring(MC_VERSION.length() + 1).toString()
'forge.spec': SPEC_VERSION, property 'terminal.ansi', 'true'
'forge.group': project.group, property 'fmllauncher.version', SPEC_VERSION
'fmllauncher.version': SPEC_VERSION, property 'org.lwjgl.system.SharedLibraryExtractDirectory', 'lwjgl_dll'
'terminal.ansi': 'true'
]
} }
forge_server = {
forge_server {
taskName 'forge_server'
main 'net.minecraftforge.fml.LaunchTesting' main 'net.minecraftforge.fml.LaunchTesting'
environment = [ workingDirectory project.file('run')
target: 'fmldevserver'
] environment 'target', 'fmldevserver'
properties = [
'mc.version': MC_VERSION, property 'mc.version', MC_VERSION
'mcp.version': MCP_VERSION, property 'forge.spec', SPEC_VERSION
'forge.version': "${project.version.substring(MC_VERSION.length() + 1)}".toString(), property 'mcp.version', MCP_VERSION
'forge.spec': SPEC_VERSION, property 'forge.group', project.group
'forge.group': project.group, property 'forge.version', project.version.substring(MC_VERSION.length() + 1).toString()
'fmllauncher.version': SPEC_VERSION property 'fmllauncher.version', SPEC_VERSION
]
} }
} }
} }
@ -290,43 +308,6 @@ project(':forge') {
testImplementation "org.opentest4j:opentest4j:1.0.0" // needed for junit 5 testImplementation "org.opentest4j:opentest4j:1.0.0" // needed for junit 5
testImplementation "org.hamcrest:hamcrest-all:1.3" // needs advanced matching for list order testImplementation "org.hamcrest:hamcrest-all:1.3" // needs advanced matching for list order
} }
task runclient(type: JavaExec, dependsOn: [":forge:downloadAssets", ":forge:extractNatives"]) {
doFirst {
mkdir 'runclient'
}
doFirst {
copy {
from sourceSets.main.resources
into "$buildDir/classes/java/main"
}
}
//jvmArgs = ['-verbose:class']
classpath sourceSets.main.runtimeClasspath
main patcher.runs.forge_client.main
systemProperties = patcher.runs.forge_client.properties
environment += patcher.runs.forge_client.environment
workingDir 'runclient'
}
task runserver(type: JavaExec) {
doFirst {
mkdir 'runserver'
}
doFirst {
copy {
from sourceSets.main.resources
into "$buildDir/classes/java/main"
}
}
classpath sourceSets.main.runtimeClasspath
main patcher.runs.forge_server.main
args 'nogui'
systemProperties = patcher.runs.forge_server.properties
environment += patcher.runs.forge_server.environment
workingDir 'runserver'
standardInput = System.in
}
def extraTxts = [ def extraTxts = [
rootProject.file('CREDITS.txt'), rootProject.file('CREDITS.txt'),
@ -836,27 +817,33 @@ project(':forge') {
} }
addLibrary("${project.group}:${project.name}:${project.version}:launcher") addLibrary("${project.group}:${project.name}:${project.version}:launcher")
runs { runs {
client = { client {
main 'net.minecraftforge.userdev.UserdevLauncher' main 'net.minecraftforge.userdev.UserdevLauncher'
environment 'target', 'fmluserdevclient' environment 'target', 'fmluserdevclient'
environment 'assetIndex', '{asset_index}'
environment 'assetDirectory', '{assets_root}' environment 'assetDirectory', '{assets_root}'
environment 'nativesDirectory', '{natives}' environment 'nativesDirectory', '{natives}'
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1)
environment 'FORGE_GROUP', project.group environment 'MC_VERSION', "${MC_VERSION}"
environment 'MCP_VERSION', MCP_VERSION environment 'FORGE_GROUP', "${project.group}"
environment 'MC_VERSION', MC_VERSION environment 'MCP_VERSION', "${MCP_VERSION}"
environment 'MOD_CLASSES', '{source_roots}' environment 'MOD_CLASSES', '{source_roots}'
environment 'MCP_MAPPINGS', '{mcp_mappings}' environment 'MCP_MAPPINGS', '{mcp_mappings}'
environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}"
} }
server = {
server {
main 'net.minecraftforge.userdev.UserdevLauncher' main 'net.minecraftforge.userdev.UserdevLauncher'
environment 'target', 'fmluserdevserver' environment 'target', 'fmluserdevserver'
environment 'FORGE_VERSION', project.version.substring(MC_VERSION.length() + 1)
environment 'FORGE_GROUP', project.group environment 'MC_VERSION', "${MC_VERSION}"
environment 'MCP_VERSION', MCP_VERSION environment 'FORGE_GROUP', "${project.group}"
environment 'MC_VERSION', MC_VERSION environment 'MCP_VERSION', "${MCP_VERSION}"
environment 'MOD_CLASSES', '{source_roots}' environment 'MOD_CLASSES', '{source_roots}'
environment 'MCP_MAPPINGS', '{mcp_mappings}' environment 'MCP_MAPPINGS', '{mcp_mappings}'
environment 'FORGE_VERSION', "${project.version.substring(MC_VERSION.length() + 1)}"
} }
} }
} }

View file

@ -9,7 +9,7 @@ buildscript {
} }
} }
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse' apply plugin: 'eclipse'
version = '1.0' version = '1.0'
@ -19,34 +19,49 @@ archivesBaseName = 'modid'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
minecraft { minecraft {
// the mappings can be changed at any time, and must be in the following format. // The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly. // snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team. // stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: '@MAPPING_CHANNEL@', version: '@MAPPING_VERSION@' mappings channel: '@MAPPING_CHANNEL@', version: '@MAPPING_VERSION@'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
//accessTransformer = file('my_at.cfg') // accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
// default run configurations. // Default run configurations.
// these can be tweaked, removed, or duplicated as needed. // These can be tweaked, removed, or duplicated as needed.
runs { runs {
client = { client {
// recommended logging data for a userdev environment workingDirectory project.file('run')
properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
// recommended logging level for the console // Recommended logging data for a userdev environment
properties 'forge.logging.console.level': 'debug' property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
workingDirectory project.file('run').canonicalPath
source sourceSets.main // Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
} }
server = {
// recommended logging data for a userdev environment server {
properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP' workingDirectory project.file('run')
// recommended logging level for the console
properties 'forge.logging.console.level': 'debug' // Recommended logging data for a userdev environment
workingDirectory project.file('run').canonicalPath property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
source sourceSets.main
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
} }
} }
} }
@ -57,22 +72,21 @@ dependencies {
// The userdev artifact is a special name and will get all sorts of transformations applied to it. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@' minecraft '@FORGE_GROUP@:@FORGE_NAME@:@FORGE_VERSION@'
// you may put jars on which you depend on in ./libs // You may put jars on which you depend on in ./libs or you may define them like so..
// or you may define them like so.. // compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version"
//compile "some.group:artifact:version"
// real examples // Real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings // These dependencies get remapped to your current MCP mappings
//deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// for more info... // For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html // http://www.gradle.org/docs/current/userguide/dependency_management.html
@ -81,12 +95,14 @@ dependencies {
// Example for how to get properties into the manifest for reading by the runtime.. // Example for how to get properties into the manifest for reading by the runtime..
jar { jar {
manifest { manifest {
attributes(["Specification-Title": "examplemod", attributes([
"Specification-Vendor": "examplemodsareus", "Specification-Title": "examplemod",
"Specification-Version": "1", // We are version 1 of ourselves "Specification-Vendor": "examplemodsareus",
"Implementation-Title": project.name, "Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Version": "${version}", "Implementation-Title": project.name,
"Implementation-Vendor" :"examplemodsareus", "Implementation-Version": "${version}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],) "Implementation-Vendor" :"examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
} }
} }

View file

@ -61,11 +61,11 @@ public class LaunchTesting
if (Objects.equals(target,"fmldevclient")) { if (Objects.equals(target,"fmldevclient")) {
hackNatives(); hackNatives();
launchArgs = ObjectArrays.concat(launchArgs, new String[] { launchArgs = ObjectArrays.concat(launchArgs, new String[] {
"--accessToken", "blah", "--accessToken", "blah",
"--version", "FMLDev", "--version", "FMLDev",
"--assetIndex", "1.13.1", "--assetIndex", System.getenv("assetIndex"),
"--assetsDir", assets, "--assetsDir", assets,
"--userProperties", "{}" "--userProperties", "{}"
}, String.class); }, String.class);
} else { } else {
launchArgs = ObjectArrays.concat(launchArgs, args, String.class); launchArgs = ObjectArrays.concat(launchArgs, args, String.class);

View file

@ -65,7 +65,7 @@ public class UserdevLauncher
launchArgs = ObjectArrays.concat(launchArgs, new String[] { launchArgs = ObjectArrays.concat(launchArgs, new String[] {
"--accessToken", "blah", "--accessToken", "blah",
"--version", "FMLDev", "--version", "FMLDev",
"--assetIndex", "1.13.1", "--assetIndex", System.getenv("assetIndex"),
"--assetsDir", assets, "--assetsDir", assets,
"--userProperties", "{}" "--userProperties", "{}"
}, String.class); }, String.class);