aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/android/java/com')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/Converters.java10
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/LibraryRClassGeneratorAction.java23
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java26
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/ideinfo/JarFilter.java124
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/ideinfo/PackageParser.java26
5 files changed, 191 insertions, 18 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/Converters.java b/src/tools/android/java/com/google/devtools/build/android/Converters.java
index 63f59801aa..01342ac7df 100644
--- a/src/tools/android/java/com/google/devtools/build/android/Converters.java
+++ b/src/tools/android/java/com/google/devtools/build/android/Converters.java
@@ -19,6 +19,7 @@ import com.android.manifmerger.ManifestMerger2.MergeType;
import com.android.repository.Revision;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
import com.google.devtools.common.options.Converter;
import com.google.devtools.common.options.EnumConverter;
import com.google.devtools.common.options.OptionsParsingException;
@@ -33,6 +34,7 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nullable;
/**
* Some convenient converters used by android actions. Note: These are specific to android actions.
@@ -290,8 +292,16 @@ public final class Converters {
* Validating converter for a list of Paths.
* A Path is considered valid if it resolves to a file.
*/
+ @Deprecated
public static class PathListConverter implements Converter<List<Path>> {
+ public static List<Path> concatLists(@Nullable List<Path> a, @Nullable List<Path> b) {
+ if (a == null || a.isEmpty()) {
+ return (b == null || b.isEmpty()) ? ImmutableList.of() : b;
+ }
+ return (b == null || b.isEmpty()) ? a : ImmutableList.copyOf(Iterables.concat(a, b));
+ }
+
private final PathConverter baseConverter;
public PathListConverter() {
diff --git a/src/tools/android/java/com/google/devtools/build/android/LibraryRClassGeneratorAction.java b/src/tools/android/java/com/google/devtools/build/android/LibraryRClassGeneratorAction.java
index ec41103b08..9709583dda 100644
--- a/src/tools/android/java/com/google/devtools/build/android/LibraryRClassGeneratorAction.java
+++ b/src/tools/android/java/com/google/devtools/build/android/LibraryRClassGeneratorAction.java
@@ -22,6 +22,7 @@ import com.google.devtools.build.android.Converters.PathListConverter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import java.io.IOException;
@@ -68,15 +69,32 @@ public class LibraryRClassGeneratorAction {
public String packageForR;
@Option(
- name = "symbols",
+ name = "symbol",
+ allowMultiple = true,
defaultValue = "",
- converter = PathListConverter.class,
+ converter = PathConverter.class,
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
category = "config",
help = "Parsed symbol binaries to write as R classes."
)
public List<Path> symbols;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
+ name = "symbols",
+ defaultValue = "",
+ converter = PathListConverter.class,
+ deprecationWarning = "Deprecated in favour of \"--symbol\"",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ category = "config",
+ help = "Parsed symbol binaries to write as R classes.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
+ )
+ public List<Path> deprecatedSymbols;
}
public static void main(String[] args) throws Exception {
@@ -87,6 +105,7 @@ public class LibraryRClassGeneratorAction {
optionsParser.parseAndExitUponError(args);
AaptConfigOptions aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class);
Options options = optionsParser.getOptions(Options.class);
+ options.symbols = PathListConverter.concatLists(options.symbols, options.deprecatedSymbols);
logger.fine(
String.format("Option parsing finished at %sms", timer.elapsed(TimeUnit.MILLISECONDS)));
try (ScopedTemporaryDirectory scopedTmp =
diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java
index b6ae74ede9..dbf10163ac 100644
--- a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java
+++ b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java
@@ -32,6 +32,7 @@ import com.google.devtools.common.options.Converters.CommaSeparatedOptionListCon
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import java.io.FileInputStream;
@@ -63,7 +64,7 @@ import org.xml.sax.SAXException;
* --resources path to processed resources zip
* --rTxt path to processed resources R.txt
* --primaryManifest path to processed resources AndroidManifest.xml
- * --dependencyManifests paths to dependency library manifests
+ * --dependencyManifest path to dependency library manifest (repeated flag)
* --shrunkResourceApk path to write shrunk ap_
* --shrunkResources path to write shrunk resources zip
* </pre>
@@ -130,15 +131,32 @@ public class ResourceShrinkerAction {
public Path primaryManifest;
@Option(
+ name = "dependencyManifest",
+ allowMultiple = true,
+ defaultValue = "",
+ category = "input",
+ converter = PathConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "Paths to the manifests of the dependencies. Specify one path per flag."
+ )
+ public List<Path> dependencyManifests;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "dependencyManifests",
defaultValue = "",
category = "input",
converter = PathListConverter.class,
+ deprecationWarning = "Deprecated in favour of \"--dependencyManifest\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
- help = "A list of paths to the manifests of the dependencies."
+ help = "A list of paths to the manifests of the dependencies.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> dependencyManifests;
+ public List<Path> deprecatedDependencyManifests;
@Option(
name = "resourcePackages",
@@ -236,6 +254,8 @@ public class ResourceShrinkerAction {
optionsParser.parseAndExitUponError(args);
aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class);
options = optionsParser.getOptions(Options.class);
+ options.dependencyManifests = PathListConverter.concatLists(
+ options.dependencyManifests, options.deprecatedDependencyManifests);
AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger);
// Setup temporary working directories.
diff --git a/src/tools/android/java/com/google/devtools/build/android/ideinfo/JarFilter.java b/src/tools/android/java/com/google/devtools/build/android/ideinfo/JarFilter.java
index 604193eb77..a1678a6d00 100644
--- a/src/tools/android/java/com/google/devtools/build/android/ideinfo/JarFilter.java
+++ b/src/tools/android/java/com/google/devtools/build/android/ideinfo/JarFilter.java
@@ -34,6 +34,7 @@ import com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterC
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import java.io.BufferedReader;
@@ -65,48 +66,124 @@ public final class JarFilter {
/** The options for a {@JarFilter} action. */
public static final class JarFilterOptions extends OptionsBase {
@Option(
+ name = "filter_jar",
+ allowMultiple = true,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ help =
+ "Paths to target output jars to filter for generated sources. You may use this flag "
+ + "multiple times, specify each path with a separate instance of the flag."
+ )
+ public List<Path> filterJars;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "filter_jars",
+ deprecationWarning = "Deprecated in favour of \"--filter_jar\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "null",
converter = PathListConverter.class,
category = "input",
- help = "A list of the paths to target output jars to filter for generated sources."
+ help = "A list of the paths to target output jars to filter for generated sources.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> filterJars;
+ public List<Path> deprecatedFilterJars;
@Option(
+ name = "filter_source_jar",
+ allowMultiple = true,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ help =
+ "Paths to target output source jars to filter for generated sources. You may use this "
+ + "flag multiple times, specify each path with a separate instance of the flag."
+ )
+ public List<Path> filterSourceJars;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "filter_source_jars",
+ deprecationWarning = "Deprecated in favour of \"--filter_source_jar\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "null",
converter = PathListConverter.class,
category = "input",
- help = "A list of the paths to target output source jars to filter for generated sources."
+ help = "A list of the paths to target output source jars to filter for generated sources.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> filterSourceJars;
+ public List<Path> deprecatedFilterSourceJars;
+
+ @Option(
+ name = "keep_java_file",
+ allowMultiple = true,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ help =
+ "Path of target input java files to keep. You may use this flag multiple times, "
+ + "specify each path with a separate instance of the flag."
+ )
+ public List<Path> keepJavaFiles;
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
@Option(
name = "keep_java_files",
+ deprecationWarning = "Deprecated in favour of \"--keep_java_file\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "null",
converter = PathListConverter.class,
category = "input",
- help = "A list of target input java files to keep."
+ help = "A list of target input java files to keep.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> keepJavaFiles;
+ public List<Path> deprecatedKeepJavaFiles;
@Option(
+ name = "keep_source_jar",
+ allowMultiple = true,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ help =
+ "Path of target input .srcjar files to keep. You may use this flag multiple times, "
+ + "specify each path with a separate instance of the flag."
+ )
+ public List<Path> keepSourceJars;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "keep_source_jars",
+ deprecationWarning = "Deprecated in favour of \"--keep_source_jar\"",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
defaultValue = "null",
converter = PathListConverter.class,
category = "input",
- help = "A list of target input .srcjar files to keep."
+ help = "A list of target input .srcjar files to keep.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> keepSourceJars;
+ public List<Path> deprecatedKeepSourceJars;
@Option(
name = "filtered_jar",
@@ -135,6 +212,21 @@ public final class JarFilter {
@Deprecated
@Option(
+ name = "jar",
+ allowMultiple = true,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ help = "A list of the paths to jars to filter for generated sources."
+ )
+ public List<Path> jars;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "jars",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
@@ -143,7 +235,7 @@ public final class JarFilter {
category = "input",
help = "A list of the paths to jars to filter for generated sources."
)
- public List<Path> jars;
+ public List<Path> deprecatedJars;
@Deprecated
@Option(
@@ -235,10 +327,20 @@ public final class JarFilter {
args = parseParamFileIfUsed(args);
OptionsParser optionsParser = OptionsParser.newOptionsParser(JarFilterOptions.class);
optionsParser.parseAndExitUponError(args);
+ JarFilterOptions options = optionsParser.getOptions(JarFilterOptions.class);
+ options.filterJars = PathListConverter.concatLists(
+ options.filterJars, options.deprecatedFilterJars);
+ options.filterSourceJars = PathListConverter.concatLists(
+ options.filterSourceJars, options.deprecatedFilterSourceJars);
+ options.keepJavaFiles = PathListConverter.concatLists(
+ options.keepJavaFiles, options.deprecatedKeepJavaFiles);
+ options.keepSourceJars = PathListConverter.concatLists(
+ options.keepSourceJars, options.deprecatedKeepSourceJars);
+ options.jars = PathListConverter.concatLists(
+ options.jars, options.deprecatedJars);
// Migrate options from v1 jar filter
- JarFilterOptions options = optionsParser.getOptions(JarFilterOptions.class);
- if (options.filterJars == null && options.jars != null) {
+ if (options.filterJars.isEmpty() && !options.jars.isEmpty()) {
options.filterJars = options.jars;
}
if (options.filteredJar == null && options.output != null) {
diff --git a/src/tools/android/java/com/google/devtools/build/android/ideinfo/PackageParser.java b/src/tools/android/java/com/google/devtools/build/android/ideinfo/PackageParser.java
index e857133808..9c3db72c6c 100644
--- a/src/tools/android/java/com/google/devtools/build/android/ideinfo/PackageParser.java
+++ b/src/tools/android/java/com/google/devtools/build/android/ideinfo/PackageParser.java
@@ -29,6 +29,7 @@ import com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterC
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
import java.io.BufferedReader;
@@ -81,17 +82,36 @@ public class PackageParser {
public Path outputManifest;
@Option(
+ name = "sources_execution_path",
+ allowMultiple = true,
+ defaultValue = "null",
+ converter = PathConverter.class,
+ category = "input",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help =
+ "The execution paths of the java source files. You may use this flag multiple times, "
+ + "each instance should specify one path."
+ )
+ public List<Path> sourcesExecutionPaths;
+
+ // TODO(laszlocsomor): remove this flag after 2018-01-31 (about 6 months from now). Everyone
+ // should have updated to newer Bazel versions by then.
+ @Deprecated
+ @Option(
name = "sources_execution_paths",
defaultValue = "null",
+ deprecationWarning = "Deprecated in favour of \"--sources_execution_path\"",
converter = PathListConverter.class,
category = "input",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help =
"The execution paths of the java source files. The expected format is a "
- + "colon-separated list."
+ + "colon-separated list.",
+ metadataTags = {OptionMetadataTag.DEPRECATED}
)
- public List<Path> sourcesExecutionPaths;
+ public List<Path> deprecatedSourcesExecutionPaths;
}
private static final Logger logger = Logger.getLogger(PackageParser.class.getName());
@@ -102,6 +122,8 @@ public class PackageParser {
public static void main(String[] args) throws Exception {
PackageParserOptions options = parseArgs(args);
Preconditions.checkNotNull(options.outputManifest);
+ options.sourcesExecutionPaths = PathListConverter.concatLists(
+ options.sourcesExecutionPaths, options.deprecatedSourcesExecutionPaths);
try {
PackageParser parser = new PackageParser(PackageParserIoProvider.INSTANCE);