Skip to content

Simplify proguard handling logic. #2744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2021
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
49 changes: 0 additions & 49 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,55 +101,6 @@ configure(subprojects) {
apply plugin: "org.jlleitschuh.gradle.ktlint"
}


/**
* Configure "Preguarding" for the subprojects.
*
* <p> The way it works is every library subproject that has the android plugin applied and:
*
* <ul>
* <li>Contains a file named "preguard.txt" will get proguarded using that file as proguard
* configuration in release mode.
* <li>Contains a file named "proguard.txt" will ship this file inside its release aar as a
* consumer proguard file.
*/
configure(subprojects) {
def PREGUARD_FILE_NAME = 'preguard.txt'
def CONSUMER_PROGUARD_FILE_NAME = 'proguard.txt'
afterEvaluate { Project sub ->

if (sub.plugins.findPlugin('com.android.library') == null) {
return
}

boolean skipPreguard = sub.getProperties().getOrDefault('firebaseSkipPreguard', 'true').toBoolean()
def defaultPreguard = rootProject.getProperties().getOrDefault('firebaseDefaultPreguardFile', 'default-preguard.txt')

if(!skipPreguard) {

sub.android {
buildTypes {
release {
// default behavior for minifyEnabled is:
// useProguard true
// shrinkResources false
minifyEnabled true
proguardFiles file(defaultPreguard), sub.file(PREGUARD_FILE_NAME)
}
}
}
}

// Ship consumer proguard config if it exists.
if (sub.file(CONSUMER_PROGUARD_FILE_NAME).exists()) {
sub.android { buildTypes { release { consumerProguardFiles 'proguard.txt' } } }
}

sub.apply plugin: LicenseResolverPlugin
}
}


task clean(type: Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.firebase.gradle.plugins.apiinfo.GetMetalavaJarTask;
import com.google.firebase.gradle.plugins.ci.Coverage;
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to the proguard logic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes and no :)

It used to live in the root project configuration alongside the proguard logic. So it makes sense to move it here

import java.io.File;
import java.nio.file.Paths;
import org.gradle.api.JavaVersion;
Expand All @@ -40,6 +41,7 @@ public class FirebaseLibraryPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.apply(ImmutableMap.of("plugin", "com.android.library"));
project.apply(ImmutableMap.of("plugin", LicenseResolverPlugin.class));

FirebaseLibraryExtension firebaseLibrary =
project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* GenerateLicensesTask} to create the artifacts necessary for our release.
* </ul>
*/
class LicenseResolverPlugin implements Plugin<Project> {
public class LicenseResolverPlugin implements Plugin<Project> {
private static final String[] ANDROID_PLUGINS = {
"com.android.application", "com.android.library", "com.android.test"
};
Expand Down
Empty file.
1 change: 1 addition & 0 deletions firebase-common/firebase-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
versionName version
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}
sourceSets {
androidTest {
Expand Down
412 changes: 0 additions & 412 deletions firebase-common/mapping.txt

This file was deleted.

1 change: 1 addition & 0 deletions firebase-components/firebase-components.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ android {
targetSdkVersion project.targetSdkVersion
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}

compileOptions {
Expand Down
Empty file.
32 changes: 0 additions & 32 deletions firebase-database-collection/preguard.txt

This file was deleted.

Empty file removed firebase-database/proguard.txt
Empty file.
1 change: 1 addition & 0 deletions firebase-firestore/firebase-firestore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ android {
versionName version
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}

sourceSets {
Expand Down
1 change: 1 addition & 0 deletions firebase-functions/firebase-functions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
versionName version
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}
sourceSets {
androidTest {
Expand Down
18 changes: 0 additions & 18 deletions firebase-inappmessaging-display/preguard.txt

This file was deleted.

Empty file.
1 change: 1 addition & 0 deletions firebase-inappmessaging/firebase-inappmessaging.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ android {
multiDexEnabled true
versionName version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}
sourceSets {
main {
Expand Down
Empty file.
20 changes: 0 additions & 20 deletions firebase-inappmessaging/preguard.txt

This file was deleted.

Empty file removed firebase-storage/mapping.txt
Empty file.
Empty file removed firebase-storage/proguard.txt
Empty file.
1 change: 1 addition & 0 deletions transport/transport-api/transport-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ android {
minSdkVersion 14
targetSdkVersion project.targetSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ android {
targetSdkVersion project.targetSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionName version
consumerProguardFiles 'proguard.txt'
}
compileOptions {
sourceCompatibility = '1.8'
Expand Down