mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] project-model-updater: normalize root path
^KTIJ-35777 GitOrigin-RevId: 745494e8986ebaa126aa38d29230eca95e38eb85
This commit is contained in:
committed by
intellij-monorepo-bot
parent
effbe80afb
commit
c2d61023e6
+11
-4
@@ -23,19 +23,25 @@ object KotlinTestsDependenciesUtil {
|
||||
|
||||
// We cannot reference PathManager or build scripts here because we call this code from Gradle in TeamCity
|
||||
val communityRoot: Path by lazy {
|
||||
findCommunityRoot().toAbsolutePath().normalize()
|
||||
}
|
||||
|
||||
private fun findCommunityRoot(): Path {
|
||||
val possibleHomePaths = mutableListOf<Path>()
|
||||
System.getProperty(PROPERTY_HOME_PATH)?.let { possibleHomePaths.add(Path(it)) }
|
||||
System.getenv(IDEA_HOME)?.let { possibleHomePaths.add(Path(it)) }
|
||||
possibleHomePaths.add(Path("."))
|
||||
for (explicit in possibleHomePaths) {
|
||||
if (explicit.resolve(COMMUNITY_MARKER).isRegularFile()) {
|
||||
return@lazy explicit
|
||||
return explicit
|
||||
}
|
||||
|
||||
val communityPath = explicit.resolve("community")
|
||||
if (communityPath.resolve(COMMUNITY_MARKER).isRegularFile()) {
|
||||
return@lazy communityPath.toAbsolutePath()
|
||||
return communityPath.toAbsolutePath()
|
||||
}
|
||||
}
|
||||
|
||||
val aClass: Class<*> = KotlinTestsDependenciesUtil::class.java
|
||||
val aClassFilename = "${aClass.getName().replace('.', '/')}.class"
|
||||
val aClassLocation = aClass.classLoader.getResource(aClassFilename)?.toString()?.substringAfter("file:")
|
||||
@@ -54,15 +60,16 @@ object KotlinTestsDependenciesUtil {
|
||||
|
||||
while (rootPath != null) {
|
||||
if (rootPath.resolve(COMMUNITY_MARKER).isRegularFile()) {
|
||||
return@lazy rootPath.toAbsolutePath()
|
||||
return rootPath.toAbsolutePath()
|
||||
} else if (rootPath.resolve(ULTIMATE_MARKER).isRegularFile()) {
|
||||
val communityPath = rootPath.resolve("community")
|
||||
if (communityPath.isDirectory()) {
|
||||
return@lazy communityPath.toAbsolutePath()
|
||||
return communityPath.toAbsolutePath()
|
||||
}
|
||||
}
|
||||
rootPath = rootPath.parent
|
||||
}
|
||||
|
||||
error("cannot detect community root path for class $aClassLocation")
|
||||
}
|
||||
|
||||
|
||||
-2
@@ -21,8 +21,6 @@ internal fun publishCompiler(preferences: GeneratorPreferences) {
|
||||
val kotlinSnapshotPath = KotlinTestsDependenciesUtil.communityRoot
|
||||
.resolve("lib")
|
||||
.resolve("kotlin-snapshot")
|
||||
.absolute()
|
||||
.normalize()
|
||||
|
||||
println("Artifacts path: $kotlinSnapshotPath")
|
||||
|
||||
|
||||
+2
-13
@@ -5,9 +5,7 @@ import org.jetbrains.tools.model.updater.impl.JpsLibrary
|
||||
import org.jetbrains.tools.model.updater.impl.JpsResolverSettings
|
||||
import org.jetbrains.tools.model.updater.impl.readJpsResolverSettings
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.deleteExisting
|
||||
import kotlin.io.path.isDirectory
|
||||
import kotlin.io.path.listDirectoryEntries
|
||||
import kotlin.io.path.readText
|
||||
import kotlin.io.path.writeText
|
||||
@@ -15,17 +13,8 @@ import kotlin.io.path.writeText
|
||||
internal fun updateProjectModel(preferences: GeneratorPreferences) {
|
||||
copyBootstrapArtifactsToMavenRepositoryIfExists()
|
||||
|
||||
val communityRoot = generateSequence(Path(".").toRealPath()) { it.parent }.first {
|
||||
it.resolve(".idea").isDirectory() &&
|
||||
!it.resolve("community").isDirectory() &&
|
||||
// This file name check is needed since the project model updater might be opened as a standalone project
|
||||
it.fileName.toString() != "project-model-updater"
|
||||
}
|
||||
|
||||
val monorepoRoot = communityRoot.parent.takeIf {
|
||||
// The community name check is required since the community might be placed directly inside another repo (e.g., kotlin)
|
||||
it.resolve(".idea").isDirectory() && it.resolve("community").isDirectory()
|
||||
}
|
||||
val communityRoot = KotlinTestsDependenciesUtil.communityRoot
|
||||
val monorepoRoot = KotlinTestsDependenciesUtil.monorepoRoot
|
||||
|
||||
val resolverSettings = readJpsResolverSettings(communityRoot, monorepoRoot)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user