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 {
|
||||
|
||||
configurations.maybeCreate("embedded")
|
||||
|
||||
jvmTarget = defaultJvmTarget
|
||||
if (defaultJavaHome != null) {
|
||||
javaHome = defaultJavaHome
|
||||
|
||||
@@ -73,6 +73,12 @@ fun <T : Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
removeArtifacts(configurations.getOrCreate("archives"), defaultJarTask)
|
||||
}
|
||||
return task.apply {
|
||||
configurations.findByName("embedded")?.let { embedded ->
|
||||
dependsOn(embedded)
|
||||
from {
|
||||
embedded.map(::zipTree)
|
||||
}
|
||||
}
|
||||
setupPublicJar(project.the<BasePluginConvention>().archivesBaseName)
|
||||
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||
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"
|
||||
|
||||
object EmbeddedComponents {
|
||||
val CONFIGURATION_NAME = "embeddedComponents"
|
||||
val CONFIGURATION_NAME = "embedded"
|
||||
}
|
||||
|
||||
fun AbstractCopyTask.fromEmbeddedComponents() {
|
||||
|
||||
@@ -131,7 +131,7 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile {
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.io.File
|
||||
|
||||
class PillConfigurablePlugin : Plugin<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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ dependencies {
|
||||
compileOnly(commonDep("net.rubygrapefruit", "native-platform"))
|
||||
compileOnly(intellijDep()) { includeIntellijCoreJarDependencies(project) }
|
||||
|
||||
embeddedComponents(project(":compiler:daemon-common")) { isTransitive = false }
|
||||
embeddedComponents(commonDep("net.rubygrapefruit", "native-platform"))
|
||||
embedded(project(":compiler:daemon-common")) { isTransitive = false }
|
||||
embedded(commonDep("net.rubygrapefruit", "native-platform"))
|
||||
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")) {
|
||||
from(mainSourceSet.output)
|
||||
fromEmbeddedComponents()
|
||||
}
|
||||
|
||||
sourcesJar()
|
||||
|
||||
@@ -34,7 +34,7 @@ dependencies {
|
||||
robolectricClasspath("org.robolectric:android-all:4.4_r1-robolectric-1")
|
||||
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 {
|
||||
@@ -42,9 +42,7 @@ sourceSets {
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
fromEmbeddedComponents()
|
||||
}
|
||||
runtimeJar()
|
||||
|
||||
dist()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ dependencies {
|
||||
|
||||
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 {
|
||||
@@ -34,8 +34,6 @@ projectTest {
|
||||
dependsOn(":dist")
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
fromEmbeddedComponents()
|
||||
}
|
||||
runtimeJar()
|
||||
|
||||
dist()
|
||||
@@ -33,9 +33,9 @@ dependencies {
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(project(":kotlin-annotation-processing-runtime"))
|
||||
|
||||
embeddedComponents(project(":kotlin-annotation-processing-runtime")) { isTransitive = false }
|
||||
embeddedComponents(project(":kotlin-annotation-processing-cli")) { isTransitive = false }
|
||||
embeddedComponents(project(":kotlin-annotation-processing-base")) { isTransitive = false }
|
||||
embedded(project(":kotlin-annotation-processing-runtime")) { isTransitive = false }
|
||||
embedded(project(":kotlin-annotation-processing-cli")) { isTransitive = false }
|
||||
embedded(project(":kotlin-annotation-processing-base")) { isTransitive = false }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -52,9 +52,7 @@ projectTest {
|
||||
|
||||
publish()
|
||||
|
||||
runtimeJar {
|
||||
fromEmbeddedComponents()
|
||||
}
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
@@ -97,7 +97,6 @@ val projectsToShadow by extra(listOf(
|
||||
emptyArray<String>()
|
||||
))
|
||||
|
||||
val embedded by configurations.creating // PILL: used in pill importer
|
||||
val libraries by configurations.creating
|
||||
val jpsPlugin by configurations.creating
|
||||
|
||||
@@ -137,12 +136,7 @@ dependencies {
|
||||
}
|
||||
|
||||
val jar = runtimeJar {
|
||||
dependsOn(embedded)
|
||||
from("$rootDir/resources/kotlinManifest.properties")
|
||||
from {
|
||||
embedded.files.map(::zipTree)
|
||||
}
|
||||
|
||||
archiveName = "kotlin-plugin.jar"
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,14 @@ val projectsToShadow = listOf(
|
||||
|
||||
dependencies {
|
||||
projectsToShadow.forEach {
|
||||
embeddedComponents(project(it)) { isTransitive = false }
|
||||
embedded(project(it)) { isTransitive = false }
|
||||
}
|
||||
|
||||
embeddedComponents(projectRuntimeJar(":kotlin-daemon-client"))
|
||||
embedded(projectRuntimeJar(":kotlin-daemon-client"))
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.runner.Main"
|
||||
manifest.attributes["Class-Path"] = "kotlin-stdlib.jar"
|
||||
from(files("$rootDir/resources/kotlinManifest.properties"))
|
||||
fromEmbeddedComponents()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user