Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions KeepAnnotationsSample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ plugins {
* Register a new task that can generate the artifact with keep rules.

```kotlin
val outputJar = project.tasks.named<org.gradle.jvm.tasks.Jar>("jar").flatMap { task ->
task.archiveFile
val jarTask = project.tasks.named<org.gradle.jvm.tasks.Jar>("jar")
val outputJar = jarTask.flatMap { it.archiveFile }
val outputFile = jarTask.flatMap { it.archiveFileName }.map { fileName ->
"keep${fileName.uppercaseFirstChar()}"
}

val outputFile = outputJar.map { file -> "keep${file.asFile.name.uppercaseFirstChar()}" }

// Register the JAR transform for extracting keep rules.
val artifactTask = annotationKeep.registerJavaArchiveTransform(
taskName = "keepRulesJar",
Expand All @@ -54,7 +54,7 @@ val artifactTask = annotationKeep.registerJavaArchiveTransform(
// Register the new artifact.
project.configurations.configureEach {
if (name == "apiElements" || name == "runtimeElements") {
outgoing.artifact(artifactTask)
outgoing.artifact(artifactTask.flatMap { it.outputJar })
}
}
```
1 change: 0 additions & 1 deletion KeepAnnotationsSample/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.junit)
debugImplementation(libs.androidx.compose.ui.test.manifest)
Expand Down
6 changes: 3 additions & 3 deletions KeepAnnotationsSample/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "9.5.0-alpha04"
agp = "9.5.0-alpha05"
annotationKeep = "1.0.0-SNAPSHOT"
coreKtx = "1.19.0"
junit = "4.13.2"
Expand All @@ -9,8 +9,8 @@ lifecycleRuntimeKtx = "2.11.0"
activityCompose = "1.13.0"
kotlin = "2.4.20"
composeBom = "2026.08.00"
appcompat = "1.6.1"
material = "1.10.0"
appcompat = "1.8.0"
material = "1.14.0"
jetbrainsKotlinJvm = "2.4.20"

[libraries]
Expand Down
10 changes: 5 additions & 5 deletions KeepAnnotationsSample/java-library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ java {
targetCompatibility = JavaVersion.VERSION_11
}

val outputJar = project.tasks.named<org.gradle.jvm.tasks.Jar>("jar").flatMap { task ->
task.archiveFile
val jarTask = project.tasks.named<org.gradle.jvm.tasks.Jar>("jar")
val outputJar = jarTask.flatMap { it.archiveFile }
val outputFile = jarTask.flatMap { it.archiveFileName }.map { fileName ->
"keep${fileName.uppercaseFirstChar()}"
}

val outputFile = outputJar.map { file -> "keep${file.asFile.name.uppercaseFirstChar()}" }

// Register the JAR transform for extracting keep rules.
val artifactTask = annotationKeep.registerJavaArchiveTransform(
taskName = "keepRulesJar",
Expand All @@ -27,7 +27,7 @@ val artifactTask = annotationKeep.registerJavaArchiveTransform(
// Register the new artifact.
project.configurations.configureEach {
if (name == "apiElements" || name == "runtimeElements") {
outgoing.artifact(artifactTask)
outgoing.artifact(artifactTask.flatMap { it.outputJar })
}
}

Expand Down
Loading