Move common configuration from /build.gradle.kts into plugin
Move all common to all projects configuration from root build.gradle.kts into common-configuration convention plugin.
This commit is contained in:
+34
-245
@@ -76,11 +76,6 @@ val kotlinVersion by extra(
|
|||||||
|
|
||||||
val kotlinLanguageVersion by extra("1.7")
|
val kotlinLanguageVersion by extra("1.7")
|
||||||
|
|
||||||
allprojects {
|
|
||||||
group = "org.jetbrains.kotlin"
|
|
||||||
version = kotlinVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
extra["kotlin_root"] = rootDir
|
extra["kotlin_root"] = rootDir
|
||||||
|
|
||||||
val jpsBootstrap by configurations.creating
|
val jpsBootstrap by configurations.creating
|
||||||
@@ -134,11 +129,6 @@ if (!project.hasProperty("versions.kotlin-native")) {
|
|||||||
extra["versions.kotlin-native"] = "1.7.20-dev-1094"
|
extra["versions.kotlin-native"] = "1.7.20-dev-1094"
|
||||||
}
|
}
|
||||||
|
|
||||||
val useJvmFir by extra(project.kotlinBuildProperties.useFir)
|
|
||||||
val useFirLT by extra(project.kotlinBuildProperties.useFirWithLightTree)
|
|
||||||
val useFirIC by extra(project.kotlinBuildProperties.useFirTightIC)
|
|
||||||
val renderDiagnosticNames by extra(project.kotlinBuildProperties.renderDiagnosticNames)
|
|
||||||
|
|
||||||
val irCompilerModules = arrayOf(
|
val irCompilerModules = arrayOf(
|
||||||
":compiler:ir.tree",
|
":compiler:ir.tree",
|
||||||
":compiler:ir.tree.impl",
|
":compiler:ir.tree.impl",
|
||||||
@@ -341,46 +331,30 @@ extra["compilerArtifactsForIde"] = listOfNotNull(
|
|||||||
":kotlin-main-kts"
|
":kotlin-main-kts"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: fix remaining warnings and remove this property.
|
val coreLibProjects by extra {
|
||||||
extra["tasksWithWarnings"] = listOf(
|
listOfNotNull(
|
||||||
":kotlin-gradle-plugin:compileKotlin",
|
":kotlin-stdlib",
|
||||||
":kotlin-gradle-plugin:compileCommonKotlin",
|
":kotlin-stdlib-common",
|
||||||
":kotlin-gradle-plugin:compileGradle70Kotlin"
|
":kotlin-stdlib-js",
|
||||||
)
|
":kotlin-stdlib-jdk7",
|
||||||
|
":kotlin-stdlib-jdk8",
|
||||||
|
":kotlin-test",
|
||||||
|
":kotlin-test:kotlin-test-annotations-common",
|
||||||
|
":kotlin-test:kotlin-test-common",
|
||||||
|
":kotlin-test:kotlin-test-jvm",
|
||||||
|
":kotlin-test:kotlin-test-junit",
|
||||||
|
":kotlin-test:kotlin-test-junit5",
|
||||||
|
":kotlin-test:kotlin-test-testng",
|
||||||
|
":kotlin-test:kotlin-test-js".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
|
||||||
|
":kotlin-reflect"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val tasksWithWarnings: List<String> by extra
|
val projectsWithEnabledContextReceivers by extra {
|
||||||
|
listOf(
|
||||||
val coreLibProjects = listOfNotNull(
|
":compiler:fir:fir2ir"
|
||||||
":kotlin-stdlib",
|
)
|
||||||
":kotlin-stdlib-common",
|
}
|
||||||
":kotlin-stdlib-js",
|
|
||||||
":kotlin-stdlib-jdk7",
|
|
||||||
":kotlin-stdlib-jdk8",
|
|
||||||
":kotlin-test",
|
|
||||||
":kotlin-test:kotlin-test-annotations-common",
|
|
||||||
":kotlin-test:kotlin-test-common",
|
|
||||||
":kotlin-test:kotlin-test-jvm",
|
|
||||||
":kotlin-test:kotlin-test-junit",
|
|
||||||
":kotlin-test:kotlin-test-junit5",
|
|
||||||
":kotlin-test:kotlin-test-testng",
|
|
||||||
":kotlin-test:kotlin-test-js".takeIf { !kotlinBuildProperties.isInJpsBuildIdeaSync },
|
|
||||||
":kotlin-reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
val projectsWithDisabledFirBootstrap = coreLibProjects + listOf(
|
|
||||||
":kotlin-gradle-plugin",
|
|
||||||
":kotlinx-metadata",
|
|
||||||
":kotlinx-metadata-jvm",
|
|
||||||
// For some reason stdlib isn't imported correctly for this module
|
|
||||||
// Probably it's related to kotlin-test module usage
|
|
||||||
":kotlin-gradle-statistics",
|
|
||||||
// Requires serialization plugin
|
|
||||||
":wasm:wasm.ir"
|
|
||||||
)
|
|
||||||
|
|
||||||
val projectsWithEnabledContextReceivers = listOf(
|
|
||||||
":compiler:fir:fir2ir"
|
|
||||||
)
|
|
||||||
|
|
||||||
val gradlePluginProjects = listOf(
|
val gradlePluginProjects = listOf(
|
||||||
":kotlin-gradle-plugin",
|
":kotlin-gradle-plugin",
|
||||||
@@ -395,29 +369,12 @@ val gradlePluginProjects = listOf(
|
|||||||
":kotlin-lombok"
|
":kotlin-lombok"
|
||||||
)
|
)
|
||||||
|
|
||||||
apply {
|
|
||||||
from("libraries/commonConfiguration.gradle")
|
|
||||||
}
|
|
||||||
|
|
||||||
apply {
|
|
||||||
if (extra["isDeployStagingRepoGenerationRequired"] as? Boolean == true) {
|
|
||||||
logger.info("Applying configuration for sonatype release")
|
|
||||||
from("libraries/prepareSonatypeStaging.gradle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Task.listConfigurationContents(configName: String) {
|
|
||||||
doFirst {
|
|
||||||
project.configurations.findByName(configName)?.let {
|
|
||||||
println("$configName configuration files:\n${it.allArtifacts.files.files.joinToString("\n ", " ")}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
|
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
pluginManager.apply("common-configuration")
|
if (!project.path.startsWith(":kotlin-ide.")) {
|
||||||
|
pluginManager.apply("common-configuration")
|
||||||
|
}
|
||||||
val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString()
|
val mirrorRepo: String? = findProperty("maven.repository.mirror")?.toString()
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -463,183 +420,15 @@ allprojects {
|
|||||||
|
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (path.startsWith(":kotlin-ide.")) {
|
apply {
|
||||||
return@allprojects
|
from("libraries/commonConfiguration.gradle")
|
||||||
}
|
if (extra.has("isDeployStagingRepoGenerationRequired") &&
|
||||||
|
project.extra["isDeployStagingRepoGenerationRequired"] as Boolean == true
|
||||||
configurations.maybeCreate("embedded").apply {
|
) {
|
||||||
isCanBeConsumed = false
|
logger.info("Applying configuration for sonatype release")
|
||||||
isCanBeResolved = true
|
from("libraries/prepareSonatypeStaging.gradle")
|
||||||
attributes {
|
|
||||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
|
||||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations.maybeCreate("embeddedElements").apply {
|
|
||||||
extendsFrom(configurations["embedded"])
|
|
||||||
isCanBeConsumed = true
|
|
||||||
isCanBeResolved = false
|
|
||||||
attributes {
|
|
||||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There are problems with common build dir:
|
|
||||||
// - some tests (in particular js and binary-compatibility-validator depend on the fixed (default) location
|
|
||||||
// - idea seems unable to exclude common buildDir from indexing
|
|
||||||
// therefore it is disabled by default
|
|
||||||
// buildDir = File(commonBuildDir, project.name)
|
|
||||||
|
|
||||||
project.configureJvmDefaultToolchain()
|
|
||||||
plugins.withId("java-base") {
|
|
||||||
project.configureShadowJarSubstitutionInCompileClasspath()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<JavaCompile> {
|
|
||||||
options.compilerArgs.add("-Xlint:deprecation")
|
|
||||||
options.compilerArgs.add("-Xlint:unchecked")
|
|
||||||
options.compilerArgs.add("-Werror")
|
|
||||||
}
|
|
||||||
|
|
||||||
val commonCompilerArgs = listOfNotNull(
|
|
||||||
"-opt-in=kotlin.RequiresOptIn",
|
|
||||||
"-progressive".takeIf { hasProperty("test.progressive.mode") }
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
|
||||||
kotlinOptions {
|
|
||||||
languageVersion = kotlinLanguageVersion
|
|
||||||
apiVersion = kotlinLanguageVersion
|
|
||||||
freeCompilerArgs = commonCompilerArgs
|
|
||||||
}
|
|
||||||
|
|
||||||
val relativePathBaseArg: String? =
|
|
||||||
"-Xklib-relative-path-base=$buildDir,$projectDir,$rootDir".takeIf {
|
|
||||||
!kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib")
|
|
||||||
}
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
if (relativePathBaseArg != null) {
|
|
||||||
kotlinOptions.freeCompilerArgs += relativePathBaseArg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val jvmCompilerArgs = listOf(
|
|
||||||
"-Xno-optimized-callable-references",
|
|
||||||
"-Xno-kotlin-nothing-value-exception",
|
|
||||||
"-Xsuppress-deprecated-jvm-target-warning" // Remove as soon as there are no modules for JDK 1.6 & 1.7
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {
|
|
||||||
kotlinOptions {
|
|
||||||
freeCompilerArgs = commonCompilerArgs + jvmCompilerArgs
|
|
||||||
|
|
||||||
val moduleName = this@allprojects.path
|
|
||||||
if (useJvmFir && moduleName !in projectsWithDisabledFirBootstrap) {
|
|
||||||
freeCompilerArgs += "-Xuse-fir"
|
|
||||||
freeCompilerArgs += "-Xabi-stability=stable"
|
|
||||||
if (useFirLT) {
|
|
||||||
freeCompilerArgs += "-Xuse-fir-lt"
|
|
||||||
}
|
|
||||||
if (useFirIC) {
|
|
||||||
freeCompilerArgs += "-Xuse-fir-ic"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (renderDiagnosticNames) {
|
|
||||||
freeCompilerArgs += "-Xrender-internal-diagnostic-names"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moduleName in projectsWithEnabledContextReceivers) {
|
|
||||||
freeCompilerArgs += "-Xcontext-receivers"
|
|
||||||
freeCompilerArgs += "-Xdont-poison-binaries-with-prerelease"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!kotlinBuildProperties.disableWerror) {
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {
|
|
||||||
if (path !in tasksWithWarnings) {
|
|
||||||
kotlinOptions {
|
|
||||||
allWarningsAsErrors = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(VerificationTask::class.java as Class<Task>) {
|
|
||||||
(this as VerificationTask).ignoreFailures = ignoreTestFailures
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Javadoc> {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Jar> {
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<AbstractArchiveTask> {
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test> {
|
|
||||||
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { true }
|
|
||||||
}
|
|
||||||
|
|
||||||
normalization {
|
|
||||||
runtimeClasspath {
|
|
||||||
ignore("META-INF/MANIFEST.MF")
|
|
||||||
ignore("META-INF/compiler.version")
|
|
||||||
ignore("META-INF/plugin.xml")
|
|
||||||
ignore("kotlin/KotlinVersionCurrentValue.class")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
register("listArchives") { listConfigurationContents("archives") }
|
|
||||||
|
|
||||||
register("listDistJar") { listConfigurationContents("distJar") }
|
|
||||||
|
|
||||||
// Aggregate task for build related checks
|
|
||||||
register("checkBuild")
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(from = "$rootDir/gradle/cacheRedirector.gradle.kts")
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
fun File.toProjectRootRelativePathOrSelf() = (relativeToOrNull(rootDir)?.takeUnless { it.startsWith("..") } ?: this).path
|
|
||||||
|
|
||||||
fun FileCollection.printClassPath(role: String) =
|
|
||||||
println("${project.path} $role classpath:\n ${joinToString("\n ") { it.toProjectRootRelativePathOrSelf() }}")
|
|
||||||
|
|
||||||
try {
|
|
||||||
javaPluginExtension()
|
|
||||||
} catch (_: UnknownDomainObjectException) {
|
|
||||||
null
|
|
||||||
}?.let { javaExtension ->
|
|
||||||
tasks {
|
|
||||||
register("printCompileClasspath") { doFirst { javaExtension.sourceSets["main"].compileClasspath.printClassPath("compile") } }
|
|
||||||
register("printRuntimeClasspath") { doFirst { javaExtension.sourceSets["main"].runtimeClasspath.printClassPath("runtime") } }
|
|
||||||
register("printTestCompileClasspath") { doFirst { javaExtension.sourceSets["test"].compileClasspath.printClassPath("test compile") } }
|
|
||||||
register("printTestRuntimeClasspath") { doFirst { javaExtension.sourceSets["test"].runtimeClasspath.printClassPath("test runtime") } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run configureCompilerClasspath@{
|
|
||||||
val bootstrapCompilerClasspath by rootProject.buildscript.configurations
|
|
||||||
configurations.findByName("kotlinCompilerClasspath")?.let {
|
|
||||||
dependencies.add(it.name, files(bootstrapCompilerClasspath))
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations.findByName("kotlinCompilerPluginClasspath")
|
|
||||||
?.exclude("org.jetbrains.kotlin", "kotlin-scripting-compiler-embeddable")
|
|
||||||
}
|
|
||||||
|
|
||||||
apply(from = "$rootDir/gradle/testRetry.gradle.kts")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import gradle.kotlin.dsl.accessors._6fcc03dc3ac2d481a1d2799d95ed6983.implementation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper
|
||||||
import org.gradle.kotlin.dsl.dependencies
|
|
||||||
|
|
||||||
// Contains common configuration that should be applied to all projects
|
// Contains common configuration that should be applied to all projects
|
||||||
|
|
||||||
|
// Common Group and version
|
||||||
|
val kotlinVersion: String by rootProject.extra
|
||||||
|
group = "org.jetbrains.kotlin"
|
||||||
|
version = kotlinVersion
|
||||||
|
|
||||||
// Forcing minimal gson dependency version
|
// Forcing minimal gson dependency version
|
||||||
val gsonVersion = rootProject.extra["versions.gson"] as String
|
val gsonVersion = rootProject.extra["versions.gson"] as String
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -17,3 +21,225 @@ dependencies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply(from = "$rootDir/gradle/cacheRedirector.gradle.kts")
|
||||||
|
project.configureJvmDefaultToolchain()
|
||||||
|
project.addEmbeddedConfigurations()
|
||||||
|
project.configureJavaCompile()
|
||||||
|
project.configureJavaBasePlugin()
|
||||||
|
project.configureKotlinCompilationOptions()
|
||||||
|
project.configureArtifacts()
|
||||||
|
project.configureTests()
|
||||||
|
|
||||||
|
// There are problems with common build dir:
|
||||||
|
// - some tests (in particular js and binary-compatibility-validator depend on the fixed (default) location
|
||||||
|
// - idea seems unable to exclude common buildDir from indexing
|
||||||
|
// therefore it is disabled by default
|
||||||
|
// buildDir = File(commonBuildDir, project.name)
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
run configureCompilerClasspath@{
|
||||||
|
val bootstrapCompilerClasspath by rootProject.buildscript.configurations
|
||||||
|
configurations.findByName("kotlinCompilerClasspath")?.let {
|
||||||
|
dependencies.add(it.name, files(bootstrapCompilerClasspath))
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.findByName("kotlinCompilerPluginClasspath")
|
||||||
|
?.exclude("org.jetbrains.kotlin", "kotlin-scripting-compiler-embeddable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.addEmbeddedConfigurations() {
|
||||||
|
configurations.maybeCreate("embedded").apply {
|
||||||
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.maybeCreate("embeddedElements").apply {
|
||||||
|
extendsFrom(configurations["embedded"])
|
||||||
|
isCanBeConsumed = true
|
||||||
|
isCanBeResolved = false
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.configureJavaCompile() {
|
||||||
|
plugins.withType<JavaPlugin> {
|
||||||
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
|
options.compilerArgs.add("-Xlint:deprecation")
|
||||||
|
options.compilerArgs.add("-Xlint:unchecked")
|
||||||
|
options.compilerArgs.add("-Werror")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.configureJavaBasePlugin() {
|
||||||
|
plugins.withId("java-base") {
|
||||||
|
project.configureShadowJarSubstitutionInCompileClasspath()
|
||||||
|
|
||||||
|
fun File.toProjectRootRelativePathOrSelf() = (relativeToOrNull(rootDir)?.takeUnless { it.startsWith("..") } ?: this).path
|
||||||
|
|
||||||
|
fun FileCollection.printClassPath(role: String) =
|
||||||
|
println("${project.path} $role classpath:\n ${joinToString("\n ") { it.toProjectRootRelativePathOrSelf() }}")
|
||||||
|
|
||||||
|
val javaExtension = javaPluginExtension()
|
||||||
|
tasks {
|
||||||
|
register("printCompileClasspath") { doFirst { javaExtension.sourceSets["main"].compileClasspath.printClassPath("compile") } }
|
||||||
|
register("printRuntimeClasspath") { doFirst { javaExtension.sourceSets["main"].runtimeClasspath.printClassPath("runtime") } }
|
||||||
|
register("printTestCompileClasspath") { doFirst { javaExtension.sourceSets["test"].compileClasspath.printClassPath("test compile") } }
|
||||||
|
register("printTestRuntimeClasspath") { doFirst { javaExtension.sourceSets["test"].runtimeClasspath.printClassPath("test runtime") } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.configureKotlinCompilationOptions() {
|
||||||
|
plugins.withType<KotlinBasePluginWrapper>() {
|
||||||
|
val commonCompilerArgs = listOfNotNull(
|
||||||
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
|
"-progressive".takeIf { hasProperty("test.progressive.mode") }
|
||||||
|
)
|
||||||
|
|
||||||
|
val kotlinLanguageVersion: String by rootProject.extra
|
||||||
|
val useJvmFir by extra(project.kotlinBuildProperties.useFir)
|
||||||
|
val useFirLT by extra(project.kotlinBuildProperties.useFirWithLightTree)
|
||||||
|
val useFirIC by extra(project.kotlinBuildProperties.useFirTightIC)
|
||||||
|
val renderDiagnosticNames by extra(project.kotlinBuildProperties.renderDiagnosticNames)
|
||||||
|
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
languageVersion = kotlinLanguageVersion
|
||||||
|
apiVersion = kotlinLanguageVersion
|
||||||
|
freeCompilerArgs += commonCompilerArgs
|
||||||
|
}
|
||||||
|
|
||||||
|
val relativePathBaseArg: String? =
|
||||||
|
"-Xklib-relative-path-base=$buildDir,$projectDir,$rootDir".takeIf {
|
||||||
|
!kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib")
|
||||||
|
}
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
if (relativePathBaseArg != null) {
|
||||||
|
kotlinOptions.freeCompilerArgs += relativePathBaseArg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val jvmCompilerArgs = listOf(
|
||||||
|
"-Xno-optimized-callable-references",
|
||||||
|
"-Xno-kotlin-nothing-value-exception",
|
||||||
|
"-Xsuppress-deprecated-jvm-target-warning" // Remove as soon as there are no modules for JDK 1.6 & 1.7
|
||||||
|
)
|
||||||
|
|
||||||
|
val coreLibProjects: List<String> by rootProject.extra
|
||||||
|
val projectsWithDisabledFirBootstrap = coreLibProjects + listOf(
|
||||||
|
":kotlin-gradle-plugin",
|
||||||
|
":kotlinx-metadata",
|
||||||
|
":kotlinx-metadata-jvm",
|
||||||
|
// For some reason stdlib isn't imported correctly for this module
|
||||||
|
// Probably it's related to kotlin-test module usage
|
||||||
|
":kotlin-gradle-statistics",
|
||||||
|
// Requires serialization plugin
|
||||||
|
":wasm:wasm.ir"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO: fix remaining warnings and remove this property.
|
||||||
|
val tasksWithWarnings = listOf(
|
||||||
|
":kotlin-gradle-plugin:compileKotlin",
|
||||||
|
":kotlin-gradle-plugin:compileCommonKotlin",
|
||||||
|
":kotlin-gradle-plugin:compileGradle70Kotlin"
|
||||||
|
)
|
||||||
|
|
||||||
|
val projectsWithEnabledContextReceivers: List<String> by rootProject.extra
|
||||||
|
|
||||||
|
@Suppress("SuspiciousCollectionReassignment", "DEPRECATION")
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += jvmCompilerArgs
|
||||||
|
|
||||||
|
if (useJvmFir && project.path !in projectsWithDisabledFirBootstrap) {
|
||||||
|
freeCompilerArgs += "-Xuse-fir"
|
||||||
|
freeCompilerArgs += "-Xabi-stability=stable"
|
||||||
|
if (useFirLT) {
|
||||||
|
freeCompilerArgs += "-Xuse-fir-lt"
|
||||||
|
}
|
||||||
|
if (useFirIC) {
|
||||||
|
freeCompilerArgs += "-Xuse-fir-ic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (renderDiagnosticNames) {
|
||||||
|
freeCompilerArgs += "-Xrender-internal-diagnostic-names"
|
||||||
|
}
|
||||||
|
if (path !in tasksWithWarnings) {
|
||||||
|
allWarningsAsErrors = !kotlinBuildProperties.disableWerror
|
||||||
|
}
|
||||||
|
if (project.path in projectsWithEnabledContextReceivers) {
|
||||||
|
freeCompilerArgs += listOf(
|
||||||
|
"-Xcontext-receivers",
|
||||||
|
"-Xdont-poison-binaries-with-prerelease"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.configureArtifacts() {
|
||||||
|
tasks.withType<Javadoc>().configureEach {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Jar>().configureEach {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
}
|
||||||
|
|
||||||
|
normalization {
|
||||||
|
runtimeClasspath {
|
||||||
|
ignore("META-INF/MANIFEST.MF")
|
||||||
|
ignore("META-INF/compiler.version")
|
||||||
|
ignore("META-INF/plugin.xml")
|
||||||
|
ignore("kotlin/KotlinVersionCurrentValue.class")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Task.listConfigurationContents(configName: String) {
|
||||||
|
doFirst {
|
||||||
|
project.configurations.findByName(configName)?.let {
|
||||||
|
println("$configName configuration files:\n${it.allArtifacts.files.files.joinToString("\n ", " ")}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("listArchives") { listConfigurationContents("archives") }
|
||||||
|
tasks.register("listDistJar") { listConfigurationContents("distJar") }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.configureTests() {
|
||||||
|
val ignoreTestFailures: Boolean by rootProject.extra
|
||||||
|
tasks.configureEach {
|
||||||
|
if (this is VerificationTask) {
|
||||||
|
ignoreFailures = ignoreTestFailures
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>().configureEach {
|
||||||
|
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { true }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate task for build related checks
|
||||||
|
tasks.register("checkBuild")
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
apply(from = "$rootDir/gradle/testRetry.gradle.kts")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ val projectsAllowedToUseFirFromSymbol = listOf(
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
if (name in projectsAllowedToUseFirFromSymbol) {
|
if (name in projectsAllowedToUseFirFromSymbol) {
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs += "-opt-in=org.jetbrains.kotlin.fir.symbols.SymbolInternals"
|
freeCompilerArgs += "-opt-in=org.jetbrains.kotlin.fir.symbols.SymbolInternals"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) {
|
|||||||
systemProperties["line.separator"] = "\n"
|
systemProperties["line.separator"] = "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
val compileKotlin by tasks
|
tasks.named("compileKotlin") {
|
||||||
|
dependsOn(generateTree)
|
||||||
compileKotlin.dependsOn(generateTree)
|
}
|
||||||
|
|
||||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||||
apply(plugin = "idea")
|
apply(plugin = "idea")
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
id("jps-compatible")
|
id("jps-compatible")
|
||||||
@@ -13,10 +15,12 @@ dependencies {
|
|||||||
testImplementation(kotlin("test-junit"))
|
testImplementation(kotlin("test-junit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin.target.compilations.all {
|
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||||
kotlinOptions.languageVersion = "1.4"
|
kotlinOptions {
|
||||||
kotlinOptions.apiVersion = "1.4"
|
languageVersion = "1.4"
|
||||||
kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check", "-Xsuppress-version-warnings")
|
apiVersion = "1.4"
|
||||||
|
freeCompilerArgs += listOf("-Xskip-prerelease-check", "-Xsuppress-version-warnings")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Jar>("jar") {
|
tasks.named<Jar>("jar") {
|
||||||
|
|||||||
Reference in New Issue
Block a user