[Gradle] Split global and project persistent caches
Now for project persistent caches plugin will use '<rootDir>/.kotlin' directory. Global persistent cache has stayed in the '<user.home>/.kotlin' directory. ^KT-58223 Fixed
This commit is contained in:
committed by
Space Team
parent
5413973891
commit
070de9cc85
+6
-11
@@ -17,7 +17,6 @@ import kotlin.io.path.*
|
|||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.ThirdPartyDependencies.GRADLE_ENTERPRISE_PLUGIN_VERSION
|
import org.jetbrains.kotlin.gradle.testbase.TestVersions.ThirdPartyDependencies.GRADLE_ENTERPRISE_PLUGIN_VERSION
|
||||||
import org.junit.jupiter.api.io.TempDir
|
|
||||||
|
|
||||||
@DisplayName("Build reports")
|
@DisplayName("Build reports")
|
||||||
@JvmGradlePluginTests
|
@JvmGradlePluginTests
|
||||||
@@ -271,16 +270,14 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testErrorsFileSmokeTest(
|
fun testErrorsFileSmokeTest(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
@TempDir tempDir: Path,
|
|
||||||
) {
|
) {
|
||||||
project(
|
project(
|
||||||
projectName = "simpleProject",
|
projectName = "simpleProject",
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
buildOptions = defaultBuildOptions.copy(kotlinUserHome = tempDir)
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val lookupsTab = projectPath.resolve("build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab")
|
val lookupsTab = projectPath.resolve("build/kotlin/compileKotlin/cacheable/caches-jvm/lookups/lookups.tab")
|
||||||
fun kotlinErrorPath() = tempDir.inProjectsPersistentCache("errors")
|
val kotlinErrorPath = projectPersistentCache.resolve("errors")
|
||||||
|
|
||||||
buildGradle.appendText(
|
buildGradle.appendText(
|
||||||
"""
|
"""
|
||||||
@@ -293,14 +290,14 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
build("compileKotlin") {
|
build("compileKotlin") {
|
||||||
assertTrue { kotlinErrorPath().listDirectoryEntries().isEmpty() }
|
assertTrue { kotlinErrorPath.listDirectoryEntries().isEmpty() }
|
||||||
assertOutputDoesNotContain("errors were stored into file")
|
assertOutputDoesNotContain("errors were stored into file")
|
||||||
}
|
}
|
||||||
val kotlinFile = kotlinSourcesDir().resolve("helloWorld.kt")
|
val kotlinFile = kotlinSourcesDir().resolve("helloWorld.kt")
|
||||||
kotlinFile.modify { it.replace("ArrayList", "skjfghsjk") }
|
kotlinFile.modify { it.replace("ArrayList", "skjfghsjk") }
|
||||||
buildAndFail("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
buildAndFail("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||||
assertOutputContains("errors were stored into file")
|
assertOutputContains("errors were stored into file")
|
||||||
val files = kotlinErrorPath().listDirectoryEntries()
|
val files = kotlinErrorPath.listDirectoryEntries()
|
||||||
assertTrue { files.first().exists() }
|
assertTrue { files.first().exists() }
|
||||||
files.first().bufferedReader().use { reader ->
|
files.first().bufferedReader().use { reader ->
|
||||||
val kotlinVersion = reader.readLine()
|
val kotlinVersion = reader.readLine()
|
||||||
@@ -324,24 +321,22 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testErrorsFileWithCompilationError(
|
fun testErrorsFileWithCompilationError(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
@TempDir tempDir: Path,
|
|
||||||
) {
|
) {
|
||||||
project(
|
project(
|
||||||
projectName = "simpleProject",
|
projectName = "simpleProject",
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
buildOptions = defaultBuildOptions.copy(kotlinUserHome = tempDir)
|
|
||||||
) {
|
) {
|
||||||
fun kotlinErrorPath() = tempDir.inProjectsPersistentCache("errors")
|
val kotlinErrorPath = projectPersistentCache.resolve("errors")
|
||||||
|
|
||||||
build("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
build("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||||
assertOutputDoesNotContain("errors were stored into file")
|
assertOutputDoesNotContain("errors were stored into file")
|
||||||
assertTrue { kotlinErrorPath().listDirectoryEntries().isEmpty() }
|
assertTrue { kotlinErrorPath.listDirectoryEntries().isEmpty() }
|
||||||
}
|
}
|
||||||
val kotlinFile = kotlinSourcesDir().resolve("helloWorld.kt")
|
val kotlinFile = kotlinSourcesDir().resolve("helloWorld.kt")
|
||||||
kotlinFile.modify { it.replace("ArrayList", "skjfghsjk") }
|
kotlinFile.modify { it.replace("ArrayList", "skjfghsjk") }
|
||||||
buildAndFail("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
buildAndFail("compileKotlin", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||||
assertOutputDoesNotContain("errors were stored into file")
|
assertOutputDoesNotContain("errors were stored into file")
|
||||||
assertTrue { kotlinErrorPath().listDirectoryEntries().isEmpty() }
|
assertTrue { kotlinErrorPath.listDirectoryEntries().isEmpty() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-14
@@ -170,28 +170,26 @@ open class CommonizerIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testCommonizeCurlInteropcopyCommonizeCInteropForIde(
|
fun testCommonizeCurlInteropcopyCommonizeCInteropForIde(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
@TempDir tempDir: Path,
|
|
||||||
) {
|
) {
|
||||||
nativeProject("commonizeCurlInterop", gradleVersion, buildOptions = defaultBuildOptions.copy(kotlinUserHome = null)) {
|
nativeProject("commonizeCurlInterop", gradleVersion) {
|
||||||
|
|
||||||
configureCommonizerTargets()
|
configureCommonizerTargets()
|
||||||
|
|
||||||
fun expectedOutputDirectoryForIde(): Path = tempDir.inProjectsPersistentCache("commonizer")
|
val commonizerIdeOutput: Path = projectPersistentCache.resolve("metadata").resolve("commonizer")
|
||||||
|
|
||||||
val expectedOutputDirectoryForBuild = projectPath.resolve("build/classes/kotlin/commonizer")
|
val expectedOutputDirectoryForBuild = projectPath.resolve("build/classes/kotlin/commonizer")
|
||||||
|
|
||||||
build(":copyCommonizeCInteropForIde", "-Pkotlin.user.home=${tempDir.absolutePathString()}") {
|
build(":copyCommonizeCInteropForIde") {
|
||||||
assertTasksExecuted(":cinteropCurlTargetB")
|
assertTasksExecuted(":cinteropCurlTargetB")
|
||||||
assertTasksExecuted(":commonizeCInterop")
|
assertTasksExecuted(":commonizeCInterop")
|
||||||
|
|
||||||
val commonizerIdeOutput = expectedOutputDirectoryForIde()
|
|
||||||
assertDirectoryExists(commonizerIdeOutput, "Missing output directory for IDE")
|
assertDirectoryExists(commonizerIdeOutput, "Missing output directory for IDE")
|
||||||
assertDirectoryExists(expectedOutputDirectoryForBuild, "Missing output directory for build")
|
assertDirectoryExists(expectedOutputDirectoryForBuild, "Missing output directory for build")
|
||||||
assertEqualDirectories(expectedOutputDirectoryForBuild.toFile(), commonizerIdeOutput.toFile(), false)
|
assertEqualDirectories(expectedOutputDirectoryForBuild.toFile(), commonizerIdeOutput.toFile(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":clean", "-Pkotlin.user.home=${tempDir.absolutePathString()}") {
|
build(":clean") {
|
||||||
assertDirectoryExists(expectedOutputDirectoryForIde(), "Expected ide output directory to survive cleaning")
|
assertDirectoryExists(commonizerIdeOutput, "Expected ide output directory to survive cleaning")
|
||||||
assertFileNotExists(expectedOutputDirectoryForBuild, "Expected output directory for build to be cleaned")
|
assertFileNotExists(expectedOutputDirectoryForBuild, "Expected output directory for build to be cleaned")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,24 +540,21 @@ open class CommonizerIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testCommonizedLibrariesForIDECanBeStoredInDifferentDir(
|
fun testCommonizedLibrariesForIDECanBeStoredInDifferentDir(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
@TempDir tempDir: Path,
|
|
||||||
) {
|
) {
|
||||||
nativeProject("commonizeCurlInterop", gradleVersion, buildOptions = defaultBuildOptions.copy(kotlinUserHome = null)) {
|
nativeProject("commonizeCurlInterop", gradleVersion) {
|
||||||
gradleProperties.append("kotlin.user.home=${tempDir.absolutePathString()}")
|
|
||||||
|
|
||||||
configureCommonizerTargets()
|
configureCommonizerTargets()
|
||||||
|
|
||||||
fun expectedOutputDirectoryForIde(): Path = tempDir.inProjectsPersistentCache("commonizer")
|
val commonizerIdeOutput: Path = projectPersistentCache.resolve("metadata").resolve("commonizer")
|
||||||
|
|
||||||
build(":copyCommonizeCInteropForIde") {
|
build(":copyCommonizeCInteropForIde") {
|
||||||
assertTasksExecuted(":cinteropCurlTargetB")
|
assertTasksExecuted(":cinteropCurlTargetB")
|
||||||
assertTasksExecuted(":commonizeCInterop")
|
assertTasksExecuted(":commonizeCInterop")
|
||||||
|
|
||||||
assertDirectoryExists(expectedOutputDirectoryForIde(), "Missing output directory for IDE")
|
assertDirectoryExists(commonizerIdeOutput, "Missing output directory for IDE")
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":clean") {
|
build(":clean") {
|
||||||
assertDirectoryExists(expectedOutputDirectoryForIde(), "Expected ide output directory to survive cleaning")
|
assertDirectoryExists(commonizerIdeOutput, "Expected ide output directory to survive cleaning")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -191,12 +191,10 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun `test cinterops - are stored in root gradle folder`(
|
fun `test cinterops - are stored in root gradle folder`(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
@TempDir tempDir: Path,
|
|
||||||
) {
|
) {
|
||||||
project(
|
project(
|
||||||
projectName = "cinteropImport",
|
projectName = "cinteropImport",
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
buildOptions = defaultBuildOptions.copy(kotlinUserHome = tempDir)
|
|
||||||
) {
|
) {
|
||||||
resolveIdeDependencies("dep-with-cinterop") { dependencies ->
|
resolveIdeDependencies("dep-with-cinterop") { dependencies ->
|
||||||
|
|
||||||
@@ -205,7 +203,7 @@ class MppIdeDependencyResolutionIT : KGPBaseTest() {
|
|||||||
.filter { !it.isNativeDistribution && it.klibExtra?.isInterop == true }
|
.filter { !it.isNativeDistribution && it.klibExtra?.isInterop == true }
|
||||||
.ifEmpty { fail("Expected at least one cinterop on linuxX64Main") }
|
.ifEmpty { fail("Expected at least one cinterop on linuxX64Main") }
|
||||||
|
|
||||||
val persistentCInteropsCache = tempDir.inProjectsPersistentCache("kotlinCInteropLibraries")
|
val persistentCInteropsCache = projectPersistentCache.resolve("metadata").resolve("kotlinCInteropLibraries")
|
||||||
cinterops.forEach { cinterop ->
|
cinterops.forEach { cinterop ->
|
||||||
if (cinterop.classpath.isEmpty()) fail("Missing classpath for $cinterop")
|
if (cinterop.classpath.isEmpty()) fail("Missing classpath for $cinterop")
|
||||||
cinterop.classpath.forEach { cinteropFile ->
|
cinterop.classpath.forEach { cinteropFile ->
|
||||||
|
|||||||
+4
-6
@@ -5,6 +5,7 @@ import org.gradle.api.logging.configuration.WarningMode
|
|||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
|
import org.junit.jupiter.api.Disabled
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.io.TempDir
|
import org.junit.jupiter.api.io.TempDir
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@@ -293,6 +294,7 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Disabled("KT-58223: Currently is not used and we should start using it after working on followup issues")
|
||||||
@DisplayName("Possible to override kotlin.user.home location")
|
@DisplayName("Possible to override kotlin.user.home location")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun overrideKotlinUserHome(
|
fun overrideKotlinUserHome(
|
||||||
@@ -307,19 +309,15 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
|||||||
gradleProperties.appendText(
|
gradleProperties.appendText(
|
||||||
"""
|
"""
|
||||||
|
|
|
|
||||||
|kotlin.user.home=${tempDir.absolutePathString().normalizePath()}
|
|kotlin.user.home=${tempDir.resolve("kotlin-cache").absolutePathString().normalizePath()}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
|
|
||||||
build("compileKotlin") {
|
build("compileKotlin") {
|
||||||
assertTasksExecuted(":compileKotlin")
|
assertTasksExecuted(":compileKotlin")
|
||||||
|
|
||||||
val baseProjectsDir = tempDir.resolve("projects-1")
|
val baseProjectsDir = tempDir.resolve("kotlin-cache")
|
||||||
assertDirectoryExists(baseProjectsDir)
|
assertDirectoryExists(baseProjectsDir)
|
||||||
val projectsDirs = baseProjectsDir.listDirectoryEntries()
|
|
||||||
assertEquals(1, projectsDirs.size, message = "More then 1 child! Actual content ${projectsDirs.joinToString { it.pathString }}")
|
|
||||||
assertDirectoryExists(projectsDirs.first().resolve("sessions"))
|
|
||||||
assertDirectoryExists(projectsDirs.first().resolve("errors"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-15
@@ -121,20 +121,9 @@ fun Path.getSingleFileInDir(relativePath: String): Path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a path for per-project persistent cache directory from this base persistent cache directory.
|
* Get Gradle project Kotlin persistent cache.
|
||||||
*/
|
|
||||||
fun Path.projectsPersistentCache() = resolve("projects-1")
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for the specified directory in the projects persistent cache.
|
|
||||||
*
|
*
|
||||||
* @param directoryName The name of the directory to search for.
|
* **Note**: if a test project is using composite build - [GradleProject] should point to the root project in this composite build.
|
||||||
* @return The path of the directory if found.
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException if the directory does not exist in the projects cache. Usually they are populated after some build.
|
|
||||||
*/
|
*/
|
||||||
fun Path.inProjectsPersistentCache(
|
val GradleProject.projectPersistentCache: Path
|
||||||
directoryName: String
|
get() = projectPath.resolve(".kotlin")
|
||||||
) = projectsPersistentCache().findInPath(directoryName)
|
|
||||||
?: throw IllegalStateException("$directoryName does not exist in the projects cache under ${this.absolutePathString()}")
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle.plugin
|
package org.jetbrains.kotlin.gradle.plugin
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.invocation.Gradle
|
|
||||||
import org.gradle.api.logging.Logging
|
import org.gradle.api.logging.Logging
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
@@ -14,6 +13,7 @@ import org.gradle.api.services.BuildService
|
|||||||
import org.gradle.api.services.BuildServiceParameters
|
import org.gradle.api.services.BuildServiceParameters
|
||||||
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.utils.kotlinSessionsDir
|
import org.jetbrains.kotlin.gradle.utils.kotlinSessionsDir
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.registerClassLoaderScopedBuildService
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBuildServices.Parameters>, AutoCloseable {
|
internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBuildServices.Parameters>, AutoCloseable {
|
||||||
@@ -71,14 +71,10 @@ internal abstract class KotlinGradleBuildServices : BuildService<KotlinGradleBui
|
|||||||
private val INIT_MESSAGE = "Initialized $CLASS_NAME"
|
private val INIT_MESSAGE = "Initialized $CLASS_NAME"
|
||||||
private val DISPOSE_MESSAGE = "Disposed $CLASS_NAME"
|
private val DISPOSE_MESSAGE = "Disposed $CLASS_NAME"
|
||||||
|
|
||||||
fun registerIfAbsent(gradle: Gradle): Provider<KotlinGradleBuildServices> =
|
fun registerIfAbsent(project: Project): Provider<KotlinGradleBuildServices> =
|
||||||
gradle.sharedServices.registerIfAbsent(
|
project.gradle.registerClassLoaderScopedBuildService(KotlinGradleBuildServices::class) {
|
||||||
"kotlin-build-service-${KotlinGradleBuildServices::class.java.canonicalName}_${KotlinGradleBuildServices::class.java.classLoader.hashCode()}",
|
it.parameters.sessionsDir.set(project.kotlinSessionsDir)
|
||||||
KotlinGradleBuildServices::class.java
|
|
||||||
) { service ->
|
|
||||||
service.parameters.sessionsDir.set(gradle.rootProject.kotlinSessionsDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -82,7 +82,7 @@ abstract class DefaultKotlinBasePlugin : KotlinBasePlugin {
|
|||||||
addGradlePluginMetadataAttributes(project)
|
addGradlePluginMetadataAttributes(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinGradleBuildServices = KotlinGradleBuildServices.registerIfAbsent(project.gradle).get()
|
val kotlinGradleBuildServices = KotlinGradleBuildServices.registerIfAbsent(project).get()
|
||||||
if (!project.isProjectIsolationEnabled) {
|
if (!project.isProjectIsolationEnabled) {
|
||||||
kotlinGradleBuildServices.detectKotlinPluginLoadedInMultipleProjects(project, pluginVersion)
|
kotlinGradleBuildServices.detectKotlinPluginLoadedInMultipleProjects(project, pluginVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -543,7 +543,16 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
*
|
*
|
||||||
* If the property is not set, the plugin will use `<user_home>/.kotlin` as default.
|
* If the property is not set, the plugin will use `<user_home>/.kotlin` as default.
|
||||||
*/
|
*/
|
||||||
val kotlinUserHomeDir: String? = get(PropertyNames.KOTLIN_USER_HOME_DIR)
|
val kotlinUserHomeDir: String?
|
||||||
|
get() = get(PropertyNames.KOTLIN_USER_HOME_DIR)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The directory where Kotlin stores project-specific persistent caches.
|
||||||
|
*
|
||||||
|
* If the property is not set, the plugin will use `<project_dir>/.kotlin` as default.
|
||||||
|
*/
|
||||||
|
val kotlinProjectPersistentDir: String?
|
||||||
|
get() = get(PropertyNames.KOTLIN_PROJECT_PERSISTENT_DIR)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
|
* Retrieves a comma-separated list of browsers to use when running karma tests for [target]
|
||||||
@@ -636,6 +645,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
val KOTLIN_SUPPRESS_BUILD_TOOLS_API_VERSION_CONSISTENCY_CHECKS =
|
val KOTLIN_SUPPRESS_BUILD_TOOLS_API_VERSION_CONSISTENCY_CHECKS =
|
||||||
property("kotlin.internal.suppress.buildToolsApiVersionConsistencyChecks")
|
property("kotlin.internal.suppress.buildToolsApiVersionConsistencyChecks")
|
||||||
val KOTLIN_USER_HOME_DIR = property("kotlin.user.home")
|
val KOTLIN_USER_HOME_DIR = property("kotlin.user.home")
|
||||||
|
val KOTLIN_PROJECT_PERSISTENT_DIR = property("kotlin.project.persistent.dir")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal properties: builds get big non-suppressible warning when such properties are used
|
* Internal properties: builds get big non-suppressible warning when such properties are used
|
||||||
|
|||||||
+3
-6
@@ -19,19 +19,16 @@ internal fun ProjectLayout.kotlinTransformedMetadataLibraryDirectoryForBuild(sou
|
|||||||
buildDirectory.get().asFile.resolve(kotlinTransformedMetadataLibraries).resolve(sourceSetName)
|
buildDirectory.get().asFile.resolve(kotlinTransformedMetadataLibraries).resolve(sourceSetName)
|
||||||
|
|
||||||
internal val Project.kotlinTransformedMetadataLibraryDirectoryForIde: File
|
internal val Project.kotlinTransformedMetadataLibraryDirectoryForIde: File
|
||||||
get() = compositeBuildRootProject
|
get() = kotlinMetadataDir(compositeBuildRootProject)
|
||||||
.kotlinMetadataDir
|
|
||||||
.resolve(kotlinTransformedMetadataLibraries)
|
.resolve(kotlinTransformedMetadataLibraries)
|
||||||
|
|
||||||
internal fun ProjectLayout.kotlinTransformedCInteropMetadataLibraryDirectoryForBuild(sourceSetName: String): File =
|
internal fun ProjectLayout.kotlinTransformedCInteropMetadataLibraryDirectoryForBuild(sourceSetName: String): File =
|
||||||
buildDirectory.get().asFile.resolve(kotlinTransformedCInteropMetadataLibraries).resolve(sourceSetName)
|
buildDirectory.get().asFile.resolve(kotlinTransformedCInteropMetadataLibraries).resolve(sourceSetName)
|
||||||
|
|
||||||
internal val Project.kotlinCInteropLibraryDirectoryForIde: File
|
internal val Project.kotlinCInteropLibraryDirectoryForIde: File
|
||||||
get() = compositeBuildRootProject
|
get() = kotlinMetadataDir(compositeBuildRootProject)
|
||||||
.kotlinMetadataDir
|
|
||||||
.resolve(kotlinCInteropLibraries)
|
.resolve(kotlinCInteropLibraries)
|
||||||
|
|
||||||
internal val Project.kotlinTransformedCInteropMetadataLibraryDirectoryForIde: File
|
internal val Project.kotlinTransformedCInteropMetadataLibraryDirectoryForIde: File
|
||||||
get() = compositeBuildRootProject
|
get() = kotlinMetadataDir(compositeBuildRootProject)
|
||||||
.kotlinMetadataDir
|
|
||||||
.resolve(kotlinTransformedCInteropMetadataLibraries)
|
.resolve(kotlinTransformedCInteropMetadataLibraries)
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ internal abstract class CopyCommonizeCInteropForIdeTask @Inject constructor(
|
|||||||
commonizeCInteropTask.map { it.allOutputDirectories }
|
commonizeCInteropTask.map { it.allOutputDirectories }
|
||||||
|
|
||||||
@get:OutputDirectory
|
@get:OutputDirectory
|
||||||
override val outputDirectory: File = project.kotlinMetadataDir
|
override val outputDirectory: File = project.kotlinMetadataDir()
|
||||||
.resolve("commonizer")
|
.resolve("commonizer")
|
||||||
.resolve(project.path.removePrefix(":").replace(":", "/"))
|
.resolve(project.path.removePrefix(":").replace(":", "/"))
|
||||||
|
|
||||||
|
|||||||
+11
-17
@@ -8,31 +8,25 @@ package org.jetbrains.kotlin.gradle.utils
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.MessageDigest
|
|
||||||
|
|
||||||
private const val PROJECTS_CACHE_NAME = "projects"
|
|
||||||
private const val PROJECTS_CACHE_VERSION = 1
|
|
||||||
private const val PROJECTS_CACHE_NAME_FULL = "$PROJECTS_CACHE_NAME-$PROJECTS_CACHE_VERSION"
|
|
||||||
|
|
||||||
private const val SESSIONS_DIR_NAME = "sessions"
|
private const val SESSIONS_DIR_NAME = "sessions"
|
||||||
private const val METADATA_DIR_NAME = "metadata"
|
private const val METADATA_DIR_NAME = "metadata"
|
||||||
private const val ERRORS_DIR_NAME = "errors"
|
private const val ERRORS_DIR_NAME = "errors"
|
||||||
|
|
||||||
internal val Project.basePersistentDir
|
@Suppress("unused") // will be used in the followup KT-58223 issues
|
||||||
|
internal val Project.userKotlinPersistentDir
|
||||||
get() = kotlinPropertiesProvider.kotlinUserHomeDir?.let { File(it) }
|
get() = kotlinPropertiesProvider.kotlinUserHomeDir?.let { File(it) }
|
||||||
?: File(System.getProperty("user.home")).resolve(".kotlin")
|
?: File(System.getProperty("user.home")).resolve(".kotlin")
|
||||||
|
|
||||||
internal val Project.kotlinSessionsDir
|
internal fun Project.projectKotlinPersistentDir(compositeRootProject: Project? = null) =
|
||||||
get() = basePersistentDir.resolve(PROJECTS_CACHE_NAME_FULL).resolve(rootDir.absolutePathMd5Hash()).resolve(SESSIONS_DIR_NAME)
|
kotlinPropertiesProvider.kotlinProjectPersistentDir?.let { File(it) }
|
||||||
|
?: (compositeRootProject ?: this).rootDir.resolve(".kotlin")
|
||||||
|
|
||||||
internal val Project.kotlinMetadataDir
|
internal val Project.kotlinSessionsDir
|
||||||
get() = basePersistentDir.projectSpecificCache(rootDir).resolve(METADATA_DIR_NAME)
|
get() = projectKotlinPersistentDir().resolve(SESSIONS_DIR_NAME)
|
||||||
|
|
||||||
|
internal fun Project.kotlinMetadataDir(compositeBuildRootProject: Project? = null) =
|
||||||
|
projectKotlinPersistentDir(compositeBuildRootProject).resolve(METADATA_DIR_NAME)
|
||||||
|
|
||||||
internal val Project.kotlinErrorsDir
|
internal val Project.kotlinErrorsDir
|
||||||
get() = basePersistentDir.projectSpecificCache(rootDir).resolve(ERRORS_DIR_NAME)
|
get() = projectKotlinPersistentDir().resolve(ERRORS_DIR_NAME)
|
||||||
|
|
||||||
private val md5Digest by lazy { MessageDigest.getInstance("MD5") }
|
|
||||||
|
|
||||||
private fun File.absolutePathMd5Hash(): String = md5Digest.digest(absolutePath.toByteArray()).toHexString()
|
|
||||||
|
|
||||||
private fun File.projectSpecificCache(projectRootDir: File) = resolve(PROJECTS_CACHE_NAME_FULL).resolve(projectRootDir.absolutePathMd5Hash())
|
|
||||||
|
|||||||
Reference in New Issue
Block a user