[Gradle] Add KOTLIN_PERSISTENT_GRADLE_DATA_DIR with .kotlin/ as default
Don't store data in `.gradle` as it treated specially by gradle i.e. they are exclude this dir from UP-TO-DATE checks. This can lead into broken IDE import state which is not fixable by re-importing. Move CInterop Commonized libraries and Metadata Transformation results to new KOTLIN_PERSISTENT_GRADLE_DATA_DIR to avoid IDE import issues. ^KT-58223
This commit is contained in:
committed by
Space Team
parent
405a502675
commit
73c76c5b2d
+24
-1
@@ -173,7 +173,7 @@ open class CommonizerIT : KGPBaseTest() {
|
||||
|
||||
configureCommonizerTargets()
|
||||
|
||||
val expectedOutputDirectoryForIde = projectPath.resolve(".gradle/kotlin/commonizer")
|
||||
val expectedOutputDirectoryForIde = projectPath.resolve(".kotlin/commonizer")
|
||||
val expectedOutputDirectoryForBuild = projectPath.resolve("build/classes/kotlin/commonizer")
|
||||
|
||||
build(":copyCommonizeCInteropForIde") {
|
||||
@@ -533,6 +533,29 @@ open class CommonizerIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-58223 test commonized libraries for IDE can be stored in different data dir")
|
||||
@GradleTest
|
||||
fun testCommonizedLibrariesForIDECanBeStoredInDifferentDir(gradleVersion: GradleVersion) {
|
||||
nativeProject("commonizeCurlInterop", gradleVersion) {
|
||||
gradleProperties.append("kotlin.persistent.gradle.data.dir=.kotlin_custom")
|
||||
|
||||
configureCommonizerTargets()
|
||||
|
||||
val expectedOutputDirectoryForIde = projectPath.resolve(".kotlin_custom/commonizer")
|
||||
|
||||
build(":copyCommonizeCInteropForIde") {
|
||||
assertTasksExecuted(":cinteropCurlTargetB")
|
||||
assertTasksExecuted(":commonizeCInterop")
|
||||
|
||||
assertDirectoryExists(expectedOutputDirectoryForIde, "Missing output directory for IDE")
|
||||
}
|
||||
|
||||
build(":clean") {
|
||||
assertDirectoryExists(expectedOutputDirectoryForIde, "Expected ide output directory to survive cleaning")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun `test multiple cinterops with test source sets and compilations`(
|
||||
gradleVersion: GradleVersion,
|
||||
|
||||
+11
@@ -538,6 +538,16 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
|
||||
internal fun get(propertyName: String): String? = propertiesBuildService.get(propertyName, project)
|
||||
|
||||
/**
|
||||
* The directory where persistent data for Kotlin Gradle Plugin is stored.
|
||||
* This data is not cleaned by gradle clean task. This dir can be used to store data
|
||||
* for IDE import i.e. `./gradlew clean` will not break IDE import state.
|
||||
*
|
||||
* If the property is not set, the default value `$ROOT_DIR/.kotlin` is used.
|
||||
*/
|
||||
val kotlinPersistentGradleDataDir: String
|
||||
get() = get(PropertyNames.KOTLIN_PERSISTENT_GRADLE_DATA_DIR) ?: ".kotlin"
|
||||
|
||||
/**
|
||||
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
|
||||
* @see KOTLIN_JS_KARMA_BROWSERS
|
||||
@@ -628,6 +638,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val KONAN_DATA_DIR = property("konan.data.dir")
|
||||
val KOTLIN_SUPPRESS_BUILD_TOOLS_API_VERSION_CONSISTENCY_CHECKS =
|
||||
property("kotlin.internal.suppress.buildToolsApiVersionConsistencyChecks")
|
||||
val KOTLIN_PERSISTENT_GRADLE_DATA_DIR = property("kotlin.persistent.gradle.data.dir")
|
||||
|
||||
/**
|
||||
* Internal properties: builds get big non-suppressible warning when such properties are used
|
||||
|
||||
+10
-3
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.ProjectLayout
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.utils.compositeBuildRootProject
|
||||
import java.io.File
|
||||
|
||||
@@ -18,13 +19,19 @@ internal fun ProjectLayout.kotlinTransformedMetadataLibraryDirectoryForBuild(sou
|
||||
buildDirectory.get().asFile.resolve(kotlinTransformedMetadataLibraries).resolve(sourceSetName)
|
||||
|
||||
internal val Project.kotlinTransformedMetadataLibraryDirectoryForIde: File
|
||||
get() = compositeBuildRootProject.rootDir.resolve(".gradle").resolve("kotlin").resolve(kotlinTransformedMetadataLibraries)
|
||||
get() = compositeBuildRootProject.rootDir
|
||||
.resolve(project.kotlinPropertiesProvider.kotlinPersistentGradleDataDir)
|
||||
.resolve(kotlinTransformedMetadataLibraries)
|
||||
|
||||
internal fun ProjectLayout.kotlinTransformedCInteropMetadataLibraryDirectoryForBuild(sourceSetName: String): File =
|
||||
buildDirectory.get().asFile.resolve(kotlinTransformedCInteropMetadataLibraries).resolve(sourceSetName)
|
||||
|
||||
internal val Project.kotlinCInteropLibraryDirectoryForIde: File
|
||||
get() = compositeBuildRootProject.rootDir.resolve(".gradle").resolve("kotlin").resolve(kotlinCInteropLibraries)
|
||||
get() = compositeBuildRootProject.rootDir
|
||||
.resolve(project.kotlinPropertiesProvider.kotlinPersistentGradleDataDir)
|
||||
.resolve(kotlinCInteropLibraries)
|
||||
|
||||
internal val Project.kotlinTransformedCInteropMetadataLibraryDirectoryForIde: File
|
||||
get() = compositeBuildRootProject.rootDir.resolve(".gradle").resolve("kotlin").resolve(kotlinTransformedCInteropMetadataLibraries)
|
||||
get() = compositeBuildRootProject.rootDir
|
||||
.resolve(project.kotlinPropertiesProvider.kotlinPersistentGradleDataDir)
|
||||
.resolve(kotlinTransformedCInteropMetadataLibraries)
|
||||
|
||||
+4
-1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.build.report.metrics.GradleBuildTime
|
||||
import org.jetbrains.kotlin.compilerRunner.addBuildMetricsForTaskAction
|
||||
import org.jetbrains.kotlin.gradle.report.GradleBuildMetricsReporter
|
||||
import org.jetbrains.kotlin.gradle.utils.property
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -32,7 +33,9 @@ internal abstract class CopyCommonizeCInteropForIdeTask @Inject constructor(
|
||||
commonizeCInteropTask.map { it.allOutputDirectories }
|
||||
|
||||
@get:OutputDirectory
|
||||
override val outputDirectory: File = project.rootDir.resolve(".gradle/kotlin/commonizer")
|
||||
override val outputDirectory: File = project.rootDir
|
||||
.resolve(project.kotlinPropertiesProvider.kotlinPersistentGradleDataDir)
|
||||
.resolve("commonizer")
|
||||
.resolve(project.path.removePrefix(":").replace(":", "/"))
|
||||
|
||||
@get:Internal
|
||||
|
||||
+1
-3
@@ -11,8 +11,6 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.internal.TaskInternal
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||
import org.jetbrains.kotlin.gradle.plugin.await
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.locateOrRegisterCInteropMetadataDependencyTransformationTask
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.locateOrRegisterCInteropMetadataDependencyTransformationTaskForIde
|
||||
@@ -144,7 +142,7 @@ class CInteropMetadataDependencyTransformationTaskTest : MultiplatformExtensionT
|
||||
.map { it.relativeTo(projectRootDir) }
|
||||
.toSet()
|
||||
// common root directory where all transformations stored
|
||||
.minus(File(".gradle/kotlin/kotlinTransformedCInteropMetadataLibraries"))
|
||||
.minus(File(".kotlin/kotlinTransformedCInteropMetadataLibraries"))
|
||||
}
|
||||
|
||||
suspend fun assertTasksOutputsDoesntIntersect(a: Project, b: Project) {
|
||||
|
||||
Reference in New Issue
Block a user