diff options
author | laszlocsomor <laszlocsomor@google.com> | 2017-07-14 17:06:05 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-07-17 10:10:39 +0200 |
commit | a76c94be7c56b93fc5a2f9ececfba7ac1f61f69c (patch) | |
tree | 09c1ab12473aa8ac6b453b24db098e8b347fe7a9 /src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java | |
parent | 681b8174d5ae989cf9489716e4c15a54c2d36bc4 (diff) |
CustomCommandLine.Builder: clean up its interface
In this commit:
- remove unused methods and classes
- turn CustomCommandLine.ArgvFragment into an
interface
- remove the
CustomCommandLine.TreeFileArtifactArgvFragment
abstract class; it only had one remaining
subclass
- add @Nullable annotations where nulls are fine
- add Precondition checks for non-nullable args
- simplify the interface by removing add* methods
that can be composed of other add* methods; this
makes it easier to see what the callers do with
the Builder
- remove add* methods that add a single argument
followed by a list of other elements (or a
joined string of them); these had a bug in that
they didn't check if the collection was empty
(only that it was not null), and if it was empty
then the single argument was still added though
it was not followed by any value
- fix call sites of add* methods where we
previously could have added a flag with an empty
collection
- audit every affected call site
RELNOTES: none
PiperOrigin-RevId: 161957521
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java index 60d414ddc4..ef077eb5dc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ResourceShrinkerActionBuilder.java @@ -165,10 +165,10 @@ public class ResourceShrinkerActionBuilder { inputs.add(sdk.getAndroidJar()); if (!uncompressedExtensions.isEmpty()) { - commandLine.addJoinStrings("--uncompressedExtensions", ",", uncompressedExtensions); + commandLine.add("--uncompressedExtensions").addJoinStrings(",", uncompressedExtensions); } if (!assetsToIgnore.isEmpty()) { - commandLine.addJoinStrings("--assetsToIgnore", ",", assetsToIgnore); + commandLine.add("--assetsToIgnore").addJoinStrings(",", assetsToIgnore); } if (ruleContext.getConfiguration().getCompilationMode() != CompilationMode.OPT) { commandLine.add("--debug"); @@ -201,14 +201,18 @@ public class ResourceShrinkerActionBuilder { inputs.add(primaryResources.getManifest()); List<Artifact> dependencyManifests = getManifests(dependencyResources); - commandLine.addJoinExecPaths( - "--dependencyManifests", - ruleContext.getConfiguration().getHostPathSeparator(), - dependencyManifests); + if (!dependencyManifests.isEmpty()) { + commandLine + .add("--dependencyManifests") + .addJoinExecPaths( + ruleContext.getConfiguration().getHostPathSeparator(), dependencyManifests); + } inputs.addAll(dependencyManifests); List<String> resourcePackages = getResourcePackages(primaryResources, dependencyResources); - commandLine.addJoinStrings("--resourcePackages", ",", resourcePackages); + if (!resourcePackages.isEmpty()) { + commandLine.add("--resourcePackages").addJoinStrings(",", resourcePackages); + } commandLine.addExecPath("--shrunkResourceApk", resourceApkOut); outputs.add(resourceApkOut); |