Build: Introduce embedded configuration used for fatJars
This commit is contained in:
@@ -292,6 +292,8 @@ val ignoreTestFailures by extra(project.findProperty("ignoreTestFailures")?.toSt
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
|
configurations.maybeCreate("embedded")
|
||||||
|
|
||||||
jvmTarget = defaultJvmTarget
|
jvmTarget = defaultJvmTarget
|
||||||
if (defaultJavaHome != null) {
|
if (defaultJavaHome != null) {
|
||||||
javaHome = defaultJavaHome
|
javaHome = defaultJavaHome
|
||||||
|
|||||||
@@ -73,6 +73,12 @@ fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
|||||||
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
|
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
|
||||||
}
|
}
|
||||||
return task.apply {
|
return task.apply {
|
||||||
|
configurations.findByName("embedded")?.let { embedded ->
|
||||||
|
dependsOn(embedded)
|
||||||
|
from {
|
||||||
|
embedded.map(::zipTree)
|
||||||
|
}
|
||||||
|
}
|
||||||
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
|
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
|
||||||
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
body()
|
body()
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.artifacts.Dependency
|
||||||
|
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||||
|
import org.gradle.api.artifacts.ModuleDependency
|
||||||
|
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||||
|
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
|
||||||
|
import org.gradle.kotlin.dsl.accessors.runtime.addExternalModuleDependencyTo
|
||||||
|
import org.gradle.kotlin.dsl.add
|
||||||
|
|
||||||
|
fun DependencyHandler.embedded(dependencyNotation: Any): Dependency? =
|
||||||
|
add("embedded", dependencyNotation)
|
||||||
|
|
||||||
|
fun DependencyHandler.embedded(
|
||||||
|
dependencyNotation: String,
|
||||||
|
dependencyConfiguration: Action<ExternalModuleDependency>
|
||||||
|
): ExternalModuleDependency =
|
||||||
|
addDependencyTo(this, "embedded", dependencyNotation, dependencyConfiguration)
|
||||||
|
|
||||||
|
fun DependencyHandler.embedded(
|
||||||
|
group: String,
|
||||||
|
name: String,
|
||||||
|
version: String? = null,
|
||||||
|
configuration: String? = null,
|
||||||
|
classifier: String? = null,
|
||||||
|
ext: String? = null,
|
||||||
|
dependencyConfiguration: Action<ExternalModuleDependency>? = null
|
||||||
|
): ExternalModuleDependency = addExternalModuleDependencyTo(
|
||||||
|
this, "embedded", group, name, version, configuration, classifier, ext, dependencyConfiguration
|
||||||
|
)
|
||||||
|
|
||||||
|
fun <T : ModuleDependency> DependencyHandler.embedded(
|
||||||
|
dependency: T,
|
||||||
|
dependencyConfiguration: T.() -> Unit
|
||||||
|
): T = add("embedded", dependency, dependencyConfiguration)
|
||||||
@@ -135,7 +135,7 @@ val compilerManifestClassPath
|
|||||||
get() = "annotations-13.0.jar kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar"
|
get() = "annotations-13.0.jar kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar trove4j.jar"
|
||||||
|
|
||||||
object EmbeddedComponents {
|
object EmbeddedComponents {
|
||||||
val CONFIGURATION_NAME = "embeddedComponents"
|
val CONFIGURATION_NAME = "embedded"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun AbstractCopyTask.fromEmbeddedComponents() {
|
fun AbstractCopyTask.fromEmbeddedComponents() {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile {
|
|||||||
|
|
||||||
kotlinPluginJar.add(FileCopy(File(rootProject.projectDir, "resources/kotlinManifest.properties")))
|
kotlinPluginJar.add(FileCopy(File(rootProject.projectDir, "resources/kotlinManifest.properties")))
|
||||||
|
|
||||||
for (jarFile in sourcePath.project.configurations.getByName("embedded").resolve()) {
|
for (jarFile in sourcePath.project.configurations.getByName(EmbeddedComponents.CONFIGURATION_NAME).resolve()) {
|
||||||
kotlinPluginJar.add(ExtractedDirectory(jarFile))
|
kotlinPluginJar.add(ExtractedDirectory(jarFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.io.File
|
|||||||
|
|
||||||
class PillConfigurablePlugin : Plugin<Project> {
|
class PillConfigurablePlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.configurations.create(EmbeddedComponents.CONFIGURATION_NAME)
|
project.configurations.maybeCreate(EmbeddedComponents.CONFIGURATION_NAME)
|
||||||
project.extensions.create("pill", PillExtension::class.java)
|
project.extensions.create("pill", PillExtension::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ dependencies {
|
|||||||
compileOnly(commonDep("net.rubygrapefruit", "native-platform"))
|
compileOnly(commonDep("net.rubygrapefruit", "native-platform"))
|
||||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||||
|
|
||||||
embeddedComponents(project(":compiler:daemon-common")) { isTransitive = false }
|
embedded(project(":compiler:daemon-common")) { isTransitive = false }
|
||||||
embeddedComponents(commonDep("net.rubygrapefruit", "native-platform"))
|
embedded(commonDep("net.rubygrapefruit", "native-platform"))
|
||||||
nativePlatformVariants.forEach {
|
nativePlatformVariants.forEach {
|
||||||
embeddedComponents(commonDep("net.rubygrapefruit", "native-platform", "-$it"))
|
embedded(commonDep("net.rubygrapefruit", "native-platform", "-$it"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,6 @@ noDefaultJar()
|
|||||||
|
|
||||||
runtimeJar(task<ShadowJar>("shadowJar")) {
|
runtimeJar(task<ShadowJar>("shadowJar")) {
|
||||||
from(mainSourceSet.output)
|
from(mainSourceSet.output)
|
||||||
fromEmbeddedComponents()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ dependencies {
|
|||||||
robolectricClasspath("org.robolectric:android-all:4.4_r1-robolectric-1")
|
robolectricClasspath("org.robolectric:android-all:4.4_r1-robolectric-1")
|
||||||
robolectricClasspath(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
robolectricClasspath(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
||||||
|
|
||||||
embeddedComponents(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
embedded(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -42,9 +42,7 @@ sourceSets {
|
|||||||
"test" { projectDefault() }
|
"test" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar()
|
||||||
fromEmbeddedComponents()
|
|
||||||
}
|
|
||||||
|
|
||||||
dist()
|
dist()
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ dependencies {
|
|||||||
|
|
||||||
testCompile(projectTests(":compiler:tests-common"))
|
testCompile(projectTests(":compiler:tests-common"))
|
||||||
|
|
||||||
embeddedComponents("org.jetbrains.kotlinx", "kotlinx-serialization-runtime", kotlinxSerializationVersion) { isTransitive = false }
|
embedded("org.jetbrains.kotlinx", "kotlinx-serialization-runtime", kotlinxSerializationVersion) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -34,8 +34,6 @@ projectTest {
|
|||||||
dependsOn(":dist")
|
dependsOn(":dist")
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar()
|
||||||
fromEmbeddedComponents()
|
|
||||||
}
|
|
||||||
|
|
||||||
dist()
|
dist()
|
||||||
@@ -33,9 +33,9 @@ dependencies {
|
|||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
testCompile(project(":kotlin-annotation-processing-runtime"))
|
testCompile(project(":kotlin-annotation-processing-runtime"))
|
||||||
|
|
||||||
embeddedComponents(project(":kotlin-annotation-processing-runtime")) { isTransitive = false }
|
embedded(project(":kotlin-annotation-processing-runtime")) { isTransitive = false }
|
||||||
embeddedComponents(project(":kotlin-annotation-processing-cli")) { isTransitive = false }
|
embedded(project(":kotlin-annotation-processing-cli")) { isTransitive = false }
|
||||||
embeddedComponents(project(":kotlin-annotation-processing-base")) { isTransitive = false }
|
embedded(project(":kotlin-annotation-processing-base")) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -52,9 +52,7 @@ projectTest {
|
|||||||
|
|
||||||
publish()
|
publish()
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar()
|
||||||
fromEmbeddedComponents()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ val projectsToShadow by extra(listOf(
|
|||||||
emptyArray<String>()
|
emptyArray<String>()
|
||||||
))
|
))
|
||||||
|
|
||||||
val embedded by configurations.creating // PILL: used in pill importer
|
|
||||||
val libraries by configurations.creating
|
val libraries by configurations.creating
|
||||||
val jpsPlugin by configurations.creating
|
val jpsPlugin by configurations.creating
|
||||||
|
|
||||||
@@ -137,12 +136,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val jar = runtimeJar {
|
val jar = runtimeJar {
|
||||||
dependsOn(embedded)
|
|
||||||
from("$rootDir/resources/kotlinManifest.properties")
|
from("$rootDir/resources/kotlinManifest.properties")
|
||||||
from {
|
|
||||||
embedded.files.map(::zipTree)
|
|
||||||
}
|
|
||||||
|
|
||||||
archiveName = "kotlin-plugin.jar"
|
archiveName = "kotlin-plugin.jar"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,14 @@ val projectsToShadow = listOf(
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
projectsToShadow.forEach {
|
projectsToShadow.forEach {
|
||||||
embeddedComponents(project(it)) { isTransitive = false }
|
embedded(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
embeddedComponents(projectRuntimeJar(":kotlin-daemon-client"))
|
embedded(projectRuntimeJar(":kotlin-daemon-client"))
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar {
|
||||||
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.runner.Main"
|
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.runner.Main"
|
||||||
manifest.attributes["Class-Path"] = "kotlin-stdlib.jar"
|
manifest.attributes["Class-Path"] = "kotlin-stdlib.jar"
|
||||||
from(files("$rootDir/resources/kotlinManifest.properties"))
|
from(files("$rootDir/resources/kotlinManifest.properties"))
|
||||||
fromEmbeddedComponents()
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user