Build: Use configurations property for shadowJar in :kotlin-main-kts
It marked as classpath and improves cache reuse between different builds
This commit is contained in:
@@ -11,6 +11,8 @@ plugins {
|
|||||||
val jarBaseName = property("archivesBaseName") as String
|
val jarBaseName = property("archivesBaseName") as String
|
||||||
|
|
||||||
val proguardLibraryJars by configurations.creating
|
val proguardLibraryJars by configurations.creating
|
||||||
|
val relocatedJarContents by configurations.creating
|
||||||
|
val embedded by configurations
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.apache.ivy:ivy:2.5.0")
|
compileOnly("org.apache.ivy:ivy:2.5.0")
|
||||||
@@ -35,6 +37,9 @@ dependencies {
|
|||||||
proguardLibraryJars(kotlinStdlib())
|
proguardLibraryJars(kotlinStdlib())
|
||||||
proguardLibraryJars(project(":kotlin-reflect"))
|
proguardLibraryJars(project(":kotlin-reflect"))
|
||||||
proguardLibraryJars(project(":kotlin-compiler"))
|
proguardLibraryJars(project(":kotlin-compiler"))
|
||||||
|
|
||||||
|
relocatedJarContents(embedded)
|
||||||
|
relocatedJarContents(mainSourceSet.output)
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -46,15 +51,12 @@ publish()
|
|||||||
|
|
||||||
noDefaultJar()
|
noDefaultJar()
|
||||||
|
|
||||||
val packJar by task<ShadowJar> {
|
val relocatedJar by task<ShadowJar> {
|
||||||
configurations = emptyList()
|
configurations = listOf(relocatedJarContents)
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
destinationDirectory.set(File(buildDir, "libs"))
|
destinationDirectory.set(File(buildDir, "libs"))
|
||||||
archiveClassifier.set("before-proguard")
|
archiveClassifier.set("before-proguard")
|
||||||
|
|
||||||
from(mainSourceSet.output)
|
|
||||||
from(project.configurations.embedded)
|
|
||||||
|
|
||||||
// don't add this files to resources classpath to avoid IDE exceptions on kotlin project
|
// don't add this files to resources classpath to avoid IDE exceptions on kotlin project
|
||||||
from("jar-resources")
|
from("jar-resources")
|
||||||
|
|
||||||
@@ -66,23 +68,23 @@ val packJar by task<ShadowJar> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val proguard by task<ProGuardTask> {
|
val proguard by task<ProGuardTask> {
|
||||||
dependsOn(packJar)
|
dependsOn(relocatedJar)
|
||||||
configuration("main-kts.pro")
|
configuration("main-kts.pro")
|
||||||
|
|
||||||
injars(mapOf("filter" to "!META-INF/versions/**"), packJar.get().outputs.files)
|
injars(mapOf("filter" to "!META-INF/versions/**"), relocatedJar.get().outputs.files)
|
||||||
|
|
||||||
val outputJar = fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar")
|
val outputJar = fileFrom(buildDir, "libs", "$jarBaseName-$version-after-proguard.jar")
|
||||||
|
|
||||||
outjars(outputJar)
|
outjars(outputJar)
|
||||||
|
|
||||||
inputs.files(packJar.get().outputs.files.singleFile)
|
inputs.files(relocatedJar.get().outputs.files.singleFile)
|
||||||
outputs.file(outputJar)
|
outputs.file(outputJar)
|
||||||
|
|
||||||
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
libraryjars(mapOf("filter" to "!META-INF/versions/**"), proguardLibraryJars)
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultJar by task<Jar> {
|
val resultJar by task<Jar> {
|
||||||
val pack = if (kotlinBuildProperties.proguard) proguard else packJar
|
val pack = if (kotlinBuildProperties.proguard) proguard else relocatedJar
|
||||||
dependsOn(pack)
|
dependsOn(pack)
|
||||||
setupPublicJar(jarBaseName)
|
setupPublicJar(jarBaseName)
|
||||||
from {
|
from {
|
||||||
|
|||||||
Reference in New Issue
Block a user