Skip to content

Commit

Permalink
Merge pull request #213 from skydoves/proguard/ktor
Browse files Browse the repository at this point in the history
Add proguard rules and configure kmp hierachy for ktor
  • Loading branch information
skydoves authored Nov 10, 2023
2 parents 1d41892 + 2b78677 commit ff318c8
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 165 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ jobs:
- name: Build with Gradle
run: |
./gradlew --scan --stacktrace \
assemble -x :baselineprofile:pixel6api31Setup -x :baselineprofile:pixel6api31NonMinifiedReleaseAndroidTest -x :baselineprofile:collectNonMinifiedReleaseBaselineProfile
assembleDebug -x :baselineprofile:pixel6api31Setup -x :baselineprofile:pixel6api31NonMinifiedReleaseAndroidTest -x :baselineprofile:collectNonMinifiedReleaseBaselineProfile
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation(libs.moshi)
ksp(libs.moshi.codegen)

implementation(libs.okhttp)
implementation(libs.ktor.negotiation)
implementation(libs.ktor.okhttp)
implementation(libs.ktor.json)
Expand Down
6 changes: 2 additions & 4 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# TODO: Waiting for new retrofit release to remove these rules
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
# R8 full mode strips signatures from non-kept items.
-dontobfuscate
108 changes: 49 additions & 59 deletions app/src/release/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions sandwich-ktor/api/android/sandwich-ktor.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public final class com/skydoves/sandwich/ktor/ApiResponseExtensionKt {
public static final fun bodyChannel (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun bodyString (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun bodyString$default (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun getHeaders (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lio/ktor/http/Headers;
public static final fun getHeaders (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/http/Headers;
public static final fun getHttpResponse (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/client/statement/HttpResponse;
public static final fun getPayloadResponse (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lio/ktor/client/statement/HttpResponse;
public static final fun getStatusCode (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getStatusCode (Lcom/skydoves/sandwich/ApiResponse$Success;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getStatusCode (Lio/ktor/client/statement/HttpResponse;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getTagResponse (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/client/statement/HttpResponse;
}

public synthetic class com/skydoves/sandwich/ktor/ApiResponseExtensionKt$EntriesMappings {
public static final synthetic field entries$0 Lkotlin/enums/EnumEntries;
}

18 changes: 18 additions & 0 deletions sandwich-ktor/api/jvm/sandwich-ktor.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public final class com/skydoves/sandwich/ktor/ApiResponseExtensionKt {
public static final fun bodyChannel (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun bodyString (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun bodyString$default (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;Ljava/nio/charset/Charset;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun getHeaders (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lio/ktor/http/Headers;
public static final fun getHeaders (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/http/Headers;
public static final fun getHttpResponse (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/client/statement/HttpResponse;
public static final fun getPayloadResponse (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lio/ktor/client/statement/HttpResponse;
public static final fun getStatusCode (Lcom/skydoves/sandwich/ApiResponse$Failure$Error;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getStatusCode (Lcom/skydoves/sandwich/ApiResponse$Success;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getStatusCode (Lio/ktor/client/statement/HttpResponse;)Lcom/skydoves/sandwich/StatusCode;
public static final fun getTagResponse (Lcom/skydoves/sandwich/ApiResponse$Success;)Lio/ktor/client/statement/HttpResponse;
}

public synthetic class com/skydoves/sandwich/ktor/ApiResponseExtensionKt$EntriesMappings {
public static final synthetic field entries$0 Lkotlin/enums/EnumEntries;
}

94 changes: 43 additions & 51 deletions sandwich-ktor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
import com.github.skydoves.sandwich.Configuration

plugins {
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.kotlin.multiplatform.get().pluginId)
id(libs.plugins.kotlin.serialization.get().pluginId)
id(libs.plugins.nexus.plugin.get().pluginId)
java
id(libs.plugins.baseline.profile.get().pluginId)
}

apply(from = "${rootDir}/scripts/publish-module.gradle.kts")
Expand All @@ -33,18 +34,30 @@ mavenPublishing {
}

kotlin {
jvmToolchain(libs.versions.jvmTarget.get().toInt())
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
macosArm64(),
macosX64(),
).forEach {
it.binaries.framework {
baseName = "common"
}
}

jvm {
libs.versions.jvmTarget.get().toInt()
compilations.all {
kotlinOptions.jvmTarget = libs.versions.jvmTarget.get()
}
withJava()
}
iosX64()
iosArm64()
iosSimulatorArm64()
macosArm64()
macosX64()

androidTarget {
publishLibraryVariants("release")
}

applyDefaultHierarchyTemplate()

sourceSets {
all {
Expand All @@ -57,55 +70,34 @@ kotlin {
implementation(libs.coroutines)
}
}
}

val commonTest by getting {
dependencies {
}
}
explicitApi()
}

val jvmMain by getting
val jvmTest by getting
android {
compileSdk = Configuration.compileSdk
namespace = "com.skydoves.sandwich.ktor"
defaultConfig {
minSdk = Configuration.minSdk
consumerProguardFiles("consumer-rules.pro")
}

val appleMain by creating {
dependsOn(commonMain)
}
val macosArm64Main by getting {
dependsOn(appleMain)
}
val macosX64Main by getting {
dependsOn(appleMain)
}
val iosSimulatorArm64Main by getting {
dependsOn(appleMain)
}
val iosArm64Main by getting {
dependsOn(appleMain)
}
val iosX64Main by getting {
dependsOn(appleMain)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

val appleTest by creating {
dependsOn(commonTest)
}
val iosArm64Test by getting {
dependsOn(appleTest)
}
val iosX64Test by getting {
dependsOn(appleTest)
}
val iosSimulatorArm64Test by getting {
dependsOn(appleTest)
}
val macosX64Test by getting {
dependsOn(appleTest)
}
val macosArm64Test by getting {
dependsOn(appleTest)
}
baselineProfile {
baselineProfileOutputDir = "../../src/androidMain"
filter {
include("com.skydoves.sandwich.ktor.**")
}
}

explicitApi()
dependencies {
baselineProfile(project(":baselineprofile"))
}

java {
Expand Down
14 changes: 14 additions & 0 deletions sandwich-ktor/src/androidMain/baseline-prof.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;-><clinit>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;-><init>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;->suspendResponseConverter(Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$SuspendResponseConverter;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;-><init>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;->create()Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;-><init>(Lde/jensklingenberg/ktorfit/internal/TypeData;)V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;->convert(Lde/jensklingenberg/ktorfit/converter/KtorfitResult;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;->convert(Lio/ktor/client/statement/HttpResponse;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1$convert$1;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1$convert$1;-><init>(Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;Lkotlin/coroutines/Continuation;)V
2 changes: 2 additions & 0 deletions sandwich-ktorfit/src/androidMain/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# R8 full mode strips signatures from non-kept items.
-dontwarn org.slf4j.impl.StaticLoggerBinder
4 changes: 4 additions & 0 deletions sandwich/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ baselineProfile {
baselineProfileOutputDir = "../../src/androidMain"
filter {
include("com.skydoves.sandwich.**")
exclude("com.skydoves.sandwich.sandwichdemo.**")
exclude("com.skydoves.sandwich.retrofit.**")
exclude("com.skydoves.sandwich.ktor.**")
exclude("com.skydoves.sandwich.ktorfit.**")
}
}

Expand Down
49 changes: 0 additions & 49 deletions sandwich/src/androidMain/baseline-prof.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,6 @@ HSPLcom/skydoves/sandwich/SandwichInitializer;->getSandwichFailureMappers()Ljava
HSPLcom/skydoves/sandwich/SandwichInitializer;->getSandwichOperators()Ljava/util/List;
HSPLcom/skydoves/sandwich/SandwichInitializer;->getSandwichScope()Lkotlinx/coroutines/CoroutineScope;
HSPLcom/skydoves/sandwich/SandwichInitializer;->getSuccessCodeRange()Lkotlin/ranges/IntRange;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;-><clinit>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;-><init>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;->suspendResponseConverter(Lde/jensklingenberg/ktorfit/internal/TypeData;Lde/jensklingenberg/ktorfit/Ktorfit;)Lde/jensklingenberg/ktorfit/converter/Converter$SuspendResponseConverter;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;-><init>()V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$Companion;->create()Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;-><init>(Lde/jensklingenberg/ktorfit/internal/TypeData;)V
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;->convert(Lde/jensklingenberg/ktorfit/converter/KtorfitResult;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;->convert(Lio/ktor/client/statement/HttpResponse;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1$convert$1;
HSPLcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1$convert$1;-><init>(Lcom/skydoves/sandwich/ktorfit/ApiResponseConverterFactory$suspendResponseConverter$1;Lkotlin/coroutines/Continuation;)V
Lcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;-><clinit>()V
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;-><init>(Lkotlinx/coroutines/CoroutineScope;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;-><init>(Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;->get(Ljava/lang/reflect/Type;[Ljava/lang/annotation/Annotation;Lretrofit2/Retrofit;)Lretrofit2/CallAdapter;
Lcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;-><init>()V
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;->create$default(Lcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;Lkotlinx/coroutines/CoroutineScope;ILjava/lang/Object;)Lcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;
HSPLcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory$Companion;->create(Lkotlinx/coroutines/CoroutineScope;)Lcom/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory;
Lcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter;-><init>(Ljava/lang/reflect/Type;Lkotlinx/coroutines/CoroutineScope;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter;->adapt(Lretrofit2/Call;)Ljava/lang/Object;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter;->adapt(Lretrofit2/Call;)Lretrofit2/Call;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter;->responseType()Ljava/lang/reflect/Type;
Lcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate;-><init>(Lretrofit2/Call;Lkotlinx/coroutines/CoroutineScope;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate;->enqueueImpl(Lretrofit2/Callback;)V
Lcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate$enqueueImpl$1;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate$enqueueImpl$1;-><init>(Lcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate;Lretrofit2/Callback;Lkotlin/coroutines/Continuation;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate$enqueueImpl$1;->create(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
HPLcom/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate$enqueueImpl$1;->invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
Lcom/skydoves/sandwich/retrofit/adapters/internal/CallDelegate;
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/CallDelegate;-><init>(Lretrofit2/Call;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/CallDelegate;->enqueue(Lretrofit2/Callback;)V
HSPLcom/skydoves/sandwich/retrofit/adapters/internal/CallDelegate;->getProxy()Lretrofit2/Call;
Lcom/skydoves/sandwich/retrofit/datasource/DataSource;
Lcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory;
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory;-><clinit>()V
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory;-><init>()V
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
Lcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory$Companion;
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory$Companion;-><init>()V
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory$Companion;-><init>(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
HSPLcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory$Companion;->create()Lcom/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory;
Lcom/skydoves/sandwichdemo/DataBinderMapperImpl;
HSPLcom/skydoves/sandwichdemo/DataBinderMapperImpl;-><clinit>()V
HSPLcom/skydoves/sandwichdemo/DataBinderMapperImpl;-><init>()V
Expand Down

0 comments on commit ff318c8

Please sign in to comment.