Skip to content

Commit d69e308

Browse files
committed
build: correct duplicate-merge comment and clarify global scope of shipped keep-rules
1 parent d8a4a74 commit d69e308

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

sdk-core/src/main/resources/META-INF/proguard/sdk-core.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,9 @@
6666
# Kotlin emits @Metadata on every class; reflective Kotlin tooling (including Jackson's Kotlin
6767
# module) reads it to recover constructor parameter names and nullability. Strip it and
6868
# data-class binding silently degrades, so keep the annotation across the toolkit.
69+
#
70+
# Scope note: `-keepattributes` is a global directive. Because this file ships under
71+
# META-INF/proguard, depending on sdk-core adds these attributes to the consumer's *entire*
72+
# program, not just the SDK's classes.
6973
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
7074
-keep class kotlin.Metadata { *; }

sdk-serde-jackson/src/main/resources/META-INF/proguard/sdk-serde-jackson.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
# conventional — and the only safe — consumer recommendation is to keep the databind, core, and
2121
# annotation packages wholesale, retain the attributes Jackson reflects over, and keep every
2222
# annotation enum intact.
23+
#
24+
# Scope note: because this file ships under META-INF/proguard, R8/AGP applies it to the consumer's
25+
# entire program, not just the SDK's classes. The wholesale Jackson `-keep` rules below therefore
26+
# exempt the consumer's *entire* Jackson surface from shrinking — including any Jackson the app uses
27+
# directly, elsewhere. The `-keepattributes` directive is likewise global: it adds these attributes
28+
# to the whole consumer build, not only to SDK classes. An app that wants tighter shrinking can
29+
# override these rules in its own configuration.
2330
-keepattributes Signature,*Annotation*,EnclosingMethod,InnerClasses
2431
-keep class com.fasterxml.jackson.databind.** { *; }
2532
-keep class com.fasterxml.jackson.core.** { *; }

sdk-shrink-test/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ val shippedConsumerRulePaths: List<String> =
8787
)
8888

8989
// Bundle the consumer program and its entire runtime classpath into one jar — the program R8 will
90-
// shrink. Service-loader manifests are concatenated; other duplicates (e.g. repeated module
91-
// metadata, signature files) are dropped so the merged jar stays valid.
90+
// shrink. `DuplicatesStrategy.EXCLUDE` keeps only the first occurrence of any duplicated path and
91+
// skips the rest; it does not merge. That includes service-loader manifests — colliding
92+
// `META-INF/services/<iface>` entries are NOT concatenated, only the first wins. It happens not to
93+
// matter for the current classpath (no colliding service files), but a future dependency that
94+
// ships one would need explicit concatenation (e.g. a Shadow `ServiceFileTransformer`) here.
9295
val buildShrinkInputJar by tasks.registering(Jar::class) {
9396
group = "shrink"
9497
description = "Bundles the consumer program and its runtime classpath into the R8 input jar."

sdk-shrink-test/src/main/kotlin/org/dexpace/sdk/shrinktest/ShrinkSurvivalApp.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ import org.dexpace.sdk.transport.okhttp.OkHttpTransport
2626
* seams — the same surface the shipped `META-INF/proguard` consumer rules protect — and prints
2727
* [SUCCESS_SENTINEL] on a clean run.
2828
*
29-
* The harness runs this twice: once from the un-shrunk jar to establish the baseline, and once
30-
* from the R8-shrunk jar. Because the shrunk run performs a real HTTP round-trip and a real JSON
31-
* round-trip, it proves not merely that the kept classes still exist but that their members
32-
* remain wired correctly after tree-shaking and (potential) renaming.
29+
* The harness runs this from the R8-shrunk jar. Because that run performs a real HTTP round-trip
30+
* and a real JSON round-trip, it proves not merely that the kept classes still exist but that their
31+
* members remain wired correctly after tree-shaking and (potential) renaming.
3332
*/
3433
public object ShrinkSurvivalApp {
3534
/** Printed verbatim to stdout once every exercise below has passed. */

0 commit comments

Comments
 (0)