187 lines
5.9 KiB
Groovy
187 lines
5.9 KiB
Groovy
buildscript {
|
|
ext.kotlin_version = project.properties["deployVersion"] ?: "1.1-SNAPSHOT"
|
|
ext.kotlin_language_version = "1.1"
|
|
ext.kotlin_gradle_plugin_version = "1.1.1"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_gradle_plugin_version}"
|
|
}
|
|
}
|
|
|
|
ext.JDK_16 = System.getenv("JDK_16")
|
|
ext.JDK_17 = System.getenv("JDK_17")
|
|
ext.JDK_18 = System.getenv("JDK_18")
|
|
ext.distDir = project.file("${rootDir}/../dist/kotlinc/lib")
|
|
ext.bootstrapCompilerFile = project.file("${rootDir}/../dist/kotlin-compiler-for-maven.jar")
|
|
|
|
allprojects {
|
|
group = 'org.jetbrains.kotlin'
|
|
version = "$kotlin_version"
|
|
}
|
|
|
|
subprojects {
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
configurations {
|
|
scriptCompile
|
|
scriptRuntime.extendsFrom(scriptCompile)
|
|
}
|
|
|
|
dependencies {
|
|
scriptCompile "org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlin_gradle_plugin_version}"
|
|
}
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile) {
|
|
compilerJarFile = bootstrapCompilerFile
|
|
}
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = 'javadoc'
|
|
}
|
|
|
|
}
|
|
|
|
task clean {
|
|
doLast {
|
|
delete "${buildDir}/repo"
|
|
}
|
|
}
|
|
|
|
static def configureJvmProject(Project project) {
|
|
project.configure(project) {
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.kotlin
|
|
}
|
|
|
|
tasks.withType(JavaCompile) {
|
|
sourceCompatibility = 1.6
|
|
targetCompatibility = 1.6
|
|
options.fork = true
|
|
options.forkOptions.executable = "${JDK_16}/bin/javac"
|
|
}
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
|
kotlinOptions.jdkHome = JDK_16
|
|
}
|
|
|
|
test {
|
|
executable = "$JDK_16/bin/java"
|
|
}
|
|
}
|
|
}
|
|
|
|
static def manifestAttributes(Manifest manifest, Project project, String component = null) {
|
|
project.configure(manifest) {
|
|
attributes \
|
|
'Implementation-Vendor': 'JetBrains',
|
|
'Implementation-Title': project.archivesBaseName,
|
|
'Implementation-Version': project.version,
|
|
'Build-Jdk': System.getProperty('java.version')
|
|
|
|
if (component != null) {
|
|
attributes \
|
|
'Kotlin-Runtime-Component': component,
|
|
'Kotlin-Version': project.kotlin_language_version
|
|
}
|
|
}
|
|
}
|
|
|
|
static def configurePublishing(Project project) {
|
|
project.configure(project) {
|
|
apply plugin: 'maven'
|
|
apply plugin: 'signing'
|
|
|
|
signing {
|
|
required { (project.properties["signingRequired"] ?: false) }
|
|
sign configurations.archives
|
|
}
|
|
|
|
signArchives {
|
|
enabled signing.required
|
|
}
|
|
|
|
task dist(type: Copy, dependsOn: assemble) {
|
|
rename "-${java.util.regex.Pattern.quote(version)}", ''
|
|
// rename { String fileName -> 'gradle-' + fileName }
|
|
into distDir
|
|
}
|
|
|
|
uploadArchives {
|
|
repositories {
|
|
mavenDeployer {
|
|
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
|
repository(url: project.properties["deployRepoUrl"] ?: "file://${rootProject.buildDir}/repo") {
|
|
authentication(
|
|
userName: project.properties["deployRepoUsername"],
|
|
password: project.properties["deployRepoPassword"]
|
|
)
|
|
}
|
|
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)
|
|
}
|
|
|
|
}
|
|
|
|
def createPreprocessorTask(Project project, def name, def sourceDir, def targetDir, def profile = "JS") {
|
|
return project.tasks.create("preprocessSources$name", JavaExec) {
|
|
inputs.dir(sourceDir)
|
|
outputs.dir(targetDir)
|
|
classpath = project.files(bootstrapCompilerFile)
|
|
main = "org.jetbrains.kotlin.preprocessor.PreprocessorCLI"
|
|
args = [sourceDir, targetDir, profile]
|
|
}
|
|
}
|
|
|
|
static def createScriptTask(Project project, def name, Closure<JavaExec> configureClosure = null) {
|
|
JavaExec task = project.tasks.create(name, JavaExec)
|
|
return project.configure(task) {
|
|
classpath = project.configurations.scriptCompile
|
|
main = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
|
|
args = [
|
|
"-script",
|
|
"-version",
|
|
"-no-stdlib",
|
|
"-cp", project.configurations.scriptRuntime.asPath]
|
|
|
|
if (configureClosure != null) {
|
|
configureClosure.delegate = it
|
|
configureClosure.call()
|
|
}
|
|
}
|
|
}
|