Build: Minor cleanup & format root build.gradle.kts

This commit is contained in:
Vyacheslav Gerasimov
2019-05-20 14:45:40 +03:00
parent 40e9f48bd0
commit c2a2d80d4c
2 changed files with 156 additions and 134 deletions
+2
View File
@@ -4,9 +4,11 @@
<w>cidr</w> <w>cidr</w>
<w>foldable</w> <w>foldable</w>
<w>instrumentator</w> <w>instrumentator</w>
<w>jdks</w>
<w>protobuf</w> <w>protobuf</w>
<w>redirector</w> <w>redirector</w>
<w>remapper</w> <w>remapper</w>
<w>unpresent</w>
</words> </words>
</dictionary> </dictionary>
</component> </component>
+154 -134
View File
@@ -1,4 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.plugins.ide.idea.model.IdeaModel import org.gradle.plugins.ide.idea.model.IdeaModel
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
@@ -64,11 +63,11 @@ buildScan {
} }
val configuredJdks: List<JdkId> = val configuredJdks: List<JdkId> =
getConfiguredJdks().also { getConfiguredJdks().also {
it.forEach { it.forEach { jdkId ->
logger.info("Using ${it.majorVersion} home: ${it.homeDir}") logger.info("Using ${jdkId.majorVersion} home: ${jdkId.homeDir}")
}
} }
}
val defaultSnapshotVersion: String by extra val defaultSnapshotVersion: String by extra
val buildNumber by extra(findProperty("build.number")?.toString() ?: defaultSnapshotVersion) val buildNumber by extra(findProperty("build.number")?.toString() ?: defaultSnapshotVersion)
@@ -136,10 +135,20 @@ fun checkJDK() {
if (jdkChecked) { if (jdkChecked) {
return return
} }
var unpresentJdks = JdkMajorVersion.values().filter { it.isMandatory() }.map { it -> it.name }.filter { it == null || extra[it] == jdkNotFoundConst }.toList()
if (!unpresentJdks.isEmpty()) { val unpresentJdks = JdkMajorVersion.values()
throw GradleException("Please set environment variable${if (unpresentJdks.size > 1) "s" else ""}: ${unpresentJdks.joinToString()} to point to corresponding JDK installation.") .filter { it.isMandatory() }
.map { it.name }
.filter { extra[it] == jdkNotFoundConst }
.toList()
if (unpresentJdks.isNotEmpty()) {
throw GradleException("Please set environment variable" +
(if (unpresentJdks.size > 1) "s" else "") +
": " + unpresentJdks.joinToString() +
" to point to corresponding JDK installation.")
} }
jdkChecked = true jdkChecked = true
} }
@@ -191,92 +200,94 @@ extra["intellijUltimateEnabled"] = intellijUltimateEnabled
extra["intellijSeparateSdks"] = intellijSeparateSdks extra["intellijSeparateSdks"] = intellijSeparateSdks
extra["IntellijCoreDependencies"] = extra["IntellijCoreDependencies"] =
listOf(if (Platform[191].orHigher()) "asm-all-7.0.1" else "asm-all", listOf(
"guava", if (Platform[191].orHigher()) "asm-all-7.0.1" else "asm-all",
"jdom", "guava",
"jna", "jdom",
"log4j", "jna",
"picocontainer", "log4j",
"snappy-in-java", "picocontainer",
"streamex", "snappy-in-java",
"trove4j") "streamex",
"trove4j"
)
extra["compilerModules"] = arrayOf( extra["compilerModules"] = arrayOf(
":compiler:util", ":compiler:util",
":compiler:container", ":compiler:container",
":compiler:resolution", ":compiler:resolution",
":compiler:serialization", ":compiler:serialization",
":compiler:psi", ":compiler:psi",
":compiler:frontend", ":compiler:frontend",
":compiler:frontend.common", ":compiler:frontend.common",
":compiler:frontend.java", ":compiler:frontend.java",
":compiler:cli-common", ":compiler:cli-common",
":compiler:ir.tree", ":compiler:ir.tree",
":compiler:ir.psi2ir", ":compiler:ir.psi2ir",
":compiler:ir.backend.common", ":compiler:ir.backend.common",
":compiler:backend.jvm", ":compiler:backend.jvm",
":compiler:backend.js", ":compiler:backend.js",
":compiler:ir.serialization.common", ":compiler:ir.serialization.common",
":compiler:ir.serialization.js", ":compiler:ir.serialization.js",
":compiler:backend-common", ":compiler:backend-common",
":compiler:backend", ":compiler:backend",
":compiler:plugin-api", ":compiler:plugin-api",
":compiler:light-classes", ":compiler:light-classes",
":compiler:cli", ":compiler:cli",
":compiler:cli-js", ":compiler:cli-js",
":compiler:incremental-compilation-impl", ":compiler:incremental-compilation-impl",
":js:js.ast", ":js:js.ast",
":js:js.serializer", ":js:js.serializer",
":js:js.parser", ":js:js.parser",
":js:js.frontend", ":js:js.frontend",
":js:js.translator", ":js:js.translator",
":js:js.dce", ":js:js.dce",
":compiler", ":compiler",
":kotlin-build-common", ":kotlin-build-common",
":core:metadata", ":core:metadata",
":core:metadata.jvm", ":core:metadata.jvm",
":core:descriptors", ":core:descriptors",
":core:descriptors.jvm", ":core:descriptors.jvm",
":core:deserialization", ":core:deserialization",
":core:util.runtime", ":core:util.runtime",
":core:type-system", ":core:type-system",
":compiler:fir:cones", ":compiler:fir:cones",
":compiler:fir:resolve", ":compiler:fir:resolve",
":compiler:fir:tree", ":compiler:fir:tree",
":compiler:fir:psi2fir", ":compiler:fir:psi2fir",
":compiler:fir:fir2ir" ":compiler:fir:fir2ir"
) )
val coreLibProjects = listOfNotNull( val coreLibProjects = listOfNotNull(
":kotlin-stdlib", ":kotlin-stdlib",
":kotlin-stdlib-common", ":kotlin-stdlib-common",
":kotlin-stdlib-js", ":kotlin-stdlib-js",
// Local builds are disabled at the request of the lib team // Local builds are disabled at the request of the lib team
// TODO: Enable when tests are fixed // TODO: Enable when tests are fixed
":kotlin-stdlib-js-ir".takeIf { isTeamcityBuild }, ":kotlin-stdlib-js-ir".takeIf { isTeamcityBuild },
":kotlin-stdlib-jdk7", ":kotlin-stdlib-jdk7",
":kotlin-stdlib-jdk8", ":kotlin-stdlib-jdk8",
":kotlin-test:kotlin-test-common", ":kotlin-test:kotlin-test-common",
":kotlin-test:kotlin-test-jvm", ":kotlin-test:kotlin-test-jvm",
":kotlin-test:kotlin-test-junit", ":kotlin-test:kotlin-test-junit",
":kotlin-test:kotlin-test-junit5", ":kotlin-test:kotlin-test-junit5",
":kotlin-test:kotlin-test-testng", ":kotlin-test:kotlin-test-testng",
":kotlin-test:kotlin-test-js", ":kotlin-test:kotlin-test-js",
":kotlin-reflect" ":kotlin-reflect"
) )
val gradlePluginProjects = listOf( val gradlePluginProjects = listOf(
":kotlin-gradle-plugin", ":kotlin-gradle-plugin",
":kotlin-gradle-plugin:plugin-marker", ":kotlin-gradle-plugin:plugin-marker",
":kotlin-gradle-plugin-api", ":kotlin-gradle-plugin-api",
// ":kotlin-gradle-plugin-integration-tests", // TODO: build fails // ":kotlin-gradle-plugin-integration-tests", // TODO: build fails
":kotlin-allopen", ":kotlin-allopen",
":kotlin-allopen:plugin-marker", ":kotlin-allopen:plugin-marker",
":kotlin-annotation-processing-gradle", ":kotlin-annotation-processing-gradle",
":kotlin-noarg", ":kotlin-noarg",
":kotlin-noarg:plugin-marker", ":kotlin-noarg:plugin-marker",
":kotlin-sam-with-receiver" ":kotlin-sam-with-receiver"
) )
apply { apply {
@@ -306,18 +317,13 @@ val ignoreTestFailures by extra(project.findProperty("ignoreTestFailures")?.toSt
allprojects { allprojects {
configurations.maybeCreate("embedded") configurations.maybeCreate("embedded")
jvmTarget = defaultJvmTarget
if (defaultJavaHome != null) {
javaHome = defaultJavaHome
} else {
logger.error("Could not find default java home. Please set environment variable JDK_${defaultJavaHome} to point to JDK ${defaultJavaHome} installation.")
}
jvmTarget = defaultJvmTarget
javaHome = defaultJavaHome
// There are problems with common build dir: // There are problems with common build dir:
// - some tests (in particular js and binary-compatibility-validator depend on the fixed (default) location // - some tests (in particular js and binary-compatibility-validator depend on the fixed (default) location
// - idea seems unable to exclude common builddir from indexing // - idea seems unable to exclude common buildDir from indexing
// therefore it is disabled by default // therefore it is disabled by default
// buildDir = File(commonBuildDir, project.name) // buildDir = File(commonBuildDir, project.name)
@@ -385,16 +391,20 @@ allprojects {
fun File.toProjectRootRelativePathOrSelf() = (relativeToOrNull(rootDir)?.takeUnless { it.startsWith("..") } ?: this).path fun File.toProjectRootRelativePathOrSelf() = (relativeToOrNull(rootDir)?.takeUnless { it.startsWith("..") } ?: this).path
fun FileCollection.printClassPath(role: String) = fun FileCollection.printClassPath(role: String) =
println("${project.path} $role classpath:\n ${joinToString("\n ") { it.toProjectRootRelativePathOrSelf() } }") println("${project.path} $role classpath:\n ${joinToString("\n ") { it.toProjectRootRelativePathOrSelf() }}")
try { javaPluginConvention() } catch (_: UnknownDomainObjectException) { null }?.let { javaConvention -> try {
javaPluginConvention()
} catch (_: UnknownDomainObjectException) {
null
}?.let { javaConvention ->
task("printCompileClasspath") { doFirst { javaConvention.sourceSets["main"].compileClasspath.printClassPath("compile") } } task("printCompileClasspath") { doFirst { javaConvention.sourceSets["main"].compileClasspath.printClassPath("compile") } }
task("printRuntimeClasspath") { doFirst { javaConvention.sourceSets["main"].runtimeClasspath.printClassPath("runtime") } } task("printRuntimeClasspath") { doFirst { javaConvention.sourceSets["main"].runtimeClasspath.printClassPath("runtime") } }
task("printTestCompileClasspath") { doFirst { javaConvention.sourceSets["test"].compileClasspath.printClassPath("test compile") } } task("printTestCompileClasspath") { doFirst { javaConvention.sourceSets["test"].compileClasspath.printClassPath("test compile") } }
task("printTestRuntimeClasspath") { doFirst { javaConvention.sourceSets["test"].runtimeClasspath.printClassPath("test runtime") } } task("printTestRuntimeClasspath") { doFirst { javaConvention.sourceSets["test"].runtimeClasspath.printClassPath("test runtime") } }
} }
run configureCompilerClasspath@ { run configureCompilerClasspath@{
val bootstrapCompilerClasspath by rootProject.buildscript.configurations val bootstrapCompilerClasspath by rootProject.buildscript.configurations
configurations.findByName("kotlinCompilerClasspath")?.let { configurations.findByName("kotlinCompilerClasspath")?.let {
dependencies.add(it.name, files(bootstrapCompilerClasspath)) dependencies.add(it.name, files(bootstrapCompilerClasspath))
@@ -471,18 +481,18 @@ tasks {
create("coreLibsTest") { create("coreLibsTest") {
(coreLibProjects + listOf( (coreLibProjects + listOf(
":kotlin-stdlib:samples", ":kotlin-stdlib:samples",
":kotlin-test:kotlin-test-js:kotlin-test-js-it", ":kotlin-test:kotlin-test-js:kotlin-test-js-it",
":kotlinx-metadata-jvm", ":kotlinx-metadata-jvm",
":tools:binary-compatibility-validator" ":tools:binary-compatibility-validator"
)).forEach { )).forEach {
dependsOn(it + ":check") dependsOn("$it:check")
} }
} }
create("gradlePluginTest") { create("gradlePluginTest") {
gradlePluginProjects.forEach { gradlePluginProjects.forEach {
dependsOn(it + ":check") dependsOn("$it:check")
} }
} }
@@ -492,10 +502,12 @@ tasks {
create("jvmCompilerTest") { create("jvmCompilerTest") {
dependsOn("dist") dependsOn("dist")
dependsOn(":compiler:test", dependsOn(
":compiler:container:test", ":compiler:test",
":compiler:tests-java8:test", ":compiler:container:test",
":compiler:tests-spec:remoteRunTests") ":compiler:tests-java8:test",
":compiler:tests-spec:remoteRunTests"
)
dependsOn(":plugins:jvm-abi-gen:test") dependsOn(":plugins:jvm-abi-gen:test")
} }
@@ -566,46 +578,54 @@ tasks {
create("idea-plugin-additional-tests") { create("idea-plugin-additional-tests") {
dependsOn("dist") dependsOn("dist")
dependsOn(":idea:idea-gradle:test", dependsOn(
":idea:idea-gradle-native:test", ":idea:idea-gradle:test",
":idea:idea-maven:test", ":idea:idea-gradle-native:test",
":j2k:test", ":idea:idea-maven:test",
":idea:eval4j:test") ":j2k:test",
":idea:eval4j:test"
)
} }
create("idea-plugin-tests") { create("idea-plugin-tests") {
dependsOn("dist") dependsOn("dist")
dependsOn("idea-plugin-main-tests", dependsOn(
"idea-plugin-additional-tests") "idea-plugin-main-tests",
"idea-plugin-additional-tests"
)
} }
create("android-ide-tests") { create("android-ide-tests") {
dependsOn("dist") dependsOn("dist")
dependsOn(":plugins:android-extensions-ide:test", dependsOn(
":idea:idea-android:test", ":plugins:android-extensions-ide:test",
":kotlin-annotation-processing:test") ":idea:idea-android:test",
":kotlin-annotation-processing:test"
)
} }
create("plugins-tests") { create("plugins-tests") {
dependsOn("dist") dependsOn("dist")
dependsOn(":kotlin-annotation-processing:test", dependsOn(
":kotlin-source-sections-compiler-plugin:test", ":kotlin-annotation-processing:test",
":kotlin-allopen-compiler-plugin:test", ":kotlin-source-sections-compiler-plugin:test",
":kotlin-noarg-compiler-plugin:test", ":kotlin-allopen-compiler-plugin:test",
":kotlin-sam-with-receiver-compiler-plugin:test", ":kotlin-noarg-compiler-plugin:test",
":plugins:uast-kotlin:test", ":kotlin-sam-with-receiver-compiler-plugin:test",
":kotlin-annotation-processing-gradle:test", ":plugins:uast-kotlin:test",
":kotlinx-serialization-ide-plugin:test") ":kotlin-annotation-processing-gradle:test",
":kotlinx-serialization-ide-plugin:test"
)
} }
create("ideaPluginTest") { create("ideaPluginTest") {
dependsOn( dependsOn(
"idea-plugin-tests", "idea-plugin-tests",
"jps-tests", "jps-tests",
"plugins-tests", "plugins-tests",
"android-ide-tests", "android-ide-tests",
":generators:test" ":generators:test"
) )
} }
@@ -691,11 +711,11 @@ val zipPlugin by task<Zip> {
configure<IdeaModel> { configure<IdeaModel> {
module { module {
excludeDirs = files( excludeDirs = files(
project.buildDir, project.buildDir,
commonLocalDataDir, commonLocalDataDir,
".gradle", ".gradle",
"dependencies", "dependencies",
"dist" "dist"
).toSet() ).toSet()
} }
} }
@@ -703,7 +723,7 @@ configure<IdeaModel> {
fun jdkPath(version: String): String { fun jdkPath(version: String): String {
val jdkName = "JDK_${version.replace(".", "")}" val jdkName = "JDK_${version.replace(".", "")}"
val jdkMajorVersion = JdkMajorVersion.valueOf(jdkName) val jdkMajorVersion = JdkMajorVersion.valueOf(jdkName)
return configuredJdks.find { it.majorVersion == jdkMajorVersion }?.homeDir?.canonicalPath?:jdkNotFoundConst return configuredJdks.find { it.majorVersion == jdkMajorVersion }?.homeDir?.canonicalPath ?: jdkNotFoundConst
} }