Skip to content

Commit 2da738b

Browse files
committed
Derive project MC version from project name (backwards incompatible!)
1 parent cf751cb commit 2da738b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class PreprocessPlugin : Plugin<Project> {
1818

1919
val parent = project.parent!!
2020
val coreVersion = coreVersionFile.readText().toInt()
21-
val mcVersion = project.extra["mcVersion"] as Int
21+
val mcVersion = project.getMcVersion()
22+
project.extra["mcVersion"] = mcVersion
2223
if (coreVersion == mcVersion) {
2324
project.the<SourceSetContainer>().configureEach {
2425
java.setSrcDirs(listOf(parent.file("src/$name/java")))
@@ -118,6 +119,10 @@ class PreprocessPlugin : Plugin<Project> {
118119
}
119120
}
120121

122+
private fun Project.getMcVersion(): Int = (name.split(".") + listOf("")).let { (major, minor, patch) ->
123+
"$major${minor.padStart(2, '0')}${patch.padStart(2, '0')}".toInt()
124+
}
125+
121126
private fun Project.byVersion(version: Int): Project {
122127
val name = "${version/10000}.${version/100 % 100}${if (version%100 == 0) "" else ".${version%100}"}"
123128
return project.parent!!.evaluationDependsOn(name)

0 commit comments

Comments
 (0)