Minor: Reformat and fix warnings in dependencies.kt
This commit is contained in:
committed by
teamcity
parent
944c7990a1
commit
443cbcbc3c
@@ -3,10 +3,6 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:Suppress("unused")
|
|
||||||
|
|
||||||
// usages in build scripts are not tracked properly
|
|
||||||
|
|
||||||
import org.gradle.api.GradleException
|
import org.gradle.api.GradleException
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.*
|
import org.gradle.api.artifacts.*
|
||||||
@@ -14,10 +10,7 @@ import org.gradle.api.artifacts.dsl.DependencyHandler
|
|||||||
import org.gradle.api.file.ConfigurableFileCollection
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.internal.jvm.Jvm
|
import org.gradle.internal.jvm.Jvm
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
|
||||||
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
|
|
||||||
import org.gradle.kotlin.dsl.closureOf
|
import org.gradle.kotlin.dsl.closureOf
|
||||||
import org.gradle.kotlin.dsl.exclude
|
|
||||||
import org.gradle.kotlin.dsl.extra
|
import org.gradle.kotlin.dsl.extra
|
||||||
import org.gradle.kotlin.dsl.project
|
import org.gradle.kotlin.dsl.project
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -25,33 +18,35 @@ import java.io.File
|
|||||||
private val Project.isEAPIntellij get() = rootProject.extra["versions.intellijSdk"].toString().contains("-EAP-")
|
private val Project.isEAPIntellij get() = rootProject.extra["versions.intellijSdk"].toString().contains("-EAP-")
|
||||||
private val Project.isNightlyIntellij get() = rootProject.extra["versions.intellijSdk"].toString().endsWith("SNAPSHOT") && !isEAPIntellij
|
private val Project.isNightlyIntellij get() = rootProject.extra["versions.intellijSdk"].toString().endsWith("SNAPSHOT") && !isEAPIntellij
|
||||||
|
|
||||||
val Project.intellijRepo get() =
|
val Project.intellijRepo
|
||||||
when {
|
get() =
|
||||||
isEAPIntellij -> "https://www.jetbrains.com/intellij-repository/snapshots"
|
when {
|
||||||
isNightlyIntellij -> "https://www.jetbrains.com/intellij-repository/nightly"
|
isEAPIntellij -> "https://www.jetbrains.com/intellij-repository/snapshots"
|
||||||
else -> "https://www.jetbrains.com/intellij-repository/releases"
|
isNightlyIntellij -> "https://www.jetbrains.com/intellij-repository/nightly"
|
||||||
}
|
else -> "https://www.jetbrains.com/intellij-repository/releases"
|
||||||
|
}
|
||||||
|
|
||||||
val Project.internalBootstrapRepo: String? get() =
|
val Project.internalBootstrapRepo: String?
|
||||||
when {
|
get() =
|
||||||
bootstrapKotlinRepo?.startsWith("https://buildserver.labs.intellij.net") == true
|
when {
|
||||||
|| bootstrapKotlinRepo?.startsWith("https://teamcity.jetbrains.com") == true ->
|
bootstrapKotlinRepo?.startsWith("https://buildserver.labs.intellij.net") == true
|
||||||
bootstrapKotlinRepo!!.replace("artifacts/content/maven", "artifacts/content/internal/repo")
|
|| bootstrapKotlinRepo?.startsWith("https://teamcity.jetbrains.com") == true ->
|
||||||
|
bootstrapKotlinRepo!!.replace("artifacts/content/maven", "artifacts/content/internal/repo")
|
||||||
|
|
||||||
project.kotlinBuildProperties.isJpsBuildEnabled ->
|
project.kotlinBuildProperties.isJpsBuildEnabled ->
|
||||||
"https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Aggregate)," +
|
"https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Aggregate)," +
|
||||||
"number:$bootstrapKotlinVersion,branch:default:any/artifacts/content/internal/repo/"
|
"number:$bootstrapKotlinVersion,branch:default:any/artifacts/content/internal/repo/"
|
||||||
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.commonDependency(coord: String): String {
|
fun Project.commonDependency(coordinates: String): String {
|
||||||
val parts = coord.split(':')
|
val parts = coordinates.split(':')
|
||||||
return when (parts.size) {
|
return when (parts.size) {
|
||||||
1 -> "$coord:$coord:${commonDependencyVersion(coord, coord)}"
|
1 -> "$coordinates:$coordinates:${commonDependencyVersion(coordinates, coordinates)}"
|
||||||
2 -> "${parts[0]}:${parts[1]}:${commonDependencyVersion(parts[0], parts[1])}"
|
2 -> "${parts[0]}:${parts[1]}:${commonDependencyVersion(parts[0], parts[1])}"
|
||||||
3 -> coord
|
3 -> coordinates
|
||||||
else -> throw IllegalArgumentException("Illegal maven coordinates: $coord")
|
else -> throw IllegalArgumentException("Illegal maven coordinates: $coordinates")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,10 +65,10 @@ fun Project.commonDependencyVersion(group: String, artifact: String) =
|
|||||||
fun Project.preloadedDeps(
|
fun Project.preloadedDeps(
|
||||||
vararg artifactBaseNames: String,
|
vararg artifactBaseNames: String,
|
||||||
baseDir: File = File(rootDir, "dependencies"),
|
baseDir: File = File(rootDir, "dependencies"),
|
||||||
subdir: String? = null,
|
subDir: String? = null,
|
||||||
optional: Boolean = false
|
optional: Boolean = false
|
||||||
): ConfigurableFileCollection {
|
): ConfigurableFileCollection {
|
||||||
val dir = if (subdir != null) File(baseDir, subdir) else baseDir
|
val dir = if (subDir != null) File(baseDir, subDir) else baseDir
|
||||||
if (!dir.exists() || !dir.isDirectory) {
|
if (!dir.exists() || !dir.isDirectory) {
|
||||||
if (optional) return files()
|
if (optional) return files()
|
||||||
throw GradleException("Invalid base directory $dir")
|
throw GradleException("Invalid base directory $dir")
|
||||||
@@ -82,20 +77,22 @@ fun Project.preloadedDeps(
|
|||||||
if (matchingFiles == null || matchingFiles.size < artifactBaseNames.size) {
|
if (matchingFiles == null || matchingFiles.size < artifactBaseNames.size) {
|
||||||
throw GradleException(
|
throw GradleException(
|
||||||
"Not all matching artifacts '${artifactBaseNames.joinToString()}' found in the '$dir' " +
|
"Not all matching artifacts '${artifactBaseNames.joinToString()}' found in the '$dir' " +
|
||||||
"(missing: ${artifactBaseNames.filterNot { request ->
|
"(missing: ${
|
||||||
matchingFiles.any {
|
artifactBaseNames.filterNot { request ->
|
||||||
it.matchMaybeVersionedArtifact(
|
matchingFiles?.any {
|
||||||
request
|
it.matchMaybeVersionedArtifact(
|
||||||
)
|
request
|
||||||
}
|
)
|
||||||
}.joinToString()};" +
|
} ?: false
|
||||||
|
}.joinToString()
|
||||||
|
};" +
|
||||||
" found: ${matchingFiles?.joinToString { it.name }})"
|
" found: ${matchingFiles?.joinToString { it.name }})"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return files(*matchingFiles.map { it.canonicalPath }.toTypedArray())
|
return files(*matchingFiles.map { it.canonicalPath }.toTypedArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.kotlinDep(artifactBaseName: String, version: String, classifier: String? = null): String =
|
fun kotlinDep(artifactBaseName: String, version: String, classifier: String? = null): String =
|
||||||
listOfNotNull("org.jetbrains.kotlin:kotlin-$artifactBaseName:$version", classifier).joinToString(":")
|
listOfNotNull("org.jetbrains.kotlin:kotlin-$artifactBaseName:$version", classifier).joinToString(":")
|
||||||
|
|
||||||
fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): Any {
|
fun Project.kotlinStdlib(suffix: String? = null, classifier: String? = null): Any {
|
||||||
@@ -126,6 +123,7 @@ fun DependencyHandler.add(configurationName: String, dependencyNotation: Any, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused") // Used in cooperative mode with IDEA Kotlin plugin
|
||||||
fun Project.disableDependencyVerification() {
|
fun Project.disableDependencyVerification() {
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
@@ -171,6 +169,7 @@ fun DependencyHandler.jpsLikeJarDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused") // Used in cooperative mode with IDEA Kotlin plugin
|
||||||
fun DependencyHandler.jpsLikeModuleDependency(moduleName: String, scope: JpsDepScope, exported: Boolean = false) {
|
fun DependencyHandler.jpsLikeModuleDependency(moduleName: String, scope: JpsDepScope, exported: Boolean = false) {
|
||||||
jpsLikeJarDependency(project(moduleName), scope, exported = exported)
|
jpsLikeJarDependency(project(moduleName), scope, exported = exported)
|
||||||
when (scope) {
|
when (scope) {
|
||||||
@@ -305,5 +304,5 @@ val compilerManifestClassPath
|
|||||||
get() = "annotations-13.0.jar kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar"
|
get() = "annotations-13.0.jar kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar"
|
||||||
|
|
||||||
object EmbeddedComponents {
|
object EmbeddedComponents {
|
||||||
val CONFIGURATION_NAME = "embedded"
|
const val CONFIGURATION_NAME = "embedded"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user