From 7d391c5dd8fd05a7e9a21a6bedc898c2a53432d4 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 20 Sep 2016 21:57:05 +0000 Subject: Remove absolute paths from proto RELNOTES: Remove deprecated absolute paths in blaze IDE artifacts -- MOS_MIGRATED_REVID=133758389 --- .../android/ideinfo/ArtifactLocationConverter.java | 4 +- .../build/android/ideinfo/PackageParser.java | 65 ++-------------------- 2 files changed, 6 insertions(+), 63 deletions(-) (limited to 'src/tools/android/java/com/google/devtools') diff --git a/src/tools/android/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverter.java b/src/tools/android/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverter.java index 318807a1b8..c64b616478 100644 --- a/src/tools/android/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverter.java +++ b/src/tools/android/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverter.java @@ -40,7 +40,8 @@ public class ArtifactLocationConverter implements Converter { Path rootExecutionPathFragment = pathConverter.convert(values.next()); Path relPath = pathConverter.convert(values.next()); - // will be removed in a future release -- make it forward-compatible + // TODO: remove this support for old format after the next blaze release + @SuppressWarnings("unused") String root = values.hasNext() ? pathConverter.convert(values.next()).toString() : ""; if (values.hasNext()) { @@ -49,7 +50,6 @@ public class ArtifactLocationConverter implements Converter { boolean isSource = rootExecutionPathFragment.toString().isEmpty(); return ArtifactLocation.newBuilder() - .setRootPath(root) .setRootExecutionPathFragment(rootExecutionPathFragment.toString()) .setRelativePath(relPath.toString()) .setIsSource(isSource) 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 f982a3104d..a9a8ccebf9 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 @@ -16,7 +16,6 @@ package com.google.devtools.build.android.ideinfo; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; import com.google.common.util.concurrent.ListenableFuture; @@ -30,7 +29,6 @@ import com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterC import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionsBase; import com.google.devtools.common.options.OptionsParser; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -46,7 +44,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -72,14 +69,6 @@ public class PackageParser { help = "The path to the manifest file this parser writes to.") public Path outputManifest; - @Option(name = "sources_absolute_paths", - defaultValue = "null", - converter = PathListConverter.class, - category = "input", - help = "The absolute paths of the java source files. The expected format is a " - + "colon-separated list.") - public List sourcesAbsolutePaths; - @Option(name = "sources_execution_paths", defaultValue = "null", converter = PathListConverter.class, @@ -98,20 +87,10 @@ public class PackageParser { PackageParserOptions options = parseArgs(args); Preconditions.checkNotNull(options.outputManifest); - // temporary code to handle output from older builds - boolean oldFormat = options.sources == null; - if (oldFormat) { - Preconditions.checkNotNull(options.sourcesAbsolutePaths); - Preconditions.checkNotNull(options.sourcesExecutionPaths); - Preconditions.checkState( - options.sourcesAbsolutePaths.size() == options.sourcesExecutionPaths.size()); - convertFromOldFormat(options); - } - try { PackageParser parser = new PackageParser(PackageParserIoProvider.INSTANCE); Map outputMap = parser.parsePackageStrings(options.sources); - parser.writeManifest(outputMap, options.outputManifest, oldFormat); + parser.writeManifest(outputMap, options.outputManifest); } catch (Throwable e) { logger.log(Level.SEVERE, "Error parsing package strings", e); System.exit(1); @@ -119,43 +98,11 @@ public class PackageParser { System.exit(0); } - @VisibleForTesting - @Deprecated - protected static void convertFromOldFormat(PackageParserOptions options) { - options.sources = Lists.newArrayList(); - for (int i = 0; i < options.sourcesAbsolutePaths.size(); i++) { - options.sources.add(dummySourceFromOldFormat( - options.sourcesAbsolutePaths.get(i).toString(), - options.sourcesExecutionPaths.get(i).toString())); - } - } - - @Deprecated - private static ArtifactLocation dummySourceFromOldFormat( - String absolutePath, - String executionPath) { - if (!absolutePath.endsWith(executionPath)) { - throw new IllegalArgumentException( - String.format("Cannot parse root path from absolute path %s and execution path %s", - absolutePath, executionPath)); - } - String rootPath = absolutePath.substring(0, absolutePath.lastIndexOf(executionPath)); - return ArtifactLocation.newBuilder() - .setRelativePath(executionPath) - .setRootPath(rootPath) - .build(); - } - @Nonnull private static Path getExecutionPath(@Nonnull ArtifactLocation location) { return Paths.get(location.getRootExecutionPathFragment(), location.getRelativePath()); } - @Nonnull - private static Path getAbsolutePath(@Nonnull ArtifactLocation location) { - return Paths.get(location.getRootPath(), location.getRelativePath()); - } - @VisibleForTesting public static PackageParserOptions parseArgs(String[] args) { args = parseParamFileIfUsed(args); @@ -186,17 +133,13 @@ public class PackageParser { @VisibleForTesting public void writeManifest( @Nonnull Map sourceToPackageMap, - Path outputFile, - boolean oldFormat) + Path outputFile) throws IOException { PackageManifest.Builder builder = PackageManifest.newBuilder(); for (Entry entry : sourceToPackageMap.entrySet()) { JavaSourcePackage.Builder srcBuilder = JavaSourcePackage.newBuilder() - .setAbsolutePath(getAbsolutePath(entry.getKey()).toString()) - .setPackageString(entry.getValue()); - if (!oldFormat) { - srcBuilder.setArtifactLocation(entry.getKey()); - } + .setPackageString(entry.getValue()) + .setArtifactLocation(entry.getKey()); builder.addSources(srcBuilder.build()); } -- cgit v1.2.3