Implement Gradle Kotlin DSL build
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
compile(project(":core:builtins"))
|
||||
compile(project("util.runtime"))
|
||||
compile(protobufLite())
|
||||
compile(commonDep("javax.inject"))
|
||||
}
|
||||
|
||||
configureKotlinProjectSources(
|
||||
"descriptor.loader.java/src",
|
||||
"descriptors/src",
|
||||
"descriptors.runtime/src",
|
||||
"deserialization/src")
|
||||
configureKotlinProjectResources(
|
||||
"descriptor.loader.java/src", "deserialization/src") { include("META-INF/**") }
|
||||
configureKotlinProjectNoTests()
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.serialization.builtins.BuiltInsSerializer
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import java.io.File
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
val builtinsSrc = File(rootDir, "core", "builtins", "src")
|
||||
val builtinsNative = File(rootDir, "core", "builtins", "native")
|
||||
// TODO: rewrite dependent projects on using build results instead of the fixed location
|
||||
val builtinsSerialized = File(rootProject.extra["distDir"].toString(), "builtins")
|
||||
|
||||
val builtins by configurations.creating
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
compile(protobufLite())
|
||||
compile(files(builtinsSerialized))
|
||||
}
|
||||
|
||||
configureKotlinProjectSources("core/builtins/src", "core/runtime.jvm/src", sourcesBaseDir = rootDir)
|
||||
configureKotlinProjectResources(listOf(builtinsSerialized))
|
||||
configureKotlinProjectNoTests()
|
||||
|
||||
val serialize = task("serialize") {
|
||||
val outDir = builtinsSerialized
|
||||
val inDirs = arrayOf(builtinsSrc, builtinsNative)
|
||||
outputs.file(outDir)
|
||||
inputs.files(*inDirs)
|
||||
doLast {
|
||||
System.setProperty("kotlin.colors.enabled", "false")
|
||||
BuiltInsSerializer(dependOnOldBuiltIns = false)
|
||||
.serialize(outDir, inDirs.asList(), listOf()) { totalSize, totalFiles ->
|
||||
println("Total bytes written: $totalSize to $totalFiles files")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
dependsOn(serialize)
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
dependsOn(serialize)
|
||||
}
|
||||
|
||||
val jar: Jar by tasks
|
||||
jar.apply {
|
||||
dependsOn(serialize)
|
||||
from(builtinsSerialized) { include("kotlin/**") }
|
||||
}
|
||||
|
||||
val builtinsJar by task<Jar> {
|
||||
dependsOn(serialize)
|
||||
from(builtinsSerialized) { include("kotlin/**") }
|
||||
baseName = "platform-builtins"
|
||||
destinationDir = File(buildDir, "libs")
|
||||
}
|
||||
|
||||
artifacts.add(builtins.name, builtinsJar)
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import java.io.File
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
|
||||
classpath(ideaSdkDeps("asm-all"))
|
||||
}
|
||||
}
|
||||
|
||||
apply {
|
||||
plugin("kotlin")
|
||||
plugin("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
configure<JavaPluginConvention> {
|
||||
sourceSets.getByName("main")?.apply {
|
||||
val srcs = listOf(File(rootDir, "core/reflection.jvm/src"))
|
||||
java.setSrcDirs(srcs)
|
||||
}
|
||||
sourceSets.getByName("test").apply {
|
||||
java.setSrcDirs(emptyList<File>())
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
compile(project(":core:builtins"))
|
||||
compile(project(":core"))
|
||||
compile(protobufLite())
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
dependsOn(protobufLiteTask)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
compile(project(":core:builtins"))
|
||||
compile(kotlinDep("stdlib"))
|
||||
buildVersion()
|
||||
}
|
||||
|
||||
configureKotlinProjectSourcesDefault()
|
||||
configureKotlinProjectNoTests()
|
||||
|
||||
tasks.withType<Jar> {
|
||||
setupRuntimeJar("Kotlin Script Runtime")
|
||||
archiveName = "kotlin-script-runtime.jar"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
apply {
|
||||
plugin("java")
|
||||
plugin("kotlin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val compile by configurations
|
||||
compile(project(":core:builtins"))
|
||||
compile(kotlinDep("stdlib"))
|
||||
}
|
||||
|
||||
configureKotlinProjectSourcesDefault()
|
||||
configureKotlinProjectNoTests()
|
||||
|
||||
Reference in New Issue
Block a user