Remove :versions prefix from gradle projects and remove duplicated build code

This commit is contained in:
Jonas Herzig
2018-03-05 20:46:56 +01:00
parent 8ed9c75ba1
commit fbbca76099
28 changed files with 85 additions and 231 deletions

View File

@@ -8,7 +8,7 @@ pipeline:
commands:
- curl --fail --create-dirs -o $HOME/.gradle/init.d/mirror.gradle https://maven.johni0702.de/config/gradle
- git config --global user.email "replaymod@drone" && git config --global user.name "Drone"
- SIGNED_JAR=$(! git describe --exact 2>&1 > /dev/null; echo $?) REPRODUCIBLE_BUILD=1 ./gradlew $(bash -c "echo :versions:{1.8,1.8.9,1.9.4,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2}:reobfJar") --parallel
- SIGNED_JAR=$(! git describe --exact 2>&1 > /dev/null; echo $?) REPRODUCIBLE_BUILD=1 ./gradlew $(bash -c "echo :{1.8,1.8.9,1.9.4,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2}:reobfJar") --parallel
- mkdir -p build/libs && mv versions/*/build/libs/* build/libs/
archive:
image: plugins/s3

View File

@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgY2xvbmU6CiAgICBpbWFnZTogcGx1Z2lucy9naXQKICAgIHRhZ3M6IHRydWUKICAgIHJlY3Vyc2l2ZTogdHJ1ZQogIGJ1aWxkOgogICAgaW1hZ2U6IG1hdmVuOjMuMy45LWpkay04CiAgICBjb21tYW5kczoKICAgICAgLSBjdXJsIC0tZmFpbCAtLWNyZWF0ZS1kaXJzIC1vICRIT01FLy5ncmFkbGUvaW5pdC5kL21pcnJvci5ncmFkbGUgaHR0cHM6Ly9tYXZlbi5qb2huaTA3MDIuZGUvY29uZmlnL2dyYWRsZQogICAgICAtIGdpdCBjb25maWcgLS1nbG9iYWwgdXNlci5lbWFpbCAicmVwbGF5bW9kQGRyb25lIiAmJiBnaXQgY29uZmlnIC0tZ2xvYmFsIHVzZXIubmFtZSAiRHJvbmUiCiAgICAgIC0gU0lHTkVEX0pBUj0kKCEgZ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2xvYmFsIHVzZXIubmFtZSAiRHJvbmUiCiAgICAgIC0gU0lHTkVEX0pBUj0kKCEgZ2l0IGRlc2NyaWJlIC0tZXhhY3QgMj4mMSA-IC9kZXYvbnVsbDsgZWNobyAkPykgUkVQUk9EVUNJQkxFX0JVSUxEPTEgLi9ncmFkbGV3ICQoYmFzaCAtYyAiZWNobyA6ezEuOCwxLjguOSwxLjkuNCwxLjEwLjIsMS4xMSwxLjExLjIsMS4xMiwxLjEyLjEsMS4xMi4yfTpyZW9iZkphciIpIC0tcGFyYWxsZWwKICAgICAgLSBta2RpciAtcCBidWlsZC9saWJzICYmIG12IHZlcnNpb25zLyovYnVpbGQvbGlicy8qIGJ1aWxkL2xpYnMvCiAgYXJjaGl2ZToKICAgIGltYWdlOiBwbHVnaW5zL3MzCiAgICBhY2w6IHB1YmxpYy1yZWFkCiAgICByZWdpb246ICJ1cy1lYXN0LTEiCiAgICBidWNrZXQ6ICJyZXBsYXltb2QiCiAgICBwYXRoX3N0eWxlOiB0cnVlCiAgICBzb3VyY2U6IGJ1aWxkL2xpYnMvKgogICAgc3RyaXBfcHJlZml4OiBidWlsZC9saWJzLwogICAgdGFyZ2V0OiAvCg.fT6kOBDI6aBi4mOm999DOflJ7ZCkclgr6Vz69rlOpQ0

View File

@@ -10,7 +10,7 @@ to access private fields is a good indication that this has happened).
### No IDE
You can build the mod by running `./gradlew build`. You can then find the final jar files in `versions/$MCVERSION/build/libs/`.
You can also build single versions by running `./gradlew :versions:1.8:build` (builds the MC 1.8 version).
You can also build single versions by running `./gradlew :1.8:build` (builds the MC 1.8 version).
### IntelliJ
For the initial setup run `./gradlew idea genIntellijRuns`.
@@ -74,15 +74,15 @@ Code for the more recent MC version shall be placed in the first branch of the i
Version-dependent import statements shall be placed separately from and after all other imports but before the `static` and `java.*` imports.
Common version dependent code (including the fml and forge event bus) are available as static methods/fields in the `MCVer` class.
The source code resides in `src/main` (gradle project `:versions:core`) and is automatically passed through the
preprocessor when any of the concrete versions are built (gradle projects `:versions:1.8`, `:versions:1.8.9`, etc.).
The source code resides in `src/main` (gradle project `:core`) and is automatically passed through the
preprocessor when any of the concrete versions are built (gradle projects `:1.8`, `:1.8.9`, etc.).
Do **NOT** edit any of the code in `versions/$MCVERSION/build/` as it is automatically generated and will be overwritten without warning.
You can pass the original source code through the preprocessor if you wish to develop/debug with another version of Minecraft:
```bash
./gradle -PmcVersion=10904 :setCoreVersion # switches all sources in src/main to 1.9.4
```
If you do so, you'll also have to run `./gradlew :versions:core:copySrg :versions:core:setupDecompWorkspace :jGui:versions:core:setupDecompWorkspace`,
If you do so, you'll also have to run `./gradlew :core:copySrg :core:setupDecompWorkspace :jGui:core:setupDecompWorkspace`,
followed by a refresh of the project in your IDE.
Make sure to switch back to the most recent branch before committing!

View File

@@ -21,25 +21,8 @@ group= "com.replaymod"
subprojects {
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven { url 'https://jitpack.io' }
}
dependencies {
classpath('com.github.SpongePowered:MixinGradle:dcfaf61'){ // 0.6
// Because forgegradle requires 6.0 (not -debug-all) while mixingradle depends on 5.0
// and putting mixin right here will place it before forge in the class loader
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
}
}
configurations.classpath.resolutionStrategy.eachDependency { dep ->
if (System.getenv('REPRODUCIBLE_BUILD') == '1') return
def req = dep.target
@@ -80,7 +63,7 @@ task setCoreVersion() {
def vars = [MC: project.mcVersion as int, DEV_ENV: 1]
project.convertTree(vars, 'src/main/java')
project.convertTree(vars, 'src/main/resources')
project.convertTree(vars, 'versions/core/build.gradle')
project.file('versions/core/mcVersion').write(vars.MC.toString())
}
}

2
jGui

Submodule jGui updated: 88cf678236...0990337089

View File

@@ -1,12 +1,16 @@
include ':jGui'
([
[
'core',
'1.8',
'1.8.9',
'1.9.4',
'1.12'
].collect {":jGui:versions:$it"} as String[]).each {
include it
].each { version ->
include ":jGui:$version"
project(":jGui:$version").with {
projectDir = file("jGui/versions/$version")
buildFileName = '../common.gradle'
}
}
def versions = [
@@ -21,6 +25,10 @@ def versions = [
'1.12.1',
'1.12.2'
]
versions.collect {":versions:$it"}.each {
include it
versions.each { version ->
include ":$version"
project(":$version").with {
projectDir = file("versions/$version")
buildFileName = '../common.gradle'
}
}

0
versions/1.10.2/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.10.2-12.18.2.2099'
mappings = "snapshot_20160518"
}

0
versions/1.11.2/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.11.2-13.20.0.2216'
mappings = "snapshot_20161220"
}

0
versions/1.11/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.11-13.19.1.2188'
mappings = "snapshot_20161111"
}

0
versions/1.12.1/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12.1-14.22.0.2444'
mappings = "snapshot_20170615"
}

0
versions/1.12.2/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12.2-14.23.0.2486'
mappings = "snapshot_20170615"
}

0
versions/1.12/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.12-14.21.1.2387'
mappings = "snapshot_20170615"
}

0
versions/1.8.9/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.8.9-11.15.1.1722'
mappings = "stable_22"
}

0
versions/1.8/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.8-11.14.4.1563'
mappings = "snapshot_nodoc_20141130"
}

0
versions/1.9.4/.gitkeep Normal file
View File

View File

@@ -1,12 +0,0 @@
buildscript {
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply from: '../common.gradle'
minecraft {
version = '1.9.4-12.17.0.1976'
mappings = "snapshot_20160518"
}

View File

@@ -1,20 +1,42 @@
buildscript {
repositories {
mavenCentral()
def mcVersion
if (project.name != 'core') {
def (major, minor, patch) = project.name.tokenize('.')
mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}" as int
} else {
def f = file('mcVersion')
mcVersion = f.exists() ? f.readLines().first() as int : 11202
}
project.ext.mcVersion = mcVersion
repositories {
jcenter()
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
dependencies {
classpath 'org.ow2.asm:asm:6.0'
}
// This and calls to it should really also be handled by the gradle/reprod/init.gradle script
// but apparently there's no sane way to do that for external scripts in gradle :(
def convertRepoToHttp = { repo ->
if (repo instanceof MavenArtifactRepository && repo.url.toString().startsWith('https://')) {
URL url = repo.url.toURL()
repo.url = new URL("http", url.getHost(), url.getPort(), url.getFile()).toURI()
dependencies {
classpath 'org.ow2.asm:asm:6.0'
classpath('com.github.SpongePowered:MixinGradle:dcfaf61'){ // 0.6
// Because forgegradle requires 6.0 (not -debug-all) while mixingradle depends on 5.0
// and putting mixin right here will place it before forge in the class loader
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
}
classpath 'net.minecraftforge.gradle:ForgeGradle:' + (
mcVersion >= 11200 ? '2.3-SNAPSHOT' :
mcVersion >= 10904 ? '2.2-SNAPSHOT' :
mcVersion >= 10809 ? '2.1-SNAPSHOT' :
mcVersion >= 10800 ? '2.0-SNAPSHOT' :
'invalid'
)
}
if (System.getenv('REPRODUCIBLE_BUILD') == '1') repositories.all convertRepoToHttp
}
apply plugin: 'net.minecraftforge.gradle.forge'
@@ -32,6 +54,29 @@ archivesBaseName = "replaymod"
minecraft {
coreMod = 'com.replaymod.core.LoadingPlugin'
runDir = "../../eclipse"
version = [
11202: '1.12.2-14.23.0.2486',
11201: '1.12.1-14.22.0.2444',
11200: '1.12-14.21.1.2387',
11102: '1.11.2-13.20.0.2216',
11100: '1.11-13.19.1.2188',
11002: '1.10.2-12.18.2.2099',
10904: '1.9.4-12.17.0.1976',
10809: '1.8.9-11.15.1.1722',
10800: '1.8-11.14.4.1563',
][mcVersion]
mappings = [
11202: "snapshot_20170615",
11201: "snapshot_20170615",
11200: "snapshot_20170615",
11102: "snapshot_20161220",
11100: "snapshot_20161111",
11002: "snapshot_20160518",
10904: "snapshot_20160518",
10809: "stable_22",
10800: "snapshot_nodoc_20141130",
][mcVersion]
}
afterEvaluate {
// Note cannot use minecraft.replace because that has already been forwarded to the task by FG by now
@@ -49,15 +94,6 @@ repositories {
maven { url 'https://jitpack.io' }
}
// And because gradle does *something*, this definition even needs to be duplicated instead of shared
def convertRepoToHttp = { repo ->
if (repo instanceof MavenArtifactRepository && repo.url.toString().startsWith('https://')) {
URL url = repo.url.toURL()
repo.url = new URL("http", url.getHost(), url.getPort(), url.getFile()).toURI()
}
}
if (System.getenv('REPRODUCIBLE_BUILD') == '1') repositories.all convertRepoToHttp
configurations {
shade
compile.extendsFrom shade
@@ -87,7 +123,7 @@ dependencies {
def jGuiVersion = project.name
if (['1.10.2', '1.11', '1.11.2'].contains(jGuiVersion)) jGuiVersion = '1.9.4'
if (['1.12.1', '1.12.2'].contains(jGuiVersion)) jGuiVersion = '1.12'
shade(project(":jGui:versions:$jGuiVersion")){
shade(project(":jGui:$jGuiVersion")){
exclude group: 'org.projectlombok', module: 'lombok' // runtime only for @SneakyThrows which isn't used
}
@@ -103,8 +139,6 @@ if (project.name != 'core') {
def preprocessedRes = 'build/preprocessed/res'
def originalSrc = '../../src/main/java'
def originalRes = '../../src/main/resources'
def (major, minor, patch) = project.name.tokenize('.')
def mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}"
def vars = [MC: mcVersion as int]
sourceSets {
@@ -135,6 +169,11 @@ if (project.name != 'core') {
}
minecraft.accessTransformer preprocessedRes + '/META-INF/replaymod_at.cfg'
} else {
sourceSets {
main.java.srcDirs = ['../../src/main/java']
main.resources.srcDirs = ['../../src/main/resources']
}
}

1
versions/core/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
mcVersion

0
versions/core/.gitkeep Normal file
View File

View File

@@ -1,69 +0,0 @@
buildscript {
dependencies {
//#if MC>=10904
//#if MC>=11200
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
//#else
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
//#endif
//#else
//#if MC>=10809
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
//#else
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
//#endif
//#endif
}
}
apply from: '../common.gradle'
sourceSets {
main.java.srcDirs = ['../../src/main/java']
main.resources.srcDirs = ['../../src/main/resources']
}
minecraft {
//#if MC>=11202
version = '1.12.2-14.23.0.2486'
mappings = "snapshot_20170615"
//#else
//#if MC>=11201
//$$ version = '1.12.1-14.22.0.2444'
//$$ mappings = "snapshot_20170615"
//#else
//#if MC>=11200
//$$ version = '1.12-14.21.1.2387'
//$$ mappings = "snapshot_20170615"
//#else
//#if MC>=11102
//$$ version = '1.11.2-13.20.0.2216'
//$$ mappings = "snapshot_20161220"
//#else
//#if MC>=11100
//$$ version = '1.11-13.19.1.2188'
//$$ mappings = "snapshot_20161111"
//#else
//#if MC>=11002
//$$ version = '1.10.2-12.18.2.2099'
//$$ mappings = "snapshot_20160518"
//#else
//#if MC>=10904
//$$ version = '1.9.4-12.17.0.1976'
//$$ mappings = "snapshot_20160518"
//#else
//#if MC>=10809
//$$ version = '1.8.9-11.15.1.1722'
//$$ mappings = "stable_22"
//#else
//$$ version = '1.8-11.14.4.1563'
//$$ mappings = "snapshot_nodoc_20141130"
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
//#endif
}