- rewritten/fixed buildconfig
- less noise - cosmetics in CLI tool
This commit is contained in:
1 parent
323c455a50
commit
fffa3d31bb
8 files changed
+103
-86
No files matched your search
+62
-39
@@ -1,17 +1,40 @@
|
||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
|
||||
import com.vanniktech.maven.publish.SonatypeHost
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
group = "net.sergeych"
|
||||
version = "0.2.1-SNAPSHOT"
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0")
|
||||
classpath("com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidLibrary)
|
||||
alias(libs.plugins.vanniktech.mavenPublish)
|
||||
kotlin("plugin.serialization") version "2.1.20"
|
||||
id("com.codingfeline.buildkonfig") version "0.17.1"
|
||||
}
|
||||
|
||||
group = "net.sergeych"
|
||||
version = "0.2.0-SNAPSHOT"
|
||||
buildkonfig {
|
||||
packageName = "net.sergeych.lyng"
|
||||
// objectName = "YourAwesomeConfig"
|
||||
// exposeObjectWithName = "YourAwesomePublicConfig"
|
||||
|
||||
defaultConfigs {
|
||||
buildConfigField(STRING, "bcprovider", "codingfeline")
|
||||
buildConfigField(STRING, "version", version.toString())
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
@@ -110,40 +133,40 @@ mavenPublishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val projectVersion by project.extra(provider {
|
||||
// Compute value lazily
|
||||
(version as String)
|
||||
})
|
||||
|
||||
val generateBuildConfig by tasks.registering {
|
||||
// Declare outputs safely
|
||||
val outputDir = layout.buildDirectory.dir("generated/buildConfig/commonMain/kotlin")
|
||||
outputs.dir(outputDir)
|
||||
|
||||
val version = projectVersion.get()
|
||||
|
||||
// Inputs: Version is tracked as an input
|
||||
inputs.property("version", version)
|
||||
|
||||
doLast {
|
||||
val packageName = "net.sergeych.lyng.buildconfig"
|
||||
val packagePath = packageName.replace('.', '/')
|
||||
val buildConfigFile = outputDir.get().file("$packagePath/BuildConfig.kt").asFile
|
||||
|
||||
buildConfigFile.parentFile?.mkdirs()
|
||||
buildConfigFile.writeText(
|
||||
"""
|
||||
|package $packageName
|
||||
|
|
||||
|object BuildConfig {
|
||||
| const val VERSION = "$version"
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
dependsOn(generateBuildConfig)
|
||||
}
|
||||
//
|
||||
//val projectVersion by project.extra(provider {
|
||||
// // Compute value lazily
|
||||
// (version as String)
|
||||
//})
|
||||
//
|
||||
//val generateBuildConfig by tasks.registering {
|
||||
// // Declare outputs safely
|
||||
// val outputDir = layout.buildDirectory.dir("generated/buildConfig/commonMain/kotlin")
|
||||
// outputs.dir(outputDir)
|
||||
//
|
||||
// val version = projectVersion.get()
|
||||
//
|
||||
// // Inputs: Version is tracked as an input
|
||||
// inputs.property("version", version)
|
||||
//
|
||||
// doLast {
|
||||
// val packageName = "net.sergeych.lyng.buildconfig"
|
||||
// val packagePath = packageName.replace('.', '/')
|
||||
// val buildConfigFile = outputDir.get().file("$packagePath/BuildConfig.kt").asFile
|
||||
//
|
||||
// buildConfigFile.parentFile?.mkdirs()
|
||||
// buildConfigFile.writeText(
|
||||
// """
|
||||
// |package $packageName
|
||||
// |
|
||||
// |object BuildConfig {
|
||||
// | const val VERSION = "$version"
|
||||
// |}
|
||||
// """.trimMargin()
|
||||
// )
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
// dependsOn(generateBuildConfig)
|
||||
//}
|
||||
@@ -745,7 +745,6 @@ class Compiler(
|
||||
bodyInit?.execute(this)
|
||||
// export public
|
||||
for( (name,record) in objects ) {
|
||||
println("-- $name $record")
|
||||
when(record.visibility) {
|
||||
Visibility.Public -> {
|
||||
thisObj.publicFields += name
|
||||
@@ -770,7 +769,6 @@ class Compiler(
|
||||
f.name,
|
||||
statement {
|
||||
val context = (thisObj as ObjInstance).instanceContext
|
||||
println("called on $thisObj")
|
||||
context[f.name]?.value ?: raiseError("field is not initialized: ${f.name}")
|
||||
},
|
||||
true,
|
||||
|
||||
@@ -23,8 +23,6 @@ class ObjClass(
|
||||
override suspend fun compareTo(context: Context, other: Obj): Int = if (other === this) 0 else -1
|
||||
|
||||
override suspend fun callOn(context: Context): Obj {
|
||||
println("callOn $this constructing....")
|
||||
println("on context: $context")
|
||||
val instance = ObjInstance(this)
|
||||
instance.instanceContext = context.copy(newThisObj = instance,args = context.args)
|
||||
if (instanceConstructor != null) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
package net.sergeych.lyng
|
||||
|
||||
import net.sergeych.lyng.buildconfig.BuildConfig
|
||||
|
||||
val LyngVersion = BuildConfig.VERSION
|
||||
val LyngVersion = BuildKonfig.version
|
||||
Reference in new issue
Block a user