[imltogradle] Add additional check for absence of snapshot version in JpsLikeJarDependency
This commit is contained in:
+7
@@ -26,6 +26,13 @@ data class JpsLikeJarDependency(
|
|||||||
val dependencyConfiguration: String?,
|
val dependencyConfiguration: String?,
|
||||||
val exported: Boolean
|
val exported: Boolean
|
||||||
) : JpsLikeDependency {
|
) : JpsLikeDependency {
|
||||||
|
init {
|
||||||
|
require(!dependencyNotation.contains(DEFAULT_KOTLIN_SNAPSHOT_VERSION)) {
|
||||||
|
"JpsLikeJarDependency dependency notation ($dependencyNotation) cannot contain Kotlin snapshot version. " +
|
||||||
|
"Most likely you want to configure JpsLikeModuleDependency"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun convertToGradleCall(): String {
|
override fun convertToGradleCall(): String {
|
||||||
val scopeArg = "JpsDepScope.$scope"
|
val scopeArg = "JpsDepScope.$scope"
|
||||||
val exportedArg = "exported = true".takeIf { exported }
|
val exportedArg = "exported = true".takeIf { exported }
|
||||||
|
|||||||
+2
-4
@@ -22,6 +22,7 @@ import kotlin.system.measureNanoTime
|
|||||||
|
|
||||||
private lateinit var intellijModuleNameToGradleDependencyNotationsMapping: Map<String, List<GradleDependencyNotation>>
|
private lateinit var intellijModuleNameToGradleDependencyNotationsMapping: Map<String, List<GradleDependencyNotation>>
|
||||||
private val KOTLIN_REPO_ROOT = File(".").canonicalFile
|
private val KOTLIN_REPO_ROOT = File(".").canonicalFile
|
||||||
|
val DEFAULT_KOTLIN_SNAPSHOT_VERSION = KOTLIN_REPO_ROOT.resolve("gradle.properties").readProperty("defaultSnapshotVersion")
|
||||||
private val INTELLIJ_REPO_ROOT = KOTLIN_REPO_ROOT.resolve("intellij").resolve("community").takeIf { it.exists() }
|
private val INTELLIJ_REPO_ROOT = KOTLIN_REPO_ROOT.resolve("intellij").resolve("community").takeIf { it.exists() }
|
||||||
?: KOTLIN_REPO_ROOT.resolve("intellij")
|
?: KOTLIN_REPO_ROOT.resolve("intellij")
|
||||||
|
|
||||||
@@ -63,10 +64,7 @@ fun main() {
|
|||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
val ideaMajorVersion = KOTLIN_REPO_ROOT.resolve("local.properties").takeIf { it.exists() }
|
val ideaMajorVersion = KOTLIN_REPO_ROOT.resolve("local.properties").readProperty("attachedIntellijVersion")
|
||||||
?.inputStream()
|
|
||||||
?.use { Properties().apply { load(it) }.getProperty("attachedIntellijVersion") }
|
|
||||||
?: error("Can't find 'attachedIntellijVersion' in 'local.properties'")
|
|
||||||
|
|
||||||
intellijModuleNameToGradleDependencyNotationsMapping = fetchJsonsFromBuildserver(ideaMajorVersion)
|
intellijModuleNameToGradleDependencyNotationsMapping = fetchJsonsFromBuildserver(ideaMajorVersion)
|
||||||
.flatMap { jsonStr ->
|
.flatMap { jsonStr ->
|
||||||
|
|||||||
+6
@@ -18,6 +18,7 @@ import org.jetbrains.jps.model.module.JpsModuleDependency
|
|||||||
import org.jetbrains.jps.model.serialization.JpsProjectLoader
|
import org.jetbrains.jps.model.serialization.JpsProjectLoader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
fun String.trimMarginWithInterpolations(): String {
|
fun String.trimMarginWithInterpolations(): String {
|
||||||
val regex = Regex("""^(\s*\|)(\s*).*$""")
|
val regex = Regex("""^(\s*\|)(\s*).*$""")
|
||||||
@@ -98,3 +99,8 @@ fun fetchJsonsFromBuildserver(ideaMajorVersion: String): List<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun File.readProperty(propertyName: String): String {
|
||||||
|
return inputStream().use { Properties().apply { load(it) }.getProperty(propertyName) }
|
||||||
|
?: error("Can't find '$propertyName' in '${this.canonicalPath}'")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user