mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Exclude modules where there are still warnings in an explicitly declared variable `tasksWithWarnings`. Also remove "-progressive" from compiler arguments in modules which are built with non-latest language version, as the warning about that leads to an error with -Werror.
242 lines
8.3 KiB
Groovy
242 lines
8.3 KiB
Groovy
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
ext.configureJavaOnlyJvm6Project = { Project project ->
|
|
project.tasks.withType(JavaCompile) {
|
|
sourceCompatibility = 1.6
|
|
targetCompatibility = 1.6
|
|
options.fork = true
|
|
options.forkOptions.javaHome = file(JDK_16)
|
|
}
|
|
}
|
|
|
|
List<String> tasksWithWarnings = (List<String>) rootProject.ext.get("tasksWithWarnings")
|
|
|
|
ext.configureJvm6Project = { Project project ->
|
|
project.configure(project) {
|
|
configurations {
|
|
sources
|
|
}
|
|
|
|
project.ext.jvmTarget = "1.6"
|
|
project.ext.javaHome = JDK_16
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.kotlin
|
|
}
|
|
|
|
configureJavaOnlyJvm6Project(project)
|
|
|
|
tasks.withType(project.compileKotlin.class) {
|
|
kotlinOptions.jdkHome = JDK_16
|
|
kotlinOptions.jvmTarget = "1.6"
|
|
}
|
|
|
|
test {
|
|
executable = "$JDK_16/bin/java"
|
|
}
|
|
}
|
|
|
|
project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile.class) { task ->
|
|
if (!tasksWithWarnings.contains(task.path)) {
|
|
task.kotlinOptions {
|
|
allWarningsAsErrors = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.compileJava9Sources = { Project project, String moduleName, Collection<FileCollection> moduleOutputs = [project.sourceSets.main.output] ->
|
|
// module-info.java should be in java9 source set by convention
|
|
SourceDirectorySet java9SourceSet = project.sourceSets.java9.java
|
|
project.configurations.java9CompileClasspath.extendsFrom(project.configurations.compileClasspath)
|
|
project.tasks.getByName("compileJava9Java").configure { JavaCompile it ->
|
|
dependsOn(moduleOutputs)
|
|
it.sourceCompatibility = 1.9
|
|
it.targetCompatibility = 1.9
|
|
it.destinationDir = file("${java9SourceSet.outputDir}/META-INF/versions/9")
|
|
it.options.fork = true
|
|
it.options.forkOptions.javaHome = file(JDK_9)
|
|
it.options.sourcepath = files(java9SourceSet.srcDirs)
|
|
|
|
doFirst {
|
|
def moduleFiles = files(*moduleOutputs)
|
|
def modulePath = project.configurations.java9CompileClasspath.filter { !(it in moduleFiles.files) }
|
|
|
|
options.compilerArgs = [
|
|
'--module-path', modulePath.asPath,
|
|
'--patch-module', "$moduleName=${moduleFiles.asPath}",
|
|
'-Xlint:-requires-transitive-automatic' // suppress automatic module transitive dependencies in kotlin.test
|
|
]
|
|
|
|
classpath = files()
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.manifestAttributes = { Manifest manifest, Project project, String component = null, boolean multiRelease = false ->
|
|
project.configure(manifest) {
|
|
attributes \
|
|
'Implementation-Vendor': 'JetBrains',
|
|
'Implementation-Title': project.archivesBaseName,
|
|
'Implementation-Version': project.buildNumber
|
|
|
|
if (component != null) {
|
|
attributes \
|
|
'Kotlin-Runtime-Component': component,
|
|
'Kotlin-Version': project.kotlinLanguageVersion
|
|
}
|
|
if (multiRelease) {
|
|
attributes \
|
|
'Multi-Release': 'true'
|
|
}
|
|
}
|
|
}
|
|
|
|
task preparePublication {
|
|
def properties = project.properties
|
|
assert project.version != 'unspecified'
|
|
|
|
Map<String, String> repositoryProviders = ['sonatype-nexus-staging' : 'sonatype', 'sonatype-nexus-snapshots' : 'sonatype']
|
|
project.ext.isRelease = !project.version.toString().contains('-SNAPSHOT')
|
|
|
|
String repo = properties["deployRepo"] ?: properties['deploy-repo']
|
|
String repoProvider = repositoryProviders.get(repo, repo)
|
|
project.ext.isSonatypePublish = repoProvider == 'sonatype'
|
|
project.ext.isSonatypeRelease = isSonatypePublish && isRelease
|
|
|
|
project.ext['signing.keyId'] = project.properties['kotlin.key.name']
|
|
project.ext['signing.password'] = project.properties['kotlin.key.passphrase']
|
|
|
|
String sonatypeSnapshotsUrl = (isSonatypePublish && !isRelease) ? "https://oss.sonatype.org/content/repositories/snapshots/" : null
|
|
|
|
ext.repoUrl = properties["deployRepoUrl"] ?: sonatypeSnapshotsUrl ?: properties["deploy-url"] ?: "file://${rootProject.buildDir}/repo".toString()
|
|
ext.username = properties["deployRepoUsername"] ?: properties["kotlin.${repoProvider}.user"]
|
|
ext.password = properties["deployRepoPassword"] ?: properties["kotlin.${repoProvider}.password"]
|
|
|
|
logger.info("Deployment repository preliminary url: $repoUrl ($repoProvider)")
|
|
|
|
doLast {
|
|
println("Deployment repository url: $repoUrl")
|
|
}
|
|
}
|
|
|
|
ext.signPom = { Project project, MavenDeployer deployer ->
|
|
deployer.beforeDeployment { MavenDeployment deployment ->
|
|
if (project.signing.required)
|
|
project.signing.signPom(deployment)
|
|
}
|
|
}
|
|
|
|
ext.configurePublishing = { Project project, configure = { } ->
|
|
ArtifactsKt.publish(project, false) { publication ->
|
|
configure.delegate = publication
|
|
configure()
|
|
}
|
|
}
|
|
|
|
ext.configurePluginMarkers = { Project project, withEmptyJars = true ->
|
|
PluginMarkersKt.publishPluginMarkers(project, withEmptyJars)
|
|
}
|
|
|
|
ext.configureLegacyPublishing = { Project project ->
|
|
project.configure(project) {
|
|
apply plugin: 'maven'
|
|
|
|
if (!project.hasProperty('prebuiltJar')) {
|
|
apply plugin: 'signing'
|
|
|
|
signing {
|
|
required { (project.properties["signingRequired"] ?: project.isSonatypeRelease) }
|
|
sign configurations.archives
|
|
useGpgCmd()
|
|
}
|
|
|
|
signArchives {
|
|
enabled signing.required
|
|
}
|
|
}
|
|
|
|
uploadArchives {
|
|
def prepareTask = rootProject.preparePublication
|
|
dependsOn prepareTask
|
|
|
|
doFirst {
|
|
repositories.mavenDeployer.repository.url = prepareTask.repoUrl
|
|
}
|
|
|
|
repositories {
|
|
mavenDeployer {
|
|
signPom(project, it)
|
|
|
|
repository(url: prepareTask.repoUrl) {
|
|
authentication(userName: prepareTask.username, password: prepareTask.password)
|
|
}
|
|
pom.project {
|
|
name "${project.group}:${project.name}"
|
|
packaging 'jar'
|
|
// optionally artifactId can be defined here
|
|
description project.description
|
|
url 'https://kotlinlang.org/'
|
|
licenses {
|
|
license {
|
|
name 'The Apache License, Version 2.0'
|
|
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
}
|
|
}
|
|
scm {
|
|
url 'https://github.com/JetBrains/kotlin'
|
|
connection 'scm:git:https://github.com/JetBrains/kotlin.git'
|
|
developerConnection 'scm:git:https://github.com/JetBrains/kotlin.git'
|
|
}
|
|
developers {
|
|
developer {
|
|
name 'Kotlin Team'
|
|
organization = 'JetBrains'
|
|
organizationUrl 'https://www.jetbrains.com'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task publish(dependsOn: uploadArchives)
|
|
}
|
|
}
|
|
|
|
ext.configureJvmIrBackend = { Project project ->
|
|
project.tasks.withType(KotlinCompile.class) { task ->
|
|
task.kotlinOptions {
|
|
useIR = project.kotlinBuildProperties.useIRForLibraries
|
|
}
|
|
}
|
|
}
|
|
|
|
allprojects { project ->
|
|
project.ext.configureSourcesJar = { lambda = {} ->
|
|
ArtifactsKt.sourcesJar(project) { task ->
|
|
lambda.delegate = task
|
|
lambda()
|
|
}
|
|
}
|
|
|
|
project.ext.configureJavadocJar = { lambda = {} ->
|
|
ArtifactsKt.javadocJar(project) { task ->
|
|
lambda.delegate = task
|
|
lambda()
|
|
}
|
|
}
|
|
|
|
project.ext.configureModularJar = { lambda = {} ->
|
|
ArtifactsKt.modularJar(project) { task ->
|
|
lambda.delegate = task
|
|
lambda()
|
|
}
|
|
}
|
|
|
|
dependencies.ext.kotlinStdlib = { suffix ->
|
|
DependenciesKt.kotlinStdlib(project, suffix, null)
|
|
}
|
|
}
|