gianluz
04/23/2019, 1:35 PMgildor
04/23/2019, 1:47 PMDominaezzz
04/23/2019, 1:55 PMkgl
using kotlinpoet. There's no nice way of reading/modifying existing Kotlin code (at least outside the JVM backend). We're sorta waiting for IR to land before anything like that is available.gildor
04/23/2019, 1:57 PMmodifying existing Kotlin codeIt’s also impossible on JVM, JSR-269 allows only read existing code and generate new code
gianluz
04/23/2019, 2:01 PMDominaezzz
04/23/2019, 2:02 PMDominaezzz
04/23/2019, 2:02 PMgianluz
04/23/2019, 2:03 PMimport gen.BuildConfigGeneratorPlugin
plugins {
id 'kotlin-multiplatform'
}
apply plugin: BuildConfigGeneratorPlugin
sourceSets {
generated {
kotlin.srcDir += "generated/source/main/kotlin"
}
}
kotlin {
targets {
fromPreset(MPPTools.defaultHostPreset(project), 'runner') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'com.danger.runner.main'
}
}
}
compileKotlinRunner{
dependsOn(generateBuildConfig)
}
but i’ve got this error:
BUILD FAILED in 0s
Could not get unknown property 'srcDir' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension.
Dominaezzz
04/23/2019, 2:03 PMbuildSrc
.gianluz
04/23/2019, 2:04 PMDominaezzz
04/23/2019, 2:05 PMsourceSets
block into the kotlin
block.Dominaezzz
04/23/2019, 2:07 PMrunnerMain
to generated
.gianluz
04/23/2019, 2:09 PMDominaezzz
04/23/2019, 2:13 PMgianluz
04/23/2019, 3:39 PM.BuildConfig
^
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':{moduleName}:compileKotlinRunner'.
here my build.gradle:
import gen.BuildConfigGeneratorPlugin
plugins {
id 'kotlin-multiplatform'
}
apply plugin: BuildConfigGeneratorPlugin
kotlin {
sourceSets {
generated {
kotlin.srcDirs += "generated/source/main/kotlin"
}
runnerMain {
dependsOn generated
}
}
targets {
fromPreset(MPPTools.defaultHostPreset(project), 'runner') {
compilations.main.outputKinds 'EXECUTABLE'
compilations.main.entryPoint 'com.danger.runner.main'
}
}
}
compileKotlinRunner {
dependsOn(generateBuildConfig)
}
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.runner) {
}
gianluz
04/23/2019, 3:40 PMDominaezzz
04/23/2019, 3:42 PMsourceSets
below targets
and if that doesn't work just rename generated
to runnerMain
and call it a day lol.gianluz
04/23/2019, 3:43 PMgianluz
04/23/2019, 3:44 PMDominaezzz
04/23/2019, 3:55 PMgenerated
.yshrsmz
04/24/2019, 12:06 AM