Skip to content

Commit 1f00d5a

Browse files
authored
Merge pull request #54 from skydoves/dep/kotlinx-serialization
Shadow kotlinx.serialization to the compiler plugin
2 parents cb90ad7 + e9db28a commit 1f00d5a

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kotlin = "2.2.21"
55
dokka = "2.1.0"
66
jvmTarget = "17"
77
kotlinxCollectionsImmutable = "0.4.0"
8-
kotlinxSerialization = "1.8.0"
8+
kotlinxSerialization = "1.9.0"
99
kotlinBinaryCompatibility = "0.18.1"
1010
lintApi = "31.13.0"
1111
nexusPlugin = "0.34.0"
@@ -15,6 +15,7 @@ androidxComposeBom = "2025.10.01"
1515
jetbrains-compose = "1.9.2"
1616
compose-stability-analyzer = "0.5.2"
1717
spotless = "6.21.0"
18+
shadow = "8.1.1"
1819

1920
[libraries]
2021
androidx-compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compiler" }
@@ -49,3 +50,4 @@ compose-stability-analyzer = { id = "com.github.skydoves.compose.stability.analy
4950
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
5051
nexus-plugin = { id = "com.vanniktech.maven.publish", version.ref = "nexusPlugin" }
5152
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
53+
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }

stability-compiler/build.gradle.kts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
17+
import org.gradle.jvm.tasks.Jar
18+
1619
plugins {
1720
kotlin("jvm")
1821
alias(libs.plugins.kotlin.serialization)
22+
alias(libs.plugins.shadow)
1923
alias(libs.plugins.nexus.plugin)
2024
}
2125

@@ -47,4 +51,32 @@ dependencies {
4751
java {
4852
sourceCompatibility = JavaVersion.VERSION_11
4953
targetCompatibility = JavaVersion.VERSION_11
54+
}
55+
56+
tasks.shadowJar {
57+
archiveClassifier.set("all")
58+
configurations = listOf(project.configurations.runtimeClasspath.get())
59+
60+
// Don't relocate - K/Native compiler needs original package names
61+
// for example, relocate("kotlinx.serialization", "...")
62+
63+
exclude("META-INF/maven/**")
64+
exclude("META-INF/*.SF")
65+
exclude("META-INF/*.DSA")
66+
exclude("META-INF/*.RSA")
67+
}
68+
69+
// Make jar task produce the shadowJar content
70+
tasks.named<Jar>("jar") {
71+
dependsOn(tasks.shadowJar)
72+
doLast {
73+
val shadowTask = tasks.shadowJar.get()
74+
val shadowJarFile = shadowTask.archiveFile.get().asFile
75+
val jarFile = archiveFile.get().asFile
76+
77+
if (shadowJarFile.exists()) {
78+
shadowJarFile.copyTo(jarFile, overwrite = true)
79+
logger.lifecycle("Replaced ${jarFile.name} with shadowJar content")
80+
}
81+
}
5082
}

stability-gradle/src/main/kotlin/com/skydoves/compose/stability/gradle/StabilityAnalyzerGradlePlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
173173
val runtimeDependency = runtimeProject
174174
?: "$GROUP_ID:$RUNTIME_ARTIFACT_ID:$VERSION"
175175

176-
// Add runtime to all compiler plugin classpath configurations (not general compiler classpath)
176+
// Add runtime to all compiler plugin classpath configurations
177177
project.configurations.configureEach {
178178
if (name.contains("CompilerPluginClasspath", ignoreCase = true)) {
179179
project.dependencies.add(name, runtimeDependency)

0 commit comments

Comments
 (0)