From a4cfd37203c649c105f52cc84430977c9126f16f Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Tue, 29 Jan 2019 19:37:06 +0300 Subject: [PATCH] Minor: Reformat dependencies.kt --- buildSrc/src/main/kotlin/dependencies.kt | 41 ++++++++++++++++-------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index d047f7c3ab8..241f1750ec1 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -1,4 +1,6 @@ -@file:Suppress("unused") // usages in build scripts are not tracked properly +@file:Suppress("unused") + +// usages in build scripts are not tracked properly import org.gradle.api.GradleException import org.gradle.api.Project @@ -28,13 +30,18 @@ fun Project.commonDep(group: String, artifact: String, vararg suffixesAndClassif } fun Project.commonVer(group: String, artifact: String) = - when { - rootProject.extra.has("versions.$artifact") -> rootProject.extra["versions.$artifact"] - rootProject.extra.has("versions.$group") -> rootProject.extra["versions.$group"] - else -> throw GradleException("Neither versions.$artifact nor versions.$group is defined in the root project's extra") - } + when { + rootProject.extra.has("versions.$artifact") -> rootProject.extra["versions.$artifact"] + rootProject.extra.has("versions.$group") -> rootProject.extra["versions.$group"] + else -> throw GradleException("Neither versions.$artifact nor versions.$group is defined in the root project's extra") + } -fun Project.preloadedDeps(vararg artifactBaseNames: String, baseDir: File = File(rootDir, "dependencies"), subdir: String? = null, optional: Boolean = false): ConfigurableFileCollection { +fun Project.preloadedDeps( + vararg artifactBaseNames: String, + baseDir: File = File(rootDir, "dependencies"), + subdir: String? = null, + optional: Boolean = false +): ConfigurableFileCollection { val dir = if (subdir != null) File(baseDir, subdir) else baseDir if (!dir.exists() || !dir.isDirectory) { if (optional) return files() @@ -42,9 +49,17 @@ fun Project.preloadedDeps(vararg artifactBaseNames: String, baseDir: File = File } val matchingFiles = dir.listFiles { file -> artifactBaseNames.any { file.matchMaybeVersionedArtifact(it) } } if (matchingFiles == null || matchingFiles.size < artifactBaseNames.size) { - throw GradleException("Not all matching artifacts '${artifactBaseNames.joinToString()}' found in the '$dir' " + - "(missing: ${artifactBaseNames.filterNot { request -> matchingFiles.any { it.matchMaybeVersionedArtifact(request) } }.joinToString()};" + - " found: ${matchingFiles?.joinToString { it.name }})") + throw GradleException( + "Not all matching artifacts '${artifactBaseNames.joinToString()}' found in the '$dir' " + + "(missing: ${artifactBaseNames.filterNot { request -> + matchingFiles.any { + it.matchMaybeVersionedArtifact( + request + ) + } + }.joinToString()};" + + " found: ${matchingFiles?.joinToString { it.name }})" + ) } return files(*matchingFiles.map { it.canonicalPath }.toTypedArray()) } @@ -73,8 +88,9 @@ fun DependencyHandler.projectArchives(name: String): ProjectDependency = project val Project.protobufVersion: String get() = findProperty("versions.protobuf") as String -val Project.protobufRepo: String get() = - "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_Protobuf),status:SUCCESS,pinned:true,tag:$protobufVersion/artifacts/content/internal/repo/" +val Project.protobufRepo: String + get() = + "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_Protobuf),status:SUCCESS,pinned:true,tag:$protobufVersion/artifacts/content/internal/repo/" fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:$protobufVersion" fun Project.protobufFull(): String = "org.jetbrains.kotlin:protobuf-relocated:$protobufVersion" @@ -100,7 +116,6 @@ private fun String.toMaybeVersionedJarRegex(): Regex { } - fun Project.firstFromJavaHomeThatExists(vararg paths: String, jdkHome: File = File(this.property("JDK_18") as String)): File? = paths.map { File(jdkHome, it) }.firstOrNull { it.exists() }.also { if (it == null)