Skip to content

Commit

Permalink
Handle new artifact groups (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz authored Sep 26, 2023
1 parent 0828476 commit 0605947
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 113 deletions.
24 changes: 4 additions & 20 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File

import org.jetbrains.kotlin.gradle.tasks.*
import java.io.StringReader
import java.util.*

Expand Down Expand Up @@ -124,27 +124,11 @@ object BuildVersions {
const val COROUTINES = "${libs.versions.kotlinx.coroutines.get()}"
const val ANDROID_BUILD = "${libs.versions.android.build.gradle.get()}"
const val KOTLIN_SERIALIZATION = "${libs.versions.kotlinx.serialization.get()}"
const val KORGE_TEST = "$projectVersion"
const val KORGE_CORE = "$projectVersion"
const val KORGE_FOUNDATION = "$projectVersion"
const val KORLIBS = "$projectVersion"
const val KRYPTO = "$projectVersion" // Deprecated
const val KLOCK = "$projectVersion" // Deprecated
const val KDS = "$projectVersion" // Deprecated
const val KMEM = "$projectVersion" // Deprecated
const val KORMA = "$projectVersion" // Deprecated
const val KORIO = "$projectVersion" // Deprecated
const val KORIM = "$projectVersion" // Deprecated
const val KORAU = "$projectVersion" // Deprecated
const val KORGW = "$projectVersion" // Deprecated
const val KORTE = "$projectVersion" // Deprecated
const val KORGE = "$projectVersion"
val ALL_PROPERTIES by lazy { listOf(
::GIT, ::KRYPTO, ::KLOCK, ::KDS, ::KMEM,
::KORMA, ::KORIO, ::KORIM, ::KORAU, ::KORGW, ::KORGE,
::KOTLIN, ::JNA, ::COROUTINES, ::ANDROID_BUILD, ::KOTLIN_SERIALIZATION,
::KORGE_TEST, ::KORGE_CORE, ::KORGE_FOUNDATION,
::GIT, ::KOTLIN, ::NODE_JS, ::JNA, ::COROUTINES,
::ANDROID_BUILD, ::KOTLIN_SERIALIZATION, ::KORGE
) }
val ALL by lazy { ALL_PROPERTIES.associate { it.name to it.get() } }
}
Expand Down
27 changes: 7 additions & 20 deletions buildSrc/src/main/kotlin/korlibs/korge/gradle/KorgeExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import korlibs.korge.gradle.targets.js.*
import korlibs.korge.gradle.targets.jvm.*
import korlibs.korge.gradle.util.*
import korlibs.modules.*
import korlibs.root.*
import org.gradle.api.*
import org.gradle.api.artifacts.*
import org.jetbrains.kotlin.gradle.plugin.mpp.*
Expand Down Expand Up @@ -328,26 +329,12 @@ open class KorgeExtension(

val versionSubstitutions = LinkedHashMap<String, String>().also {
//it["com.soywiz.korlibs.korge-test:korge-test"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korge-core:korge-core"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korge-platform:korge-platform"] = BuildVersions.KORLIBS

it["com.soywiz.korlibs.kbignum:kbignum"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.kds:kds"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.klock:klock"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.klogger:klogger"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.kmem:kmem"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korau:korau"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korge2:korge"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korge.plugins:korge-gradle-plugin"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korge.reloadagent:korge-reload-agent"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korgw:korgw"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korim:korim"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korinject:korinject"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korio:korio"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korma:korma"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.korte:korte"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.krypto:krypto"] = BuildVersions.KORLIBS
it["com.soywiz.korlibs.ktruth:ktruth"] = BuildVersions.KORLIBS
it["${RootKorlibsPlugin.KORGE_GROUP}:korge"] = BuildVersions.KORGE
it["${RootKorlibsPlugin.KORGE_GROUP}:korge-root"] = BuildVersions.KORGE
it["${RootKorlibsPlugin.KORGE_GROUP}:korge-core"] = BuildVersions.KORGE
it["${RootKorlibsPlugin.KORGE_GROUP}:korge-platform"] = BuildVersions.KORGE
it["${RootKorlibsPlugin.KORGE_RELOAD_AGENT_GROUP}:korge-reload-agent"] = BuildVersions.KORGE
it["${RootKorlibsPlugin.KORGE_GRADLE_PLUGIN_GROUP}:korge-gradle-plugin"] = BuildVersions.KORGE
}

fun versionSubstitution(groupName: String, version: String) {
Expand Down
33 changes: 8 additions & 25 deletions buildSrc/src/main/kotlin/korlibs/korge/gradle/KorgeGradlePlugin.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
package korlibs.korge.gradle

import korlibs.korge.gradle.typedresources.*
import korlibs.*
import korlibs.korge.gradle.module.*
import korlibs.korge.gradle.targets.*
import korlibs.korge.gradle.targets.all.*
import korlibs.korge.gradle.targets.jvm.*
import korlibs.korge.gradle.targets.linux.LDLibraries
import korlibs.korge.gradle.typedresources.*
import korlibs.korge.gradle.util.*
import korlibs.*
import korlibs.modules.*
import korlibs.root.*
import org.gradle.api.*
import org.gradle.api.Project
import org.gradle.api.plugins.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.diagnostics.*
import org.gradle.internal.classloader.*
import org.gradle.plugins.ide.idea.model.*
import org.jetbrains.kotlin.gradle.dsl.*
import java.io.*
import java.net.*
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap
import java.util.*
import java.util.concurrent.*
import kotlin.concurrent.*

abstract class KorgeGradleAbstractPlugin(val projectType: ProjectType) : Plugin<Project> {
Expand Down Expand Up @@ -85,27 +84,13 @@ class KorgeGradleApply(val project: Project, val projectType: ProjectType) {
private fun Project.configureDependencies() {
dependencies {
add("commonMainApi", "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
add("commonMainApi", "com.soywiz.korlibs.korge2:korge:${korgeVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korge-core:korge-core:${korgeVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korge-platform:korge-platform:${korgeVersion}")
//add("commonMainApi", "com.soywiz.korlibs.klock:klock:${klockVersion}")
//add("commonMainApi", "com.soywiz.korlibs.kmem:kmem:${kmemVersion}")
//add("commonMainApi", "com.soywiz.korlibs.kds:kds:${kdsVersion}")
//add("commonMainApi", "com.soywiz.korlibs.krypto:krypto:${kryptoVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korma:korma:${kormaVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korio:korio:${korioVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korim:korim:${korimVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korau:korau:${korauVersion}")
//add("commonMainApi", "com.soywiz.korlibs.korgw:korgw:${korgwVersion}")
add("commonMainApi", "${RootKorlibsPlugin.KORGE_GROUP}:korge:${korgeVersion}")
//add("commonMainApi", "${RootKorlibsPlugin.KORGE_GROUP}:korge-core:${korgeVersion}")
//add("commonMainApi", "${RootKorlibsPlugin.KORGE_GROUP}:korge-platform:${korgeVersion}")
}
}

private fun Project.addVersionExtension() {
ext.set("korioVersion", korioVersion)
ext.set("kormaVersion", kormaVersion)
ext.set("korauVersion", korauVersion)
ext.set("korimVersion", korimVersion)
ext.set("korgwVersion", korgwVersion)
ext.set("korgeVersion", korgeVersion)
ext.set("kotlinVersion", kotlinVersion)
ext.set("coroutinesVersion", coroutinesVersion)
Expand All @@ -117,8 +102,6 @@ class KorgeGradleApply(val project: Project, val projectType: ProjectType) {
project.korge.addDependency("commonMainImplementation", "org.jetbrains.kotlin:kotlin-stdlib-common")
project.korge.addDependency("commonTestImplementation", "org.jetbrains.kotlin:kotlin-test")

//println("korlibs.korge2:korge:$korgeVersion")
//project.dependencies.add("commonMainImplementation", "korlibs.korge2:korge:$korgeVersion")
//gkotlin.sourceSets.maybeCreate("commonMain").dependencies {
//}
//kotlin.sourceSets.create("")
Expand Down
33 changes: 1 addition & 32 deletions buildSrc/src/main/kotlin/korlibs/korge/gradle/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
package korlibs.korge.gradle

import org.gradle.api.Project
import org.gradle.api.*

val Project.korteVersion get() = findProperty("korteVersion") ?: BuildVersions.KORTE
val Project.klockVersion get() = findProperty("klockVersion") ?: BuildVersions.KLOCK
val Project.kmemVersion get() = findProperty("kmemVersion") ?: BuildVersions.KMEM
val Project.kryptoVersion get() = findProperty("kryptoVersion") ?: BuildVersions.KRYPTO
val Project.kdsVersion get() = findProperty("kdsVersion") ?: BuildVersions.KDS
val Project.korioVersion get() = findProperty("korioVersion") ?: BuildVersions.KORIO
val Project.kormaVersion get() = findProperty("kormaVersion") ?: BuildVersions.KORMA
val Project.korauVersion get() = findProperty("korauVersion") ?: BuildVersions.KORAU
val Project.korimVersion get() = findProperty("korimVersion") ?: BuildVersions.KORIM
//val Project.koruiVersion get() = findProperty("koruiVersion") ?: BuildVersions.KORUI
//val Project.korevVersion get() = findProperty("korevVersion") ?: BuildVersions.KOREV
val Project.korgwVersion get() = findProperty("korgwVersion") ?: BuildVersions.KORGW
val Project.jnaVersion get() = findProperty("jnaVersion") ?: BuildVersions.JNA
val Project.korgeVersion get() = findProperty("korgeVersion") ?: BuildVersions.KORGE
val Project.kotlinVersion: String get() = findProperty("kotlinVersion")?.toString() ?: BuildVersions.KOTLIN
val Project.kotlinVersionIsDev: Boolean get() = kotlinVersion.contains("-release") || kotlinVersion.contains("-eap") || kotlinVersion.contains("-M") || kotlinVersion.contains("-RC")
val Project.androidBuildGradleVersion get() = findProperty("androidBuildGradleVersion") ?: BuildVersions.ANDROID_BUILD
val Project.coroutinesVersion get() = findProperty("coroutinesVersion") ?: BuildVersions.COROUTINES

fun Project.getModuleVersion(name: String, defaultVersion: Any): Any {
return when (name.split(':').last().trim().toLowerCase().split('-').first().trim()) {
"krypto" -> kryptoVersion
"klock" -> klockVersion
"kmem" -> kmemVersion
"kds" -> kdsVersion
"jna" -> jnaVersion
"korio" -> korioVersion
"korma" -> kormaVersion
"korau" -> korauVersion
"korim" -> korimVersion
"korgw" -> korgwVersion
"korge" -> korgeVersion
"kotlin" -> kotlinVersion
"kotlinx.coroutines" -> coroutinesVersion
else -> defaultVersion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun Project.configureIdea() {
it.addAll(
listOf(
".gradle", ".idea", "gradle/wrapper", ".idea", "build", "@old", "_template", "docs",
"kotlin-js-store",
"kotlin-js-store", "archive",
"korge-gradle-plugin/build/srcgen2",
"e2e-test/.gradle", "e2e-test/.idea", "e2e-test/build",
"e2e-test-multi/.gradle", "e2e-test-multi/.idea", "e2e-test-multi/build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ fun Project.configureNativeIosTvos(projectType: ProjectType, targetName: String)
framework {
baseName = "GameMain"
xcf.add(this)
//export("com.soywiz.korlibs.korgw:korgw")
//export("com.soywiz.korlibs.korge2:korge")
embedBitcodeMode.set(Framework.BitcodeEmbeddingMode.BITCODE)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package korlibs.korge.gradle.targets.jvm

import korlibs.*
import korlibs.korge.gradle.*
import korlibs.korge.gradle.gkotlin
import korlibs.korge.gradle.kotlin
import korlibs.korge.gradle.targets.*
import korlibs.korge.gradle.util.*
import korlibs.*
import korlibs.root.*
import org.gradle.api.*
import org.gradle.api.file.*
import org.gradle.api.tasks.*
Expand All @@ -14,7 +15,7 @@ import org.gradle.api.tasks.testing.*
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import proguard.gradle.*
import java.io.File
import java.io.*

val KORGE_RELOAD_AGENT_CONFIGURATION_NAME = "KorgeReloadAgent"
val httpPort = 22011
Expand Down Expand Up @@ -111,7 +112,8 @@ fun Project.configureJvmRunJvm(isRootKorlibs: Boolean) {
//.setTransitive(true)
//.setDescription("korge-reload-agent to be downloaded and used for this project.")
project.dependencies {
add(KORGE_RELOAD_AGENT_CONFIGURATION_NAME, "com.soywiz.korlibs.korge.reloadagent:korge-reload-agent:${BuildVersions.KORGE}")

add(KORGE_RELOAD_AGENT_CONFIGURATION_NAME, "${RootKorlibsPlugin.KORGE_RELOAD_AGENT_GROUP}:korge-reload-agent:${BuildVersions.KORGE}")
}
}

Expand Down
11 changes: 5 additions & 6 deletions buildSrc/src/main/kotlin/korlibs/root/RootKorlibsPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import java.io.*
import java.nio.file.*

object RootKorlibsPlugin {
val KORGE_GROUP = "com.soywiz.korge"
val KORGE_RELOAD_AGENT_GROUP = "com.soywiz.korge"
val KORGE_GRADLE_PLUGIN_GROUP = "com.soywiz.korlibs.korge.plugins"

@JvmStatic
fun doInit(rootProject: Project) {
rootProject.init()
Expand Down Expand Up @@ -101,12 +105,7 @@ object RootKorlibsPlugin {
allprojectsThis {
val projectName = project.name
val firstComponent = projectName.substringBefore('-')
group = when {
projectName == "korge-gradle-plugin" -> "com.soywiz.korlibs.korge.plugins"
projectName == "korge-reload-agent" -> "com.soywiz.korlibs.korge.reloadagent"
firstComponent == "korge" -> "com.soywiz.korlibs.korge2"
else -> "com.soywiz.korlibs.$firstComponent"
}
group = RootKorlibsPlugin.KORGE_GROUP
}
}

Expand Down
3 changes: 2 additions & 1 deletion korge-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import korlibs.korge.gradle.targets.android.*
import korlibs.root.*

plugins {
id("java")
Expand All @@ -9,7 +10,7 @@ plugins {
}

description = "Multiplatform Game Engine written in Kotlin"
group = "com.soywiz.korlibs.korge.plugins"
group = RootKorlibsPlugin.KORGE_GRADLE_PLUGIN_GROUP
//group = "korlibs.korge"
//this.name = "korlibs.korge.gradle.plugin"

Expand Down
3 changes: 2 additions & 1 deletion korge-reload-agent/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import korlibs.korge.gradle.targets.android.*
import korlibs.root.*

plugins {
//id "kotlin" version "1.6.21"
Expand All @@ -8,7 +9,7 @@ plugins {
}

description = "Multiplatform Game Engine written in Kotlin"
group = "com.soywiz.korlibs.korge.reloadagent"
group = RootKorlibsPlugin.KORGE_RELOAD_AGENT_GROUP

tasks.jar {
manifest {
Expand Down
4 changes: 2 additions & 2 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#-keep @com.soywiz.korio.annotations.Keep public class *
#-keepnames @com.soywiz.korio.annotations.Keep public class *
#-keep @korlibs.io.annotations.Keep public class *
#-keepnames @korlibs.io.annotations.Keep public class *
#-keepnames public class samples.**.Main.*
-dontobfuscate

0 comments on commit 0605947

Please sign in to comment.