mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 03:17:53 +01:00
String theory
- Assume group/version are behind properties in subproject.init - Force each subproject to manually specify their base archive name - Don't generate mod/api artifact ids, just write them out by hand - Remove DependentProject
This commit is contained in:
parent
02ea671d31
commit
0dc8f97b73
7 changed files with 19 additions and 41 deletions
|
@ -13,15 +13,10 @@ import org.gradle.jvm.tasks.Jar
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.properties.ReadWriteProperty
|
import kotlin.properties.Delegates
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
open class PlatformExtension(val project: Project) {
|
open class PlatformExtension(val project: Project) {
|
||||||
var commonProject: Project by DependentProject(this.project)
|
var commonProject: Project by Delegates.notNull()
|
||||||
|
|
||||||
var modArtifactId: String = "flywheel-${project.name}-${project.property("artifact_minecraft_version")}"
|
|
||||||
|
|
||||||
var apiArtifactId: String = "flywheel-${project.name}-api-${project.property("artifact_minecraft_version")}"
|
|
||||||
|
|
||||||
val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() }
|
val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() }
|
||||||
|
|
||||||
|
@ -124,19 +119,4 @@ open class PlatformExtension(val project: Project) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DependentProject(private val thisProject: Project) : ReadWriteProperty<Any?, Project> {
|
|
||||||
private var value: Project? = null
|
|
||||||
|
|
||||||
override fun getValue(thisRef: Any?, property: KProperty<*>): Project {
|
|
||||||
return value ?: throw IllegalStateException("Property ${property.name} should be initialized before get.")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: Project) {
|
|
||||||
this.value = value
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String =
|
|
||||||
"NotNullProperty(${if (value != null) "value=$value" else "value not initialized yet"})"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@ import org.gradle.kotlin.dsl.*
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
|
|
||||||
open class SubprojectExtension(val project: Project) {
|
open class SubprojectExtension(val project: Project) {
|
||||||
fun init(group: String, version: String) {
|
fun init(archiveBase: String, group: String, version: String) {
|
||||||
setBaseProperties(group, version)
|
setBaseProperties(archiveBase, group, version)
|
||||||
setupJava()
|
setupJava()
|
||||||
addRepositories()
|
addRepositories()
|
||||||
setupLoom()
|
setupLoom()
|
||||||
|
@ -26,17 +26,17 @@ open class SubprojectExtension(val project: Project) {
|
||||||
setupPublishing()
|
setupPublishing()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setBaseProperties(group: String, version: String) {
|
private fun setBaseProperties(archiveBase: String, group: String, version: String) {
|
||||||
val dev = System.getenv("RELEASE")?.contentEquals("false", true) ?: true
|
val dev = System.getenv("RELEASE")?.contentEquals("false", true) ?: true
|
||||||
val buildNumber = System.getenv("BUILD_NUMBER")
|
val buildNumber = System.getenv("BUILD_NUMBER")
|
||||||
|
|
||||||
val versionSuffix = if (dev && buildNumber != null) "-${buildNumber}" else ""
|
val versionSuffix = if (dev && buildNumber != null) "-${buildNumber}" else ""
|
||||||
|
|
||||||
project.group = group
|
project.group = project.property(group) as String
|
||||||
project.version = "${version}${versionSuffix}"
|
project.version = "${project.property(version)}${versionSuffix}"
|
||||||
|
|
||||||
project.the<BasePluginExtension>().apply {
|
project.the<BasePluginExtension>().apply {
|
||||||
archivesName = "flywheel-${project.name}-${project.property("artifact_minecraft_version")}"
|
archivesName = "${archiveBase}-${project.property("artifact_minecraft_version")}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
id("flywheel.subproject")
|
id("flywheel.subproject")
|
||||||
}
|
}
|
||||||
|
|
||||||
subproject.init(property("flywheel_group") as String, property("flywheel_version") as String)
|
subproject.init("flywheel-common", "flywheel_group", "flywheel_version")
|
||||||
|
|
||||||
val api = sourceSets.create("api")
|
val api = sourceSets.create("api")
|
||||||
val lib = sourceSets.create("lib")
|
val lib = sourceSets.create("lib")
|
||||||
|
|
|
@ -7,7 +7,7 @@ plugins {
|
||||||
id("flywheel.platform")
|
id("flywheel.platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
subproject.init(property("flywheel_group") as String, property("flywheel_version") as String)
|
subproject.init("flywheel-fabric", "flywheel_group", "flywheel_version")
|
||||||
|
|
||||||
val api = sourceSets.create("api")
|
val api = sourceSets.create("api")
|
||||||
val lib = sourceSets.create("lib")
|
val lib = sourceSets.create("lib")
|
||||||
|
@ -55,12 +55,12 @@ platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
jarSets {
|
jarSets {
|
||||||
mainSet.publish(platform.modArtifactId)
|
mainSet.publish("flywheel-fabric-${project.property("artifact_minecraft_version")}")
|
||||||
mainSet.outgoing("flywheel")
|
mainSet.outgoing("flywheel")
|
||||||
|
|
||||||
create("api", api, lib).apply {
|
create("api", api, lib).apply {
|
||||||
addToAssemble()
|
addToAssemble()
|
||||||
publish(platform.apiArtifactId)
|
publish("flywheel-fabric-api-${project.property("artifact_minecraft_version")}")
|
||||||
|
|
||||||
configureJar {
|
configureJar {
|
||||||
manifest {
|
manifest {
|
||||||
|
|
|
@ -7,7 +7,7 @@ plugins {
|
||||||
id("flywheel.platform")
|
id("flywheel.platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
subproject.init(property("flywheel_group") as String, property("flywheel_version") as String)
|
subproject.init("flywheel-forge", "flywheel_group", "flywheel_version")
|
||||||
|
|
||||||
val api = sourceSets.create("api")
|
val api = sourceSets.create("api")
|
||||||
val lib = sourceSets.create("lib")
|
val lib = sourceSets.create("lib")
|
||||||
|
@ -53,12 +53,12 @@ platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
jarSets {
|
jarSets {
|
||||||
mainSet.publish(platform.modArtifactId)
|
mainSet.publish("flywheel-forge-${project.property("artifact_minecraft_version")}")
|
||||||
mainSet.outgoing("flywheel")
|
mainSet.outgoing("flywheel")
|
||||||
|
|
||||||
create("api", api, lib).apply {
|
create("api", api, lib).apply {
|
||||||
addToAssemble()
|
addToAssemble()
|
||||||
publish(platform.apiArtifactId)
|
publish("flywheel-forge-api-${project.property("artifact_minecraft_version")}")
|
||||||
|
|
||||||
configureJar {
|
configureJar {
|
||||||
manifest {
|
manifest {
|
||||||
|
|
|
@ -10,12 +10,11 @@ plugins {
|
||||||
id("flywheel.platform")
|
id("flywheel.platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
subproject.init(property("vanillin_group") as String, property("vanillin_version") as String)
|
subproject.init("vanillin-fabric", "vanillin_group", "vanillin_version")
|
||||||
|
|
||||||
val main = sourceSets.getByName("main")
|
val main = sourceSets.getByName("main")
|
||||||
|
|
||||||
platform {
|
platform {
|
||||||
modArtifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}"
|
|
||||||
commonProject = project(":common")
|
commonProject = project(":common")
|
||||||
setupLoomRuns()
|
setupLoomRuns()
|
||||||
}
|
}
|
||||||
|
@ -49,7 +48,7 @@ tasks.named<ProcessResources>(main.processResourcesTaskName).configure {
|
||||||
}
|
}
|
||||||
|
|
||||||
jarSets {
|
jarSets {
|
||||||
mainSet.publish(platform.modArtifactId)
|
mainSet.publish("vanillin-fabric-${project.property("artifact_minecraft_version")}")
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultPackageInfos {
|
defaultPackageInfos {
|
||||||
|
|
|
@ -10,12 +10,11 @@ plugins {
|
||||||
id("flywheel.platform")
|
id("flywheel.platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
subproject.init(property("vanillin_group") as String, property("vanillin_version") as String)
|
subproject.init("vanillin-forge", "vanillin_group", "vanillin_version")
|
||||||
|
|
||||||
val main = sourceSets.getByName("main")
|
val main = sourceSets.getByName("main")
|
||||||
|
|
||||||
platform {
|
platform {
|
||||||
modArtifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}"
|
|
||||||
commonProject = project(":common")
|
commonProject = project(":common")
|
||||||
setupLoomRuns()
|
setupLoomRuns()
|
||||||
}
|
}
|
||||||
|
@ -49,7 +48,7 @@ tasks.named<ProcessResources>(main.processResourcesTaskName).configure {
|
||||||
}
|
}
|
||||||
|
|
||||||
jarSets {
|
jarSets {
|
||||||
mainSet.publish(platform.modArtifactId)
|
mainSet.publish("vanillin-forge-${project.property("artifact_minecraft_version")}")
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultPackageInfos {
|
defaultPackageInfos {
|
||||||
|
|
Loading…
Reference in a new issue