|
| 1 | +# Copyright (c) 2026 dexpace and Omar Aljarrah |
| 2 | +# |
| 3 | +# Licensed under the MIT License. See LICENSE in the project root. |
| 4 | +# SPDX-License-Identifier: MIT |
| 5 | + |
| 6 | +# Consumer ProGuard/R8 keep rules for sdk-core. |
| 7 | +# |
| 8 | +# R8 and the Android Gradle Plugin automatically apply any rules packaged under |
| 9 | +# META-INF/proguard/ in a dependency jar, so a downstream application that shrinks its |
| 10 | +# build inherits these without extra configuration. They protect the parts of the toolkit |
| 11 | +# that a shrinker cannot prove are reachable on its own: |
| 12 | +# |
| 13 | +# * the SPI seams that callers wire at runtime (the I/O provider, the transport clients, |
| 14 | +# the serde), whose implementations live in separate modules and are referenced only |
| 15 | +# through interfaces; and |
| 16 | +# * the immutable HTTP models and the Tristate type, which Jackson and other reflective |
| 17 | +# serializers bind by walking constructors, accessors, and Kotlin metadata rather than |
| 18 | +# through direct call sites the shrinker can see. |
| 19 | + |
| 20 | +# --- SPI contracts wired at runtime -------------------------------------------------- |
| 21 | + |
| 22 | +# The single I/O seam. Io.installProvider(...) is the documented entry point and IoProvider |
| 23 | +# is implemented in an adapter module, so keep both surfaces intact. |
| 24 | +-keep class org.dexpace.sdk.core.io.Io { *; } |
| 25 | +-keep class org.dexpace.sdk.core.io.IoProvider { *; } |
| 26 | + |
| 27 | +# Transport SPIs. Concrete transports (e.g. OkHttpTransport) are reached only through these |
| 28 | +# interfaces, so the methods a caller invokes must survive. |
| 29 | +-keep class org.dexpace.sdk.core.client.HttpClient { *; } |
| 30 | +-keep class org.dexpace.sdk.core.client.AsyncHttpClient { *; } |
| 31 | + |
| 32 | +# Serde SPI. JacksonSerde and any other implementation are reached through these interfaces. |
| 33 | +-keep class org.dexpace.sdk.core.serde.Serde { *; } |
| 34 | +-keep class org.dexpace.sdk.core.serde.Serializer { *; } |
| 35 | +-keep class org.dexpace.sdk.core.serde.Deserializer { *; } |
| 36 | + |
| 37 | +# --- Immutable HTTP models and their builders ---------------------------------------- |
| 38 | + |
| 39 | +# Request / Response and their nested builders are constructed and read reflectively by |
| 40 | +# serializers and assertion frameworks; preserving every member keeps the public surface |
| 41 | +# (factories, builder fluents, component accessors) callable after shrinking. |
| 42 | +-keep class org.dexpace.sdk.core.http.request.Request { *; } |
| 43 | +-keep class org.dexpace.sdk.core.http.request.Request$RequestBuilder { *; } |
| 44 | +-keep class org.dexpace.sdk.core.http.request.RequestBody { *; } |
| 45 | +-keep class org.dexpace.sdk.core.http.request.Method { *; } |
| 46 | +-keep class org.dexpace.sdk.core.http.response.Response { *; } |
| 47 | +-keep class org.dexpace.sdk.core.http.response.Response$ResponseBuilder { *; } |
| 48 | +-keep class org.dexpace.sdk.core.http.response.ResponseBody { *; } |
| 49 | +-keep class org.dexpace.sdk.core.http.response.Status { *; } |
| 50 | +-keep class org.dexpace.sdk.core.http.common.Headers { *; } |
| 51 | +-keep class org.dexpace.sdk.core.http.common.Headers$Builder { *; } |
| 52 | +-keep class org.dexpace.sdk.core.http.common.MediaType { *; } |
| 53 | +-keep class org.dexpace.sdk.core.http.common.CommonMediaTypes { *; } |
| 54 | +-keep class org.dexpace.sdk.core.http.common.Protocol { *; } |
| 55 | + |
| 56 | +# --- Tristate ------------------------------------------------------------------------ |
| 57 | + |
| 58 | +# Tristate models the absent / null / present distinction a serializer must reconstruct from |
| 59 | +# the wire. The custom Jackson binding (shipped by sdk-serde-jackson) checks the runtime type |
| 60 | +# of each variant, so the sealed hierarchy and the Present payload accessor must remain. |
| 61 | +-keep class org.dexpace.sdk.core.serde.Tristate { *; } |
| 62 | +-keep class org.dexpace.sdk.core.serde.Tristate$Absent { *; } |
| 63 | +-keep class org.dexpace.sdk.core.serde.Tristate$Null { *; } |
| 64 | +-keep class org.dexpace.sdk.core.serde.Tristate$Present { *; } |
| 65 | + |
| 66 | +# Kotlin emits @Metadata on every class; reflective Kotlin tooling (including Jackson's Kotlin |
| 67 | +# module) reads it to recover constructor parameter names and nullability. Strip it and |
| 68 | +# 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. |
| 73 | +-keepattributes RuntimeVisibleAnnotations,AnnotationDefault |
| 74 | +-keep class kotlin.Metadata { *; } |
0 commit comments