Javascript 如何添加gradle任务以编译其他源集
我有一个KotlinJS项目,使用Javascript 如何添加gradle任务以编译其他源集,javascript,gradle,kotlin,dsl,source-sets,Javascript,Gradle,Kotlin,Dsl,Source Sets,我有一个KotlinJS项目,使用 plugins { kotlin("js") } Kotlin编译器插件,在执行任务生成时生成新的.kt文件(现在位于文件夹$buildDir/src/main/generated)。 不幸的是,我不得不再次调用build来编译生成的源代码 因此,我想添加一个任务,通过 tasks.register("compileGenerated", org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class)
plugins {
kotlin("js")
}
Kotlin编译器插件,在执行任务生成时生成新的.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.
老实说,我不知道为什么…可以发布整个构建文件吗?您可以在