Skip to content

Commit 91893b7

Browse files
author
berstanio
committed
Make ProguardCollector able to be disabled
1 parent a45363e commit 91893b7

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ moe {
180180
// whether code obfuscation is enabled. Ignored when `baseCfgFile` is specified. Default to `false`
181181
obfuscationEnabled = false
182182
183+
// whether proguard config collector is enabled. Default to `true`
184+
proguardCollectorEnabled = true
185+
183186
// exclude files from `-injars` config that will be processed by proguard
184187
excludeFiles = [
185188
'META-INF/*.SF',

src/main/java/org/moe/gradle/options/ProGuardOptions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import java.util.Arrays;
1010
import java.util.Collection;
11-
import java.util.HashSet;
1211
import java.util.LinkedHashSet;
1312
import java.util.Set;
1413

@@ -25,6 +24,7 @@ public class ProGuardOptions {
2524
private int level = LEVEL_APP;
2625
private boolean minifyEnabled = true;
2726
private boolean obfuscationEnabled = false;
27+
private boolean proguardCollectorEnabled = true;
2828
@NotNull
2929
@org.jetbrains.annotations.NotNull
3030
private Set<String> excludeFiles = new LinkedHashSet<>();
@@ -90,6 +90,15 @@ public void setObfuscationEnabled(boolean obfuscationEnabled) {
9090
this.obfuscationEnabled = obfuscationEnabled;
9191
}
9292

93+
public boolean isProguardCollectorEnabled () {
94+
return proguardCollectorEnabled;
95+
}
96+
97+
@IgnoreUnused
98+
public void setProguardCollectorEnabled (boolean proguardCollectorEnabled) {
99+
this.proguardCollectorEnabled = proguardCollectorEnabled;
100+
}
101+
93102
@NotNull
94103
@org.jetbrains.annotations.NotNull
95104
public Collection<String> getExcludeFiles() {

src/main/java/org/moe/gradle/tasks/R8.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class R8 extends AbstractBaseTask {
7272
private static final String CONVENTION_MAPPING_FILE = "mappingFile";
7373
private static final String CONVENTION_MINIFY_ENABLED = "minifyEnabled";
7474
private static final String CONVENTION_OBFUSCATION_ENABLED = "obfuscationEnabled";
75+
private static final String CONVENTION_COLLECTOR_ENABLED = "collectorEnabled";
7576
private static final String CONVENTION_DEBUG_ENABLED = "debugEnabled";
7677

7778
@Nullable
@@ -228,6 +229,19 @@ public boolean isObfuscationEnabled() {
228229
return getOrConvention(obfuscationEnabled, CONVENTION_OBFUSCATION_ENABLED);
229230
}
230231

232+
@Nullable
233+
private Boolean collectorEnabled;
234+
235+
@IgnoreUnused
236+
public void setCollectorEnabled(Boolean collectorEnabled) {
237+
this.collectorEnabled = collectorEnabled;
238+
}
239+
240+
@Input
241+
public boolean isCollectorEnabled() {
242+
return getOrConvention(collectorEnabled, CONVENTION_COLLECTOR_ENABLED);
243+
}
244+
231245
@Nullable
232246
private Boolean debugEnabled;
233247

@@ -336,9 +350,11 @@ private void composeConfigurationFile() {
336350
startSection(conf, "Appending from " + baseCfgFile);
337351
conf.append(FileUtils.read(baseCfgFile));
338352

339-
final File collectedConfig = getProguardCollectTaskDep().getOutCfgFile();
340-
startSection(conf, "Appending from " + collectedConfig);
341-
conf.append(FileUtils.read(collectedConfig));
353+
if (isCollectorEnabled()) {
354+
final File collectedConfig = getProguardCollectTaskDep().getOutCfgFile();
355+
startSection(conf, "Appending from " + collectedConfig);
356+
conf.append(FileUtils.read(collectedConfig));
357+
}
342358

343359
startSection(conf, "Shrinking & obfuscation flags");
344360
if (!isCustomisedBaseConfig()) {
@@ -513,6 +529,7 @@ protected final void setupMoeTask(final @NotNull SourceSet sourceSet, final @Not
513529
addConvention(CONVENTION_LOG_FILE, () -> resolvePathInBuildDir(out, "R8.log"));
514530
addConvention(CONVENTION_MINIFY_ENABLED, ext.proguard::isMinifyEnabled);
515531
addConvention(CONVENTION_OBFUSCATION_ENABLED, ext.proguard::isObfuscationEnabled);
532+
addConvention(CONVENTION_COLLECTOR_ENABLED, ext.proguard::isProguardCollectorEnabled);
516533
addConvention(CONVENTION_DEBUG_ENABLED, () -> mode.equals(Mode.DEBUG));
517534
}
518535
}

0 commit comments

Comments
 (0)