我有一个使用的KotlinJS项目
plugins {
kotlin("js")
}
Kotlin-compiler-plugin在执行任务构建时生成新的.kt文件(现在位于文件夹$buildDir/src/main/generated
中)。
不幸的是,我不得不再次调用build来编译生成的源
因此,我想添加一个通过
tasks.register("compileGenerated", org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class) {
sourceSets {
create("generated") {
kotlin.srcDir("${buildDir}/src/generated/kotlin/")
dependsOn(sourceSets.getByName("main"))
}
}
}
在每次构建结束时我都会使用finalizedBy
尝试一下,我只会收到以下消息:
> Could not create task ':examples:nestedmodel:model:compileGenerated'.
> Project#afterEvaluate(Action) on project ':example' cannot be executed in the current context.
说实话,我不知道为什么...