Can't use configure action from Immutable state

#KT-42413 Fixed
This commit is contained in:
nataliya.valtman
2020-10-13 12:05:09 +03:00
parent 9147aa76b5
commit 58ed1bbb64
6 changed files with 72 additions and 2 deletions
@@ -337,6 +337,19 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() {
assertTasksExecuted(lintTask) // Check that the lint task ran successfully, KT-27170
}
}
@Test
fun testJvmWithJava() = with(Project("mppJvmWithJava")) {
setupWorkingDir()
build("build") {
assertSuccessful()
}
build("assemble") {
assertSuccessful()
}
}
}
open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() {
@@ -0,0 +1,41 @@
apply plugin: 'kotlin-multiplatform'
apply plugin: 'maven-publish'
buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$android_tools_version"
}
}
repositories {
mavenLocal()
google()
jcenter()
}
kotlin {
jvm("jvmWithJava") {
withJava()
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
}
}
@@ -0,0 +1,5 @@
#kotlin_version = 1.4.255-SNAPSHOT
#android_tools_version = 3.6.0
org.gradle.paralllel=true
kotlin.parallel.tasks.in.project=true
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.compilerRunner
import org.gradle.api.Project
import org.gradle.api.UnknownTaskException
import org.gradle.api.invocation.Gradle
import org.gradle.api.logging.Logger
import org.gradle.api.plugins.JavaPluginConvention
@@ -235,8 +236,14 @@ internal open class GradleCompilerRunner(protected val taskProvider: GradleCompi
if (compilation.isMain()) {
if (isMultiplatformProject) {
project.locateTask<AbstractArchiveTask>(target.artifactsTaskName)?.configure { jarTask ->
jarToModule[jarTask.archivePathCompatible.canonicalFile] = module
try {
//It could cause task reconfiguration. TODO: fix it some day if need
// But using project.locateTask(taskName).configure cause an Exception for call from ImmutableActionSet
val archiveTask = project.tasks.getByName(target.artifactsTaskName) as AbstractArchiveTask
jarToModule[archiveTask.archivePathCompatible.canonicalFile] = module
} catch (e: UnknownTaskException) {
//ignore not found task
}
} else {
if (target is KotlinWithJavaTarget<*>) {