Make a project-wide embeddedComponents configuration for embedding external binaries to project artifacts
This commit is contained in:
@@ -5,6 +5,8 @@ import org.gradle.api.Project
|
|||||||
import org.gradle.api.artifacts.ProjectDependency
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||||
import org.gradle.api.file.ConfigurableFileCollection
|
import org.gradle.api.file.ConfigurableFileCollection
|
||||||
|
import org.gradle.api.tasks.AbstractCopyTask
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import org.gradle.kotlin.dsl.extra
|
import org.gradle.kotlin.dsl.extra
|
||||||
import org.gradle.kotlin.dsl.project
|
import org.gradle.kotlin.dsl.project
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -98,3 +100,19 @@ fun firstFromJavaHomeThatExists(vararg paths: String): File? =
|
|||||||
|
|
||||||
fun toolsJar(): File? = firstFromJavaHomeThatExists("../lib/tools.jar", "../Classes/tools.jar")
|
fun toolsJar(): File? = firstFromJavaHomeThatExists("../lib/tools.jar", "../Classes/tools.jar")
|
||||||
|
|
||||||
|
object EmbeddedComponents {
|
||||||
|
val CONFIGURATION_NAME = "embeddedComponents"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.containsEmbeddedComponents() {
|
||||||
|
configurations.create(EmbeddedComponents.CONFIGURATION_NAME)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AbstractCopyTask.fromEmbeddedComponents() {
|
||||||
|
val embeddedComponents = project.configurations.getByName(EmbeddedComponents.CONFIGURATION_NAME)
|
||||||
|
if (this is ShadowJar) {
|
||||||
|
from(embeddedComponents)
|
||||||
|
} else {
|
||||||
|
embeddedComponents.forEach { from(if (it.isDirectory) it else project.zipTree(it)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,7 +107,10 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile {
|
|||||||
val root = Root()
|
val root = Root()
|
||||||
|
|
||||||
// Copy kotlinc directory
|
// Copy kotlinc directory
|
||||||
root.add(DirectoryCopy(File(rootProject.extra["distKotlinHomeDir"].toString())))
|
root.add(Directory("kotlinc").apply {
|
||||||
|
val kotlincDirectory = rootProject.extra["distKotlinHomeDir"].toString()
|
||||||
|
add(DirectoryCopy(File(kotlincDirectory)))
|
||||||
|
})
|
||||||
|
|
||||||
for (task in ideaPluginTasks) {
|
for (task in ideaPluginTasks) {
|
||||||
val spec = task.rootSpec.children.filterIsInstance<SingleParentCopySpec>().singleOrNull()
|
val spec = task.rootSpec.children.filterIsInstance<SingleParentCopySpec>().singleOrNull()
|
||||||
@@ -146,11 +149,11 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile {
|
|||||||
root.getDirectory(targetDir).add(this)
|
root.getDirectory(targetDir).add(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
val fatJarContentsConfiguration = sourcePath.project.configurations
|
val embeddedComponents = sourcePath.project.configurations
|
||||||
.findByName("fatJarContents")?.resolvedConfiguration
|
.findByName(EmbeddedComponents.CONFIGURATION_NAME)?.resolvedConfiguration
|
||||||
|
|
||||||
if (fatJarContentsConfiguration != null) {
|
if (embeddedComponents != null) {
|
||||||
for ((_, _, dependency) in listOf(fatJarContentsConfiguration to Scope.COMPILE).collectDependencies()) {
|
for ((_, _, dependency) in listOf(embeddedComponents to Scope.COMPILE).collectDependencies()) {
|
||||||
if (dependency.configuration == "runtimeElements") {
|
if (dependency.configuration == "runtimeElements") {
|
||||||
archiveForJar.add(ModuleOutput(dependency.moduleName + ".src"))
|
archiveForJar.add(ModuleOutput(dependency.moduleName + ".src"))
|
||||||
} else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") {
|
} else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") {
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ jvmTarget = "1.6"
|
|||||||
|
|
||||||
val nativePlatformVariants: List<String> by rootProject.extra
|
val nativePlatformVariants: List<String> by rootProject.extra
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
containsEmbeddedComponents()
|
||||||
val fatJarContents by configurations.creating
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":compiler:util"))
|
compileOnly(project(":compiler:util"))
|
||||||
@@ -18,10 +17,11 @@ dependencies {
|
|||||||
compileOnly(project(":compiler:daemon-common"))
|
compileOnly(project(":compiler:daemon-common"))
|
||||||
compileOnly(project(":kotlin-reflect-api"))
|
compileOnly(project(":kotlin-reflect-api"))
|
||||||
compileOnly(commonDep("net.rubygrapefruit", "native-platform"))
|
compileOnly(commonDep("net.rubygrapefruit", "native-platform"))
|
||||||
fatJarContents(project(":compiler:daemon-common")) { isTransitive = false }
|
|
||||||
fatJarContents(commonDep("net.rubygrapefruit", "native-platform"))
|
embeddedComponents(project(":compiler:daemon-common")) { isTransitive = false }
|
||||||
|
embeddedComponents(commonDep("net.rubygrapefruit", "native-platform"))
|
||||||
nativePlatformVariants.forEach {
|
nativePlatformVariants.forEach {
|
||||||
fatJarContents(commonDep("net.rubygrapefruit", "native-platform", "-$it"))
|
embeddedComponents(commonDep("net.rubygrapefruit", "native-platform", "-$it"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +32,9 @@ sourceSets {
|
|||||||
|
|
||||||
runtimeJar(task<ShadowJar>("shadowJar")) {
|
runtimeJar(task<ShadowJar>("shadowJar")) {
|
||||||
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
from(the<JavaPluginConvention>().sourceSets.getByName("main").output)
|
||||||
from(fatJarContents)
|
fromEmbeddedComponents()
|
||||||
}
|
}
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
"configurations": [
|
"configurations": [
|
||||||
"archives",
|
"archives",
|
||||||
"default",
|
"default",
|
||||||
|
"embeddedComponents",
|
||||||
"runtimeJar"
|
"runtimeJar"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
@@ -199,8 +200,7 @@
|
|||||||
"testImplementation",
|
"testImplementation",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeClasspath",
|
"testRuntimeClasspath",
|
||||||
"testRuntimeOnly",
|
"testRuntimeOnly"
|
||||||
"tests-jar"
|
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
@@ -545,6 +545,7 @@
|
|||||||
"compileOnly",
|
"compileOnly",
|
||||||
"default",
|
"default",
|
||||||
"distJar",
|
"distJar",
|
||||||
|
"embeddedComponents",
|
||||||
"implementation",
|
"implementation",
|
||||||
"jpsTest",
|
"jpsTest",
|
||||||
"kapt",
|
"kapt",
|
||||||
@@ -1009,7 +1010,7 @@
|
|||||||
"compileOnly",
|
"compileOnly",
|
||||||
"default",
|
"default",
|
||||||
"distJar",
|
"distJar",
|
||||||
"fatJarContents",
|
"embeddedComponents",
|
||||||
"implementation",
|
"implementation",
|
||||||
"jpsTest",
|
"jpsTest",
|
||||||
"kapt",
|
"kapt",
|
||||||
@@ -1242,7 +1243,7 @@
|
|||||||
"configurations": [
|
"configurations": [
|
||||||
"archives",
|
"archives",
|
||||||
"default",
|
"default",
|
||||||
"fatJarContents",
|
"embeddedComponents",
|
||||||
"runtimeJar"
|
"runtimeJar"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
@@ -1751,10 +1752,18 @@
|
|||||||
"compileOnly",
|
"compileOnly",
|
||||||
"default",
|
"default",
|
||||||
"distJar",
|
"distJar",
|
||||||
|
"experimentalCompile",
|
||||||
|
"experimentalCompileClasspath",
|
||||||
|
"experimentalCompileOnly",
|
||||||
|
"experimentalImplementation",
|
||||||
|
"experimentalRuntime",
|
||||||
|
"experimentalRuntimeClasspath",
|
||||||
|
"experimentalRuntimeOnly",
|
||||||
"implementation",
|
"implementation",
|
||||||
"kapt",
|
"kapt",
|
||||||
"kaptAnnotations",
|
"kaptAnnotations",
|
||||||
"kaptBuiltins",
|
"kaptBuiltins",
|
||||||
|
"kaptExperimental",
|
||||||
"kaptTest",
|
"kaptTest",
|
||||||
"mainJar",
|
"mainJar",
|
||||||
"runtime",
|
"runtime",
|
||||||
@@ -1992,6 +2001,13 @@
|
|||||||
"compileOnly",
|
"compileOnly",
|
||||||
"default",
|
"default",
|
||||||
"distJar",
|
"distJar",
|
||||||
|
"experimentalCompile",
|
||||||
|
"experimentalCompileClasspath",
|
||||||
|
"experimentalCompileOnly",
|
||||||
|
"experimentalImplementation",
|
||||||
|
"experimentalRuntime",
|
||||||
|
"experimentalRuntimeClasspath",
|
||||||
|
"experimentalRuntimeOnly",
|
||||||
"implementation",
|
"implementation",
|
||||||
"merger",
|
"merger",
|
||||||
"nodeDist",
|
"nodeDist",
|
||||||
@@ -2970,7 +2986,8 @@
|
|||||||
"testImplementation",
|
"testImplementation",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeClasspath",
|
"testRuntimeClasspath",
|
||||||
"testRuntimeOnly"
|
"testRuntimeOnly",
|
||||||
|
"tests-jar"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
@@ -3006,7 +3023,8 @@
|
|||||||
"testImplementation",
|
"testImplementation",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeClasspath",
|
"testRuntimeClasspath",
|
||||||
"testRuntimeOnly"
|
"testRuntimeOnly",
|
||||||
|
"tests-jar"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
@@ -3863,7 +3881,8 @@
|
|||||||
"testImplementation",
|
"testImplementation",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeClasspath",
|
"testRuntimeClasspath",
|
||||||
"testRuntimeOnly"
|
"testRuntimeOnly",
|
||||||
|
"tests-jar"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
@@ -3910,6 +3929,38 @@
|
|||||||
"reporting": "org.gradle.api.reporting.ReportingExtension"
|
"reporting": "org.gradle.api.reporting.ReportingExtension"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
":jps-plugin:jps-services-declarations": {
|
||||||
|
"conventions": {
|
||||||
|
"base": "org.gradle.api.plugins.BasePluginConvention",
|
||||||
|
"java": "org.gradle.api.plugins.JavaPluginConvention"
|
||||||
|
},
|
||||||
|
"configurations": [
|
||||||
|
"apiElements",
|
||||||
|
"archives",
|
||||||
|
"compile",
|
||||||
|
"compileClasspath",
|
||||||
|
"compileOnly",
|
||||||
|
"default",
|
||||||
|
"implementation",
|
||||||
|
"jpsTest",
|
||||||
|
"runtime",
|
||||||
|
"runtimeClasspath",
|
||||||
|
"runtimeElements",
|
||||||
|
"runtimeOnly",
|
||||||
|
"testCompile",
|
||||||
|
"testCompileClasspath",
|
||||||
|
"testCompileOnly",
|
||||||
|
"testImplementation",
|
||||||
|
"testRuntime",
|
||||||
|
"testRuntimeClasspath",
|
||||||
|
"testRuntimeOnly"
|
||||||
|
],
|
||||||
|
"extensions": {
|
||||||
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
|
"defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet",
|
||||||
|
"reporting": "org.gradle.api.reporting.ReportingExtension"
|
||||||
|
}
|
||||||
|
},
|
||||||
":js:js.ast": {
|
":js:js.ast": {
|
||||||
"conventions": {
|
"conventions": {
|
||||||
"base": "org.gradle.api.plugins.BasePluginConvention",
|
"base": "org.gradle.api.plugins.BasePluginConvention",
|
||||||
@@ -4586,6 +4637,7 @@
|
|||||||
"compileOnly",
|
"compileOnly",
|
||||||
"default",
|
"default",
|
||||||
"distJar",
|
"distJar",
|
||||||
|
"embeddedComponents",
|
||||||
"implementation",
|
"implementation",
|
||||||
"jpsTest",
|
"jpsTest",
|
||||||
"kapt",
|
"kapt",
|
||||||
@@ -4940,7 +4992,8 @@
|
|||||||
"testImplementation",
|
"testImplementation",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeClasspath",
|
"testRuntimeClasspath",
|
||||||
"testRuntimeOnly"
|
"testRuntimeOnly",
|
||||||
|
"versions"
|
||||||
],
|
],
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ apply { plugin("jps-compatible") }
|
|||||||
|
|
||||||
val robolectricClasspath by configurations.creating
|
val robolectricClasspath by configurations.creating
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
containsEmbeddedComponents()
|
||||||
val fatJarContents by configurations.creating
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile(intellijCoreDep()) { includeJars("intellij-core") }
|
testCompile(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
@@ -34,7 +33,7 @@ dependencies {
|
|||||||
|
|
||||||
robolectricClasspath(commonDep("org.robolectric", "robolectric"))
|
robolectricClasspath(commonDep("org.robolectric", "robolectric"))
|
||||||
|
|
||||||
fatJarContents(project(":kotlin-android-extensions-runtime"))
|
embeddedComponents(project(":kotlin-android-extensions-runtime")) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -43,7 +42,7 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar {
|
||||||
from(getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs)
|
fromEmbeddedComponents()
|
||||||
}
|
}
|
||||||
|
|
||||||
dist()
|
dist()
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ description = "Annotation Processor for Kotlin"
|
|||||||
apply { plugin("kotlin") }
|
apply { plugin("kotlin") }
|
||||||
apply { plugin("jps-compatible") }
|
apply { plugin("jps-compatible") }
|
||||||
|
|
||||||
|
containsEmbeddedComponents()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
testRuntime(intellijDep())
|
testRuntime(intellijDep())
|
||||||
@@ -23,6 +25,8 @@ dependencies {
|
|||||||
testCompile(projectTests(":compiler:tests-common"))
|
testCompile(projectTests(":compiler:tests-common"))
|
||||||
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 }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -30,10 +34,6 @@ sourceSets {
|
|||||||
"test" { projectDefault() }
|
"test" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
|
||||||
from(getSourceSetsFrom(":kotlin-annotation-processing-runtime")["main"].output.classesDirs)
|
|
||||||
}
|
|
||||||
|
|
||||||
testsJar {}
|
testsJar {}
|
||||||
|
|
||||||
projectTest {
|
projectTest {
|
||||||
@@ -41,7 +41,10 @@ projectTest {
|
|||||||
dependsOn(":dist")
|
dependsOn(":dist")
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar()
|
runtimeJar {
|
||||||
|
fromEmbeddedComponents()
|
||||||
|
}
|
||||||
|
|
||||||
sourcesJar()
|
sourcesJar()
|
||||||
javadocJar()
|
javadocJar()
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,19 @@ sourceSets {
|
|||||||
"test" {}
|
"test" {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
containsEmbeddedComponents()
|
||||||
val fatJarContents by configurations.creating
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
projectsToShadow.forEach {p ->
|
projectsToShadow.forEach { p ->
|
||||||
fatJarContents(project(p)) { isTransitive = false }
|
embeddedComponents(project(p)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar {
|
runtimeJar {
|
||||||
|
/*
|
||||||
|
TODO: `fromEmbeddedComponents()` should be used here.
|
||||||
|
Couldn't use it because of the "must be locked before it can be used to compute a classpath" error.
|
||||||
|
*/
|
||||||
projectsToShadow.forEach {
|
projectsToShadow.forEach {
|
||||||
dependsOn("$it:classes")
|
dependsOn("$it:classes")
|
||||||
project(it).let { p ->
|
project(it).let { p ->
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ val shrink =
|
|||||||
val compilerManifestClassPath =
|
val compilerManifestClassPath =
|
||||||
"kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
"kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar"
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating
|
||||||
|
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
|
|||||||
@@ -21,20 +21,20 @@ val projectsToShadow = listOf(
|
|||||||
":core:util.runtime",
|
":core:util.runtime",
|
||||||
":plugins:android-extensions-jps")
|
":plugins:android-extensions-jps")
|
||||||
|
|
||||||
// Do not rename, used in JPS importer
|
|
||||||
val fatJarContents by configurations.creating
|
containsEmbeddedComponents()
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
projectsToShadow.forEach {
|
projectsToShadow.forEach {
|
||||||
fatJarContents(project(it)) { isTransitive = false }
|
embeddedComponents(project(it)) { isTransitive = false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimeJar<ShadowJar>(task<ShadowJar>("jar")) {
|
runtimeJar<ShadowJar>(task<ShadowJar>("jar")) {
|
||||||
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main")
|
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main")
|
||||||
manifest.attributes.put("Class-Path", "kotlin-stdlib.jar")
|
manifest.attributes.put("Class-Path", "kotlin-stdlib.jar")
|
||||||
from(fatJarContents)
|
|
||||||
from(files("$rootDir/resources/kotlinManifest.properties"))
|
from(files("$rootDir/resources/kotlinManifest.properties"))
|
||||||
|
fromEmbeddedComponents()
|
||||||
}
|
}
|
||||||
|
|
||||||
ideaPlugin("lib/jps")
|
ideaPlugin("lib/jps")
|
||||||
|
|||||||
Reference in New Issue
Block a user