[Gradle, JS] Prod and dev compile tasks depends on klib compile task

This commit is contained in:
Ilya Goncharov
2019-12-26 18:55:55 +03:00
parent 3ee7e9272b
commit c043fc2272
3 changed files with 21 additions and 12 deletions
@@ -86,7 +86,7 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
protected val sourceSetName: String = kotlinCompilation.compilationName
override val kotlinTask: TaskProvider<out T> = registerKotlinCompileTask()
override val kotlinTask: TaskProvider<out T> = registerKotlinCompileTask(kotlinCompilation.compileKotlinTaskName)
protected val javaSourceSet: SourceSet?
get() =
@@ -97,7 +97,18 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
else null
}
private fun registerKotlinCompileTask(): TaskProvider<out T> {
private val defaultKotlinDestinationDir: File
get() {
val kotlinExt = project.kotlinExtension
val targetSubDirectory =
if (kotlinExt is KotlinSingleJavaTargetExtension)
"" // In single-target projects, don't add the target name part to this path
else
kotlinCompilation.target.disambiguationClassifier?.let { "$it/" }.orEmpty()
return File(project.buildDir, "classes/kotlin/$targetSubDirectory${kotlinCompilation.compilationName}")
}
protected fun registerKotlinCompileTask(): TaskProvider<out T> {
val name = kotlinCompilation.compileKotlinTaskName
logger.kotlinDebug("Creating kotlin compile task $name")
@@ -347,18 +358,18 @@ internal class KotlinJsIrSourceSetProcessor(
listOf(
compilation.productionCompileTaskName,
compilation.developmentCompileTaskName
).forEach { taskName ->
doRegisterTask(
project,
).map { taskName ->
registerKotlinCompileTask(
taskName
) {
it.description = taskDescription
it.mapClasspath { kotlinCompilation.compileDependencyFiles }
)
}.forEach { task ->
task.configure {
it.dependsOn(kotlinTask)
}
}
// outputFile can be set later during the configuration phase, get it only after the phase:
project.runOnceAfterEvaluated("Kotlin2JsSourceSetProcessor.doTargetSpecificProcessing", kotlinTask) {
project.runOnceAfterEvaluated("KotlinJsIrSourceSetProcessor.doTargetSpecificProcessing", kotlinTask) {
val kotlinTaskInstance = kotlinTask.get()
kotlinTaskInstance.kotlinOptions.outputFile = kotlinTaskInstance.outputFile.absolutePath
val outputDir = kotlinTaskInstance.outputFile.parentFile
@@ -151,7 +151,6 @@ open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
disambiguateCamelCased(
buildVariant.name,
WEBPACK_TASK_NAME
)
) {
it.dependsOn(
@@ -58,7 +58,7 @@ abstract class KotlinJsIrSubTarget(
}
override fun produceJs() {
produceByFlags(PRODUCE_UNZIPPED_KLIB, PRODUCE_JS)
produceByFlags(PRODUCE_UNZIPPED_KLIB)
configureMain()
}
@@ -66,7 +66,6 @@ abstract class KotlinJsIrSubTarget(
private fun produceByFlags(vararg flags: String) {
configure()
target.compilations
.matching { it.name == KotlinCompilation.TEST_COMPILATION_NAME }
.all {