Skip to content

Commit e70e9b0

Browse files
committed
Get rid of dedicated 'core' project (backwards incompatible!)
1 parent 425d8dd commit e70e9b0

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ The `//$$` shall be aligned with the inner-most `//#if`.
3232
Code for the more recent MC version shall be placed in the first branch of the if-else-construct.
3333
Version-dependent import statements shall be placed separately from and after all other imports but before the `static` and `java.*` imports.
3434

35-
The source code resides in `src/main` (gradle project `:core`) and is automatically passed through the
36-
preprocessor when any of the concrete versions are built (gradle projects `:1.8`, `:1.8.9`, etc.).
35+
The source code resides in `src/main` (gradle project determined by `versions/mainVersion` e.g. with `11404` it'll be `:1.14.4`) and is automatically passed through the
36+
preprocessor when any of the other versions are built (gradle projects `:1.8`, `:1.8.9`, etc.).
3737
Do **NOT** edit any of the code in `versions/$MCVERSION/build/` as it is automatically generated and will be overwritten without warning.
3838

3939
You can pass the original source code through the preprocessor if you wish to develop/debug with another version of Minecraft:

src/main/kotlin/com/replaymod/gradle/preprocess/PreprocessPlugin.kt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.replaymod.gradle.preprocess
33
import org.gradle.api.Plugin
44
import org.gradle.api.Project
55
import org.gradle.api.Task
6+
import org.gradle.api.tasks.Copy
67
import org.gradle.api.tasks.SourceSetContainer
78
import org.gradle.api.tasks.compile.AbstractCompile
89

@@ -12,23 +13,24 @@ import java.util.*
1213

1314
class PreprocessPlugin : Plugin<Project> {
1415
override fun apply(project: Project) {
16+
val coreVersionFile = project.file("../mainVersion")
1517
val originalSrc = "../../src/main/java"
1618
val originalRes = "../../src/main/resources"
1719
val preprocessedSrc = "build/preprocessed/src"
1820
val preprocessedRes = "build/preprocessed/res"
1921
val mappingFiles = findMappingFiles(project)
2022

21-
if (project.name == "core") {
23+
val coreVersion = coreVersionFile.readText().toInt()
24+
val mcVersion = project.extra["mcVersion"] as Int
25+
if (coreVersion == mcVersion) {
2226
project.configure<SourceSetContainer> {
2327
named("main") {
2428
java.setSrcDirs(listOf(originalSrc))
2529
resources.setSrcDirs(listOf(originalRes))
2630
}
2731
}
2832
} else {
29-
val mcVersion = project.extra["mcVersion"] as Int
30-
val core = project.parent!!.evaluationDependsOn("core")
31-
val coreVersion = core.extra["mcVersion"] as Int
33+
val core = project.byVersion(coreVersion)
3234
val mappingFile: File?
3335
val inherited: Project?
3436
if (coreVersion < mcVersion) {
@@ -95,24 +97,24 @@ class PreprocessPlugin : Plugin<Project> {
9597
}
9698
}
9799

98-
val setCoreVersionJava = project.tasks.create<PreprocessTask>("setCoreVersionJava") {
100+
val setCoreVersionJava = project.tasks.create<Copy>("setCoreVersionJava") {
99101
dependsOn(preprocessJava)
100-
source = project.file(preprocessedSrc)
101-
generated = project.file(originalSrc)
102-
vars = mutableMapOf("MC" to mcVersion, "DEV_ENV" to 1)
102+
from(project.file(preprocessedSrc))
103+
into(project.file(originalSrc))
103104
}
104105

105-
val setCoreVersionResources = project.tasks.create<PreprocessTask>("setCoreVersionResources") {
106-
inplace(originalRes)
107-
vars = mutableMapOf("MC" to mcVersion, "DEV_ENV" to 1)
106+
val setCoreVersionResources = project.tasks.create<Copy>("setCoreVersionResources") {
107+
dependsOn(preprocessResources)
108+
from(project.file(preprocessedRes))
109+
into(project.file(originalRes))
108110
}
109111

110112
project.tasks.create("setCoreVersion") {
111113
dependsOn(setCoreVersionJava)
112114
dependsOn(setCoreVersionResources)
113115

114116
doLast {
115-
project.file("../core/mcVersion").writeText(mcVersion.toString())
117+
coreVersionFile.writeText(mcVersion.toString())
116118
}
117119
}
118120
}

0 commit comments

Comments
 (0)