Convert kotlin-gradle-plugin build script: step 2

This commit is contained in:
Alexey Tsvetkov
2018-10-30 02:29:49 +03:00
parent 911f54ed0b
commit 5a3a2df272
3 changed files with 133 additions and 130 deletions
+1
View File
@@ -31,6 +31,7 @@ buildscript {
classpath("com.gradle.publish:plugin-publish-plugin:0.9.7") classpath("com.gradle.publish:plugin-publish-plugin:0.9.7")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion)) classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath("net.sf.proguard:proguard-gradle:5.3.3") classpath("net.sf.proguard:proguard-gradle:5.3.3")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.13")
} }
} }
+1
View File
@@ -31,6 +31,7 @@ buildscript {
classpath("com.gradle.publish:plugin-publish-plugin:0.9.7") classpath("com.gradle.publish:plugin-publish-plugin:0.9.7")
classpath(kotlin("gradle-plugin", bootstrapKotlinVersion)) classpath(kotlin("gradle-plugin", bootstrapKotlinVersion))
classpath("net.sf.proguard:proguard-gradle:5.3.3") classpath("net.sf.proguard:proguard-gradle:5.3.3")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.13")
} }
} }
@@ -1,161 +1,162 @@
apply plugin: 'java' import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
apply plugin: 'java-gradle-plugin' import com.gradle.publish.PluginConfig
apply plugin: 'kotlin' import org.jetbrains.dokka.gradle.DokkaTask
apply plugin: 'org.jetbrains.dokka' import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
apply plugin: 'jps-compatible' import org.jetbrains.kotlin.pill.PillExtension
buildscript { plugins {
repositories { java
jcenter() kotlin("jvm")
} `java-gradle-plugin`
dependencies { id("org.jetbrains.dokka")
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:0.9.13' id("jps-compatible")
}
} }
configureJvmProject(project) // todo: make lazy
configurePublishing(project) val jar: Jar by tasks
runtimeJar(rewriteDepsToShadedCompiler(jar))
sourcesJar()
javadocJar()
publish()
repositories { repositories {
jcenter() google()
mavenLocal()
maven { url 'https://maven.google.com' }
} }
configurations { val agp25CompileOnly by configurations.creating
agp25CompileOnly
}
pill { pill {
variant = "FULL" variant = PillExtension.Variant.FULL
} }
dependencies { dependencies {
compile project(':kotlin-gradle-plugin-api') compile(project(":kotlin-gradle-plugin-api"))
compile project(':kotlin-gradle-plugin-model') compile(project(":kotlin-gradle-plugin-model"))
compileOnly project(':compiler') compileOnly(project(":compiler"))
compileOnly project(':compiler:incremental-compilation-impl') compileOnly(project(":compiler:incremental-compilation-impl"))
compileOnly project(':compiler:daemon-common') compileOnly(project(":compiler:daemon-common"))
compile project(':kotlin-stdlib') compile(project(":kotlin-stdlib"))
compile project(':kotlin-native:kotlin-native-utils') compile(project(":kotlin-native:kotlin-native-utils"))
compileOnly project(':kotlin-reflect-api') compileOnly(project(":kotlin-reflect-api"))
compileOnly project(':kotlin-android-extensions') compileOnly(project(":kotlin-android-extensions"))
compileOnly project(':kotlin-build-common') compileOnly(project(":kotlin-build-common"))
compileOnly project(':kotlin-compiler-runner') compileOnly(project(":kotlin-compiler-runner"))
compileOnly project(':kotlin-annotation-processing') compileOnly(project(":kotlin-annotation-processing"))
compileOnly project(':kotlin-annotation-processing-gradle') compileOnly(project(":kotlin-annotation-processing-gradle"))
compileOnly project(':kotlin-scripting-compiler') compileOnly(project(":kotlin-scripting-compiler"))
compileOnly 'com.android.tools.build:gradle:2.0.0' compileOnly("com.android.tools.build:gradle:2.0.0")
compileOnly 'org.codehaus.groovy:groovy-all:2.4.12' compileOnly("org.codehaus.groovy:groovy-all:2.4.12")
compileOnly gradleApi() compileOnly(gradleApi())
compileOnly("kotlin.build.custom.deps:intellij-core:${rootProject.ext["versions.intellijSdk"]}") { compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
artifact {
name = 'intellij-core'
type = 'jar'
extension = 'jar'
}
}
runtime project(path: ':kotlin-compiler-embeddable', configuration: "runtimeJar") runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
runtime project(path: ':kotlin-annotation-processing-gradle', configuration: "runtimeJar") runtime(projectRuntimeJar(":kotlin-annotation-processing-gradle"))
runtime project(path: ':kotlin-android-extensions', configuration: 'runtimeJar') runtime(projectRuntimeJar(":kotlin-android-extensions"))
runtime project(path: ':kotlin-compiler-runner', configuration: 'runtimeJar') runtime(projectRuntimeJar(":kotlin-compiler-runner"))
runtime project(path: ':kotlin-scripting-compiler-embeddable', configuration: 'runtimeJar') runtime(projectRuntimeJar(":kotlin-scripting-compiler-embeddable"))
runtime project(':kotlin-reflect') runtime(project(":kotlin-reflect"))
// com.android.tools.build:gradle has ~50 unneeded transitive dependencies // com.android.tools.build:gradle has ~50 unneeded transitive dependencies
agp25CompileOnly('com.android.tools.build:gradle:3.0.0-alpha1') { transitive = false } agp25CompileOnly("com.android.tools.build:gradle:3.0.0-alpha1") { isTransitive = false }
agp25CompileOnly('com.android.tools.build:gradle-core:3.0.0-alpha1') { transitive = false } agp25CompileOnly("com.android.tools.build:gradle-core:3.0.0-alpha1") { isTransitive = false }
agp25CompileOnly('com.android.tools.build:builder-model:3.0.0-alpha1') { transitive = false } agp25CompileOnly("com.android.tools.build:builder-model:3.0.0-alpha1") { isTransitive = false }
agp25CompileOnly 'org.codehaus.groovy:groovy-all:2.4.12' agp25CompileOnly("org.codehaus.groovy:groovy-all:2.4.12")
agp25CompileOnly gradleApi() agp25CompileOnly(gradleApi())
agp25CompileOnly project(':kotlin-annotation-processing') agp25CompileOnly(project(":kotlin-annotation-processing"))
agp25CompileOnly project(':kotlin-annotation-processing-gradle') agp25CompileOnly(project(":kotlin-annotation-processing-gradle"))
testCompileOnly project(':compiler') testCompileOnly (project(":compiler"))
testCompile project(path: ':kotlin-build-common', configuration: 'tests-jar') testCompile(projectTests(":kotlin-build-common"))
testCompile project(':kotlin-android-extensions') testCompile(project(":kotlin-android-extensions"))
testCompile project(':kotlin-compiler-runner') testCompile(project(":kotlin-compiler-runner"))
testCompile project(':kotlin-test::kotlin-test-junit') testCompile(project(":kotlin-test::kotlin-test-junit"))
testCompile "junit:junit:4.12" testCompile("junit:junit:4.12")
testCompileOnly project(':kotlin-reflect-api') testCompileOnly(project(":kotlin-reflect-api"))
testCompileOnly project(':kotlin-annotation-processing') testCompileOnly(project(":kotlin-annotation-processing"))
testCompileOnly project(':kotlin-annotation-processing-gradle') testCompileOnly(project(":kotlin-annotation-processing-gradle"))
} }
tasks.withType(project.compileKotlin.class) { val agp25 by sourceSets.creating
kotlinOptions.jdkHome = JDK_18 agp25.compileClasspath += configurations.compile + agp25CompileOnly + mainSourceSet.output
kotlinOptions.languageVersion = "1.2"
kotlinOptions.apiVersion = "1.2"
kotlinOptions.freeCompilerArgs += ["-Xskip-metadata-version-check"]
}
sourceSets.main.java.srcDirs += sourceSets.main.kotlin.srcDirs tasks {
withType<KotlinCompile> {
kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String
kotlinOptions.languageVersion = "1.2"
kotlinOptions.apiVersion = "1.2"
kotlinOptions.freeCompilerArgs += listOf("-Xskip-metadata-version-check")
}
sourceSets { named<ProcessResources>("processResources") {
agp25 { val propertiesToExpand = mapOf("projectVersion" to project.version)
compileClasspath += configurations.compile + configurations.agp25CompileOnly + sourceSets.main.output for ((name, value) in propertiesToExpand) {
inputs.property(name, value)
}
expand("projectVersion" to project.version)
}
named<Jar>("jar") {
dependsOn(tasks.named("agp25Classes"))
from(agp25.output.classesDirs)
callGroovy("manifestAttributes", manifest, project)
}
named<ValidateTaskProperties>("validateTaskProperties") {
failOnWarning = true
}
named<DokkaTask>("dokka") {
outputFormat = "markdown"
includes = listOf("$projectDir/Module.md")
} }
} }
processResources { projectTest {
def props = ["projectVersion" : project.version] executable = "${rootProject.extra["JDK_18"]!!}/bin/java"
inputs.properties(props) dependsOn(tasks.named("validateTaskProperties"))
expand(props)
}
jar.dependsOn agp25Classes
jar {
from sourceSets.agp25.output.classesDirs
manifestAttributes(manifest, project)
}
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDepsToShadedCompiler(project, jar, {}), {})
artifacts {
archives sourcesJar
archives javadocJar
}
test.executable = "${JDK_18}/bin/java"
test.dependsOn(validateTaskProperties)
validateTaskProperties.failOnWarning = true
dokka {
outputFormat = 'markdown'
includes = ["${projectDir}/Module.md"]
} }
pluginBundle { pluginBundle {
plugins { fun create(name: String, id: String, display: String) {
kotlinJvmPlugin { (plugins).create(name) {
id = 'org.jetbrains.kotlin.jvm' this.id = id
description = displayName = 'Kotlin JVM plugin' this.displayName = display
} this.description = display
kotlinMultiplatformPlugin {
id = 'org.jetbrains.kotlin.multiplatform'
description = displayName = 'Kotlin Multiplatform plugin'
}
kotlinAndroidPlugin {
id = 'org.jetbrains.kotlin.android'
description = displayName = 'Kotlin Android plugin'
}
kotlinAndroidExtensionsPlugin {
id = 'org.jetbrains.kotlin.android.extensions'
description = displayName = 'Kotlin Android Extensions plugin'
}
kotlinKaptPlugin {
id = 'org.jetbrains.kotlin.kapt'
description = displayName = 'Kotlin Kapt plugin'
}
kotlinScriptingPlugin {
id = 'org.jetbrains.kotlin.plugin.scripting'
description = displayName = 'Gradle plugin for kotlin scripting'
} }
} }
create(
name = "kotlinJvmPlugin",
id = "org.jetbrains.kotlin.jvm",
display = "Kotlin JVM plugin"
)
create(
name = "kotlinMultiplatformPlugin",
id = "org.jetbrains.kotlin.multiplatform",
display = "Kotlin Multiplatform plugin"
)
create(
name = "kotlinAndroidPlugin",
id = "org.jetbrains.kotlin.android",
display = "Android"
)
create(
name = "kotlinAndroidExtensionsPlugin",
id = "org.jetbrains.kotlin.android.extensions",
display = "Kotlin Android Extensions plugin"
)
create(
name = "kotlinKaptPlugin",
id = "org.jetbrains.kotlin.kapt",
display = "Kotlin Kapt plugin"
)
create(
name = "kotlinScriptingPlugin",
id = "org.jetbrains.kotlin.plugin.scripting",
display = "Gradle plugin for kotlin scripting"
)
} }