[CHERRY PICKED FROM IJ] [kotlin] migrate some io operations to nio
FLEET-T-2032 GitOrigin-RevId: a616d57c763cda61386ddb754ea45ee075764eaf Original commit: https://github.com/JetBrains/intellij-community/commit/99b6620c424773a42f44fdf398c98fbaa3b55b5c
This commit is contained in:
committed by
Nikita Bobko
parent
9c9219b285
commit
0839b6a62b
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -111,7 +111,7 @@ abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest()
|
|||||||
dumpCachesForTarget(
|
dumpCachesForTarget(
|
||||||
printer, paths, target.jpsModuleBuildTarget,
|
printer, paths, target.jpsModuleBuildTarget,
|
||||||
target.localCacheVersionManager.versionFileForTesting,
|
target.localCacheVersionManager.versionFileForTesting,
|
||||||
metaBuildInfo,
|
metaBuildInfo.toFile(),
|
||||||
subdirectory = KOTLIN_CACHE_DIRECTORY_NAME
|
subdirectory = KOTLIN_CACHE_DIRECTORY_NAME
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,11 +8,11 @@ package org.jetbrains.kotlin.jps.incremental
|
|||||||
import org.jetbrains.kotlin.jps.incremental.CacheStatus
|
import org.jetbrains.kotlin.jps.incremental.CacheStatus
|
||||||
import org.jetbrains.kotlin.jps.incremental.loadDiff
|
import org.jetbrains.kotlin.jps.incremental.loadDiff
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import kotlin.io.path.Path
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class CompositeLookupsCacheAttributesManagerTest {
|
class CompositeLookupsCacheAttributesManagerTest {
|
||||||
val manager = CompositeLookupsCacheAttributesManager(File("not-used"), setOf())
|
val manager = CompositeLookupsCacheAttributesManager(Path("not-used"), setOf())
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNothingToJava() {
|
fun testNothingToJava() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -25,6 +25,9 @@ import org.jetbrains.kotlin.utils.KotlinPathsFromBaseDirectory
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
import java.lang.ref.SoftReference
|
import java.lang.ref.SoftReference
|
||||||
|
import kotlin.io.path.Path
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
import kotlin.io.path.name
|
||||||
|
|
||||||
object CompilerRunnerUtil {
|
object CompilerRunnerUtil {
|
||||||
private var ourClassLoaderRef = SoftReference<ClassLoader>(null)
|
private var ourClassLoaderRef = SoftReference<ClassLoader>(null)
|
||||||
@@ -35,17 +38,17 @@ object CompilerRunnerUtil {
|
|||||||
if (javaHomePath == null || javaHomePath.isEmpty()) {
|
if (javaHomePath == null || javaHomePath.isEmpty()) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val javaHome = File(javaHomePath)
|
val javaHome = Path(javaHomePath)
|
||||||
var toolsJar = File(javaHome, "lib/tools.jar")
|
var toolsJar = javaHome.resolve("lib/tools.jar")
|
||||||
if (toolsJar.exists()) {
|
if (toolsJar.exists()) {
|
||||||
return toolsJar.canonicalFile
|
return toolsJar.toFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
// We might be inside jre.
|
// We might be inside jre.
|
||||||
if (javaHome.name == "jre") {
|
if (javaHome.name == "jre") {
|
||||||
toolsJar = File(javaHome.parent, "lib/tools.jar")
|
toolsJar = javaHome.parent.resolve("lib/tools.jar")
|
||||||
if (toolsJar.exists()) {
|
if (toolsJar.exists()) {
|
||||||
return toolsJar.canonicalFile
|
return toolsJar.toFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -15,7 +15,8 @@ import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
|||||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
||||||
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget
|
||||||
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
|
||||||
import java.io.File
|
import java.nio.file.Path
|
||||||
|
import kotlin.io.path.writeText
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chunk of cyclically dependent [KotlinModuleBuildTarget]s
|
* Chunk of cyclically dependent [KotlinModuleBuildTarget]s
|
||||||
@@ -82,11 +83,10 @@ class KotlinChunk internal constructor(val context: KotlinCompileContext, val ta
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildMetaInfoFile(target: ModuleBuildTarget): File =
|
fun buildMetaInfoFile(target: ModuleBuildTarget): Path = context.dataPaths
|
||||||
File(
|
.getTargetDataRoot(target)
|
||||||
context.dataPaths.getTargetDataRoot(target),
|
.toPath()
|
||||||
representativeTarget.buildMetaInfoFileName
|
.resolve(representativeTarget.buildMetaInfoFileName)
|
||||||
)
|
|
||||||
|
|
||||||
fun saveVersions() {
|
fun saveVersions() {
|
||||||
context.ensureLookupsCacheAttributesSaved()
|
context.ensureLookupsCacheAttributesSaved()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -12,8 +12,7 @@ import org.jetbrains.jps.incremental.GlobalContextKey
|
|||||||
import org.jetbrains.jps.incremental.fs.CompilationRound
|
import org.jetbrains.jps.incremental.fs.CompilationRound
|
||||||
import org.jetbrains.jps.incremental.messages.BuildMessage
|
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||||
import org.jetbrains.jps.incremental.messages.CompilerMessage
|
import org.jetbrains.jps.incremental.messages.CompilerMessage
|
||||||
import org.jetbrains.kotlin.config.CompilerRunnerConstants
|
import org.jetbrains.kotlin.config.CompilerRunnerConstants.KOTLIN_COMPILER_NAME
|
||||||
import org.jetbrains.kotlin.config.CompilerRunnerConstants.*
|
|
||||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||||
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
|
||||||
import org.jetbrains.kotlin.jps.incremental.*
|
import org.jetbrains.kotlin.jps.incremental.*
|
||||||
@@ -109,7 +108,7 @@ class KotlinCompileContext(val jpsContext: CompileContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val lookupsCacheRootPath = dataPaths.getTargetDataRoot(KotlinDataContainerTarget)
|
val lookupsCacheRootPath = dataPaths.getTargetDataRoot(KotlinDataContainerTarget)
|
||||||
return CompositeLookupsCacheAttributesManager(lookupsCacheRootPath, expectedLookupsCacheComponents)
|
return CompositeLookupsCacheAttributesManager(lookupsCacheRootPath.toPath(), expectedLookupsCacheComponents)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadLookupsCacheStateDiff(): CacheAttributesDiff<CompositeLookupsCacheAttributes> {
|
private fun loadLookupsCacheStateDiff(): CacheAttributesDiff<CompositeLookupsCacheAttributes> {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.load.kotlin.JvmBytecodeBinaryVersion
|
|||||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.nio.file.Path
|
||||||
|
import kotlin.io.path.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages files with actual version [loadActual] and provides expected version [expected].
|
* Manages files with actual version [loadActual] and provides expected version [expected].
|
||||||
@@ -18,7 +20,7 @@ import java.io.IOException
|
|||||||
* Based on that status system may perform required actions (i.e. rebuild something, clearing caches, etc...).
|
* Based on that status system may perform required actions (i.e. rebuild something, clearing caches, etc...).
|
||||||
*/
|
*/
|
||||||
class CacheVersionManager(
|
class CacheVersionManager(
|
||||||
private val versionFile: File,
|
private val versionFile: Path,
|
||||||
expectedOwnVersion: Int?
|
expectedOwnVersion: Int?
|
||||||
) : CacheAttributesManager<CacheVersion> {
|
) : CacheAttributesManager<CacheVersion> {
|
||||||
override val expected: CacheVersion? =
|
override val expected: CacheVersion? =
|
||||||
@@ -26,7 +28,7 @@ class CacheVersionManager(
|
|||||||
else CacheVersion(expectedOwnVersion, JvmBytecodeBinaryVersion.INSTANCE, JvmMetadataVersion.INSTANCE)
|
else CacheVersion(expectedOwnVersion, JvmBytecodeBinaryVersion.INSTANCE, JvmMetadataVersion.INSTANCE)
|
||||||
|
|
||||||
override fun loadActual(): CacheVersion? =
|
override fun loadActual(): CacheVersion? =
|
||||||
if (!versionFile.exists()) null
|
if (versionFile.notExists()) null
|
||||||
else try {
|
else try {
|
||||||
CacheVersion(versionFile.readText().toInt())
|
CacheVersion(versionFile.readText().toInt())
|
||||||
} catch (e: NumberFormatException) {
|
} catch (e: NumberFormatException) {
|
||||||
@@ -36,16 +38,16 @@ class CacheVersionManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun writeVersion(values: CacheVersion?) {
|
override fun writeVersion(values: CacheVersion?) {
|
||||||
if (values == null) versionFile.delete()
|
if (values == null) versionFile.deleteIfExists()
|
||||||
else {
|
else {
|
||||||
versionFile.parentFile.mkdirs()
|
versionFile.parent.createDirectories()
|
||||||
versionFile.writeText(values.intValue.toString())
|
versionFile.writeText(values.intValue.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:TestOnly
|
@get:TestOnly
|
||||||
val versionFileForTesting: File
|
val versionFileForTesting: File
|
||||||
get() = versionFile
|
get() = versionFile.toFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CacheVersion(own: Int, bytecode: JvmBytecodeBinaryVersion, metadata: JvmMetadataVersion): CacheVersion {
|
fun CacheVersion(own: Int, bytecode: JvmBytecodeBinaryVersion, metadata: JvmMetadataVersion): CacheVersion {
|
||||||
|
|||||||
+8
-7
@@ -1,13 +1,14 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.jps.incremental
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
|
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.nio.file.Path
|
||||||
|
import kotlin.io.path.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes manager for global lookups cache that may contain lookups for several compilers (jvm, js).
|
* Attributes manager for global lookups cache that may contain lookups for several compilers (jvm, js).
|
||||||
@@ -16,7 +17,7 @@ import java.io.IOException
|
|||||||
* TODO(1.2.80): got rid of shared lookup cache, replace with individual lookup cache for each compiler
|
* TODO(1.2.80): got rid of shared lookup cache, replace with individual lookup cache for each compiler
|
||||||
*/
|
*/
|
||||||
class CompositeLookupsCacheAttributesManager(
|
class CompositeLookupsCacheAttributesManager(
|
||||||
rootPath: File,
|
rootPath: Path,
|
||||||
expectedComponents: Set<String>
|
expectedComponents: Set<String>
|
||||||
) : CacheAttributesManager<CompositeLookupsCacheAttributes> {
|
) : CacheAttributesManager<CompositeLookupsCacheAttributes> {
|
||||||
private val versionManager = lookupsCacheVersionManager(
|
private val versionManager = lookupsCacheVersionManager(
|
||||||
@@ -24,7 +25,7 @@ class CompositeLookupsCacheAttributesManager(
|
|||||||
expectedComponents.isNotEmpty()
|
expectedComponents.isNotEmpty()
|
||||||
)
|
)
|
||||||
|
|
||||||
private val actualComponentsFile = File(rootPath, "components.txt")
|
private val actualComponentsFile = rootPath.resolve("components.txt")
|
||||||
|
|
||||||
override val expected: CompositeLookupsCacheAttributes? =
|
override val expected: CompositeLookupsCacheAttributes? =
|
||||||
if (expectedComponents.isEmpty()) null
|
if (expectedComponents.isEmpty()) null
|
||||||
@@ -33,7 +34,7 @@ class CompositeLookupsCacheAttributesManager(
|
|||||||
override fun loadActual(): CompositeLookupsCacheAttributes? {
|
override fun loadActual(): CompositeLookupsCacheAttributes? {
|
||||||
val version = versionManager.loadActual() ?: return null
|
val version = versionManager.loadActual() ?: return null
|
||||||
|
|
||||||
if (!actualComponentsFile.exists()) return null
|
if (actualComponentsFile.notExists()) return null
|
||||||
|
|
||||||
val components = try {
|
val components = try {
|
||||||
actualComponentsFile.readLines().toSet()
|
actualComponentsFile.readLines().toSet()
|
||||||
@@ -47,11 +48,11 @@ class CompositeLookupsCacheAttributesManager(
|
|||||||
override fun writeVersion(values: CompositeLookupsCacheAttributes?) {
|
override fun writeVersion(values: CompositeLookupsCacheAttributes?) {
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
versionManager.writeVersion(null)
|
versionManager.writeVersion(null)
|
||||||
actualComponentsFile.delete()
|
actualComponentsFile.deleteIfExists()
|
||||||
} else {
|
} else {
|
||||||
versionManager.writeVersion(CacheVersion(values.version))
|
versionManager.writeVersion(CacheVersion(values.version))
|
||||||
|
|
||||||
actualComponentsFile.parentFile.mkdirs()
|
actualComponentsFile.parent.createDirectories()
|
||||||
actualComponentsFile.writeText(values.components.joinToString("\n"))
|
actualComponentsFile.writeText(values.components.joinToString("\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.jps.incremental
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
|
|
||||||
import java.io.File
|
import java.nio.file.Path
|
||||||
|
|
||||||
private val NORMAL_VERSION = 14
|
private const val NORMAL_VERSION = 14
|
||||||
private val NORMAL_VERSION_FILE_NAME = "format-version.txt"
|
private const val NORMAL_VERSION_FILE_NAME = "format-version.txt"
|
||||||
|
|
||||||
fun localCacheVersionManager(dataRoot: File, isCachesEnabled: Boolean) =
|
fun localCacheVersionManager(dataRoot: Path, isCachesEnabled: Boolean) = CacheVersionManager(
|
||||||
CacheVersionManager(
|
dataRoot.resolve(NORMAL_VERSION_FILE_NAME),
|
||||||
File(dataRoot, NORMAL_VERSION_FILE_NAME),
|
if (isCachesEnabled) NORMAL_VERSION else null
|
||||||
if (isCachesEnabled) NORMAL_VERSION else null
|
)
|
||||||
)
|
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.jps.incremental
|
package org.jetbrains.kotlin.jps.incremental
|
||||||
|
|
||||||
import java.io.File
|
import java.nio.file.Path
|
||||||
|
|
||||||
private val DATA_CONTAINER_VERSION_FILE_NAME = "data-container-format-version.txt"
|
private const val DATA_CONTAINER_VERSION_FILE_NAME = "data-container-format-version.txt"
|
||||||
private val DATA_CONTAINER_VERSION = 5
|
private const val DATA_CONTAINER_VERSION = 5
|
||||||
|
|
||||||
fun lookupsCacheVersionManager(dataRoot: File, isEnabled: Boolean) =
|
fun lookupsCacheVersionManager(dataRoot: Path, isEnabled: Boolean) = CacheVersionManager(
|
||||||
CacheVersionManager(
|
dataRoot.resolve(DATA_CONTAINER_VERSION_FILE_NAME),
|
||||||
File(dataRoot, DATA_CONTAINER_VERSION_FILE_NAME),
|
if (isEnabled) DATA_CONTAINER_VERSION else null
|
||||||
if (isEnabled) DATA_CONTAINER_VERSION else null
|
)
|
||||||
)
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -39,6 +39,9 @@ import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.JS_EXT
|
|||||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.META_JS_SUFFIX
|
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.META_JS_SUFFIX
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import kotlin.io.path.absolute
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
import kotlin.io.path.pathString
|
||||||
|
|
||||||
private const val JS_BUILD_META_INFO_FILE_NAME = "js-build-meta-info.txt"
|
private const val JS_BUILD_META_INFO_FILE_NAME = "js-build-meta-info.txt"
|
||||||
|
|
||||||
@@ -200,9 +203,9 @@ class KotlinJsModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleBu
|
|||||||
dependencyBuildTarget is KotlinJsModuleBuildTarget &&
|
dependencyBuildTarget is KotlinJsModuleBuildTarget &&
|
||||||
dependencyBuildTarget.sources.isNotEmpty()
|
dependencyBuildTarget.sources.isNotEmpty()
|
||||||
) {
|
) {
|
||||||
val metaFile = dependencyBuildTarget.outputMetaFile
|
val metaFile = dependencyBuildTarget.outputMetaFile.toPath()
|
||||||
if (metaFile.exists()) {
|
if (metaFile.exists()) {
|
||||||
result.add(metaFile.absolutePath)
|
result.add(metaFile.absolute().pathString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
package org.jetbrains.kotlin.jps.targets
|
package org.jetbrains.kotlin.jps.targets
|
||||||
@@ -47,6 +47,9 @@ import java.io.IOException
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
import kotlin.io.path.extension
|
||||||
|
import kotlin.io.path.notExists
|
||||||
|
|
||||||
private const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt"
|
private const val JVM_BUILD_META_INFO_FILE_NAME = "jvm-build-meta-info.txt"
|
||||||
|
|
||||||
@@ -267,19 +270,18 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
|
|||||||
}.toFile()
|
}.toFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findClassPathRoots(): Collection<File> {
|
private fun findClassPathRoots(): Collection<File> = allDependencies.classes().roots.filter { file ->
|
||||||
return allDependencies.classes().roots.filter { file ->
|
val path = file.toPath()
|
||||||
if (!file.exists()) {
|
if (path.notExists()) {
|
||||||
val extension = file.extension
|
val extension = path.extension
|
||||||
|
|
||||||
// Don't filter out files, we want to report warnings about absence through the common place
|
// Don't filter out files, we want to report warnings about absence through the common place
|
||||||
if (extension != "class" && extension != "jar") {
|
if (extension != "class" && extension != "jar") {
|
||||||
return@filter false
|
return@filter false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findModularJdkRoot(): File? {
|
private fun findModularJdkRoot(): File? {
|
||||||
@@ -296,12 +298,12 @@ class KotlinJvmModuleBuildTarget(kotlinContext: KotlinCompileContext, jpsModuleB
|
|||||||
|
|
||||||
private fun findSourceRoots(context: CompileContext): List<JvmSourceRoot> {
|
private fun findSourceRoots(context: CompileContext): List<JvmSourceRoot> {
|
||||||
val roots = context.projectDescriptor.buildRootIndex.getTargetRoots(jpsModuleBuildTarget, context)
|
val roots = context.projectDescriptor.buildRootIndex.getTargetRoots(jpsModuleBuildTarget, context)
|
||||||
val result = ContainerUtil.newArrayList<JvmSourceRoot>()
|
val result = mutableListOf<JvmSourceRoot>()
|
||||||
for (root in roots) {
|
for (root in roots) {
|
||||||
val file = root.rootFile
|
val file = root.rootFile
|
||||||
val prefix = root.packagePrefix
|
val prefix = root.packagePrefix
|
||||||
if (file.exists()) {
|
if (file.toPath().exists()) {
|
||||||
result.add(JvmSourceRoot(file, if (prefix.isEmpty()) null else prefix))
|
result.add(JvmSourceRoot(file, prefix.ifEmpty { null }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -40,6 +40,8 @@ import org.jetbrains.kotlin.progress.CompilationCanceledException
|
|||||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import kotlin.io.path.notExists
|
||||||
|
import kotlin.io.path.readText
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties and actions for Kotlin test / production module build target.
|
* Properties and actions for Kotlin test / production module build target.
|
||||||
@@ -69,7 +71,7 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo> intern
|
|||||||
|
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
val localCacheVersionManager = localCacheVersionManager(
|
val localCacheVersionManager = localCacheVersionManager(
|
||||||
kotlinContext.dataPaths.getTargetDataRoot(jpsModuleBuildTarget),
|
kotlinContext.dataPaths.getTargetDataRoot(jpsModuleBuildTarget).toPath(),
|
||||||
isIncrementalCompilationEnabled
|
isIncrementalCompilationEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -330,7 +332,7 @@ abstract class KotlinModuleBuildTarget<BuildMetaInfoType : BuildMetaInfo> intern
|
|||||||
|
|
||||||
fun isVersionChanged(chunk: KotlinChunk, buildMetaInfo: BuildMetaInfo): Boolean {
|
fun isVersionChanged(chunk: KotlinChunk, buildMetaInfo: BuildMetaInfo): Boolean {
|
||||||
val file = chunk.buildMetaInfoFile(jpsModuleBuildTarget)
|
val file = chunk.buildMetaInfoFile(jpsModuleBuildTarget)
|
||||||
if (!file.exists()) return false
|
if (file.notExists()) return false
|
||||||
|
|
||||||
val prevBuildMetaInfo =
|
val prevBuildMetaInfo =
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user