diff options
Diffstat (limited to 'src')
8 files changed, 75 insertions, 274 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java index c7e3cd5613..9814a938ef 100644 --- a/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspect.java @@ -320,14 +320,6 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config outputBuilder.setLabel(base.getLabel().toString()); - outputBuilder.setBuildFile( - ruleContext - .getRule() - .getPackage() - .getBuildFile() - .getPath() - .toString()); - outputBuilder.setBuildFileArtifactLocation( makeArtifactLocation(ruleContext.getRule().getPackage())); @@ -458,8 +450,7 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config Root root = artifact.getRoot(); return Joiner.on(",").join( root.getExecPath().toString(), - artifact.getRootRelativePath().toString(), - root.getPath().toString() // Remove me once we remove ArtifactLocation root + artifact.getRootRelativePath().toString() ); } }; @@ -596,7 +587,6 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config private static ArtifactLocation makeArtifactLocation(Root root, PathFragment relativePath) { return ArtifactLocation.newBuilder() - .setRootPath(root.getPath().toString()) .setRootExecutionPathFragment(root.getExecPath().toString()) .setRelativePath(relativePath.toString()) .setIsSource(root.isSourceRoot()) @@ -605,7 +595,6 @@ public class AndroidStudioInfoAspect extends NativeAspectClass implements Config private static ArtifactLocation makeArtifactLocation(SourceDirectory resourceDir) { return ArtifactLocation.newBuilder() - .setRootPath(resourceDir.getRootPath().toString()) .setRootExecutionPathFragment(resourceDir.getRootExecutionPathFragment().toString()) .setRelativePath(resourceDir.getRelativePath().toString()) .setIsSource(resourceDir.isSource()) diff --git a/src/main/protobuf/android_studio_ide_info.proto b/src/main/protobuf/android_studio_ide_info.proto index fd5aa89372..3cc0806f93 100644 --- a/src/main/protobuf/android_studio_ide_info.proto +++ b/src/main/protobuf/android_studio_ide_info.proto @@ -21,9 +21,6 @@ option java_package = "com.google.devtools.build.lib.ideinfo.androidstudio"; message ArtifactLocation { - // deprecated -- this is not machine agnostic and will be removed in a future release - string root_path = 1 [deprecated=true]; - string relative_path = 2; bool is_source = 3; @@ -132,8 +129,6 @@ message RuleIdeInfo { string label = 1; Kind kind = 2 [deprecated=true]; - // deprecated -- this is not machine agnostic and will be removed in a future release - string build_file = 3 [deprecated=true]; repeated string dependencies = 4; // kind is one of {JAVA,ANDROID}_{LIBRARY,BINARY,TEST} and JAVA_IMPORT diff --git a/src/main/protobuf/package_manifest.proto b/src/main/protobuf/package_manifest.proto index 3ae7f46d09..aa017d410f 100644 --- a/src/main/protobuf/package_manifest.proto +++ b/src/main/protobuf/package_manifest.proto @@ -22,9 +22,6 @@ option java_package = "com.google.devtools.build.lib.ideinfo.androidstudio"; // TODO(bazel-team): support proto => proto dependencies and remove this duplication message ArtifactLocation { - // deprecated -- this is not machine agnostic and will be removed in a future release - string root_path = 1 [deprecated=true]; - string relative_path = 2; bool is_source = 3; @@ -33,8 +30,6 @@ message ArtifactLocation { } message JavaSourcePackage { - // deprecated -- this is not machine agnostic and will be removed in a future release - string absolute_path = 1 [deprecated=true]; string package_string = 2; ArtifactLocation artifact_location = 3; } diff --git a/src/test/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverterTest.java b/src/test/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverterTest.java index baa30494e2..f2628d2457 100644 --- a/src/test/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverterTest.java +++ b/src/test/java/com/google/devtools/build/android/ideinfo/ArtifactLocationConverterTest.java @@ -44,12 +44,11 @@ public class ArtifactLocationConverterTest { @Test public void testConverterSourceArtifact() throws Exception { ArtifactLocation parsed = converter.convert( - Joiner.on(",").join("", "test.java", "/usr/local/code") + Joiner.on(',').join("", "test.java") ); assertThat(parsed) .isEqualTo( ArtifactLocation.newBuilder() - .setRootPath(Paths.get("/usr/local/code").toString()) .setRelativePath(Paths.get("test.java").toString()) .setIsSource(true) .build()); @@ -58,12 +57,11 @@ public class ArtifactLocationConverterTest { @Test public void testConverterDerivedArtifact() throws Exception { ArtifactLocation parsed = converter.convert( - Joiner.on(",").join("bin", "java/com/test.java", "/usr/local/_tmp/code/bin") + Joiner.on(',').join("bin", "java/com/test.java") ); assertThat(parsed) .isEqualTo( ArtifactLocation.newBuilder() - .setRootPath(Paths.get("/usr/local/_tmp/code/bin").toString()) .setRootExecutionPathFragment(Paths.get("bin").toString()) .setRelativePath(Paths.get("java/com/test.java").toString()) .setIsSource(false) @@ -77,8 +75,9 @@ public class ArtifactLocationConverterTest { } @Test - public void testFutureFormat() throws Exception { - ArtifactLocation parsed = converter.convert("bin/out,java/com/test.java"); + public void testOldFormat() throws Exception { + ArtifactLocation parsed = converter + .convert("bin/out,java/com/test.java,/usr/local/_tmp/code/bin/out"); assertThat(parsed) .isEqualTo( ArtifactLocation.newBuilder() diff --git a/src/test/java/com/google/devtools/build/android/ideinfo/PackageParserTest.java b/src/test/java/com/google/devtools/build/android/ideinfo/PackageParserTest.java index b302641788..cfb8096ee0 100644 --- a/src/test/java/com/google/devtools/build/android/ideinfo/PackageParserTest.java +++ b/src/test/java/com/google/devtools/build/android/ideinfo/PackageParserTest.java @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterC import com.google.protobuf.MessageLite; import java.io.BufferedReader; import java.io.ByteArrayInputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -91,14 +90,12 @@ public class PackageParserTest { private static final ArtifactLocation DUMMY_SOURCE_ARTIFACT = ArtifactLocation.newBuilder() - .setRootPath("/usr/local/google/code") .setRelativePath("java/com/google/Foo.java") .setIsSource(true) .build(); private static final ArtifactLocation DUMMY_DERIVED_ARTIFACT = ArtifactLocation.newBuilder() - .setRootPath("/usr/local/_tmp/code/bin") .setRootExecutionPathFragment("bin") .setRelativePath("java/com/google/Bla.java") .setIsSource(false) @@ -124,10 +121,10 @@ public class PackageParserTest { "--output_manifest", "/tmp/out.manifest", "--sources", - Joiner.on(":").join( - ",java/com/google/Foo.java,/usr/local/google/code", - "bin,java/com/google/Bla.java,/usr/local/_tmp/code/bin" - )}; + Joiner.on(':').join( + ",java/com/google/Foo.java", + "bin/out,java/com/google/Bla.java") + }; PackageParser.PackageParserOptions options = PackageParser.parseArgs(args); assertThat(options.outputManifest.toString()) .isEqualTo(Paths.get("/tmp/out.manifest").toString()); @@ -135,15 +132,13 @@ public class PackageParserTest { assertThat(options.sources.get(0)) .isEqualTo( ArtifactLocation.newBuilder() - .setRootPath(Paths.get("/usr/local/google/code").toString()) .setRelativePath(Paths.get("java/com/google/Foo.java").toString()) .setIsSource(true) .build()); assertThat(options.sources.get(1)) .isEqualTo( ArtifactLocation.newBuilder() - .setRootPath(Paths.get("/usr/local/_tmp/code/bin").toString()) - .setRootExecutionPathFragment(Paths.get("bin").toString()) + .setRootExecutionPathFragment(Paths.get("bin/out").toString()) .setRelativePath(Paths.get("java/com/google/Bla.java").toString()) .setIsSource(false) .build()); @@ -220,8 +215,7 @@ public class PackageParserTest { public void testWriteEmptyMap() throws Exception { parser.writeManifest( Maps.<ArtifactLocation, String> newHashMap(), - Paths.get("/java/com/google/test.manifest"), - false); + Paths.get("/java/com/google/test.manifest")); assertThat(mockIoProvider.writer.toString()).isEmpty(); } @@ -233,21 +227,15 @@ public class PackageParserTest { DUMMY_DERIVED_ARTIFACT, "com.other" ); - parser.writeManifest(map, Paths.get("/java/com/google/test.manifest"), false); + parser.writeManifest(map, Paths.get("/java/com/google/test.manifest")); String writtenString = mockIoProvider.writer.toString(); assertThat(writtenString).contains(String.format( - "root_path: \"%s\"", - DUMMY_SOURCE_ARTIFACT.getRootPath())); - assertThat(writtenString).contains(String.format( "relative_path: \"%s\"", DUMMY_SOURCE_ARTIFACT.getRelativePath())); assertThat(writtenString).contains("package_string: \"com.google\""); assertThat(writtenString).contains(String.format( - "root_path: \"%s\"", - DUMMY_DERIVED_ARTIFACT.getRootPath())); - assertThat(writtenString).contains(String.format( "root_execution_path_fragment: \"%s\"", DUMMY_DERIVED_ARTIFACT.getRootExecutionPathFragment())); assertThat(writtenString).contains(String.format( @@ -258,74 +246,14 @@ public class PackageParserTest { @Test public void testHandlesOldFormat() throws Exception { - String[] args = - new String[] { - "--output_manifest", - "/tmp/out.manifest", - "--sources_absolute_paths", - "/usr/local/code/java/com/google/Foo.java" - + File.pathSeparator - + "/usr/local/code/java/com/google/Bla.java", - "--sources_execution_paths", - "java/com/google/Foo.java" + File.pathSeparator + "java/com/google/Bla.java" - }; - PackageParser.PackageParserOptions options = PackageParser.parseArgs(args); - assertThat(options.outputManifest.toString()) - .isEqualTo(Paths.get("/tmp/out.manifest").toString()); - assertThat(options.sourcesAbsolutePaths.get(0).toString()) - .isEqualTo(Paths.get("/usr/local/code/java/com/google/Foo.java").toString()); - assertThat(options.sourcesAbsolutePaths.get(1).toString()) - .isEqualTo(Paths.get("/usr/local/code/java/com/google/Bla.java").toString()); - - PackageParser.convertFromOldFormat(options); - assertThat(options.sources).hasSize(2); - assertThat(options.sources.get(0)) - .isEqualTo( - ArtifactLocation.newBuilder() - .setRootPath(Paths.get("/usr/local/code/").toString() + File.separator) - .setRelativePath(Paths.get("java/com/google/Foo.java").toString()) - .build()); - - mockIoProvider - .addSource(options.sources.get(0), - "package com.test;\n public class Bla {}\"") - .addSource(options.sources.get(1), - "package com.other;\n public class Foo {}\""); - - Map<ArtifactLocation, String> map = parser.parsePackageStrings(options.sources); - assertThat(map).hasSize(2); - assertThat(map).containsEntry(options.sources.get(0), "com.test"); - assertThat(map).containsEntry(options.sources.get(1), "com.other"); - - parser.writeManifest(map, options.outputManifest, true); - - String writtenString = mockIoProvider.writer.toString(); - assertThat(writtenString).doesNotContain("location"); - assertThat(writtenString) - .contains( - "absolute_path: \"" - + Paths.get("/usr/local/code/java/com/google/Foo.java") - .toString() - .replace("\\", "\\\\") - + "\""); - assertThat(writtenString) - .contains( - "absolute_path: \"" - + Paths.get("/usr/local/code/java/com/google/Bla.java") - .toString() - .replace("\\", "\\\\") - + "\""); - } - - @Test - public void testHandlesFutureFormat() throws Exception { String[] args = new String[] { "--output_manifest", "/tmp/out.manifest", "--sources", - ",java/com/google/Foo.java:" - + "bin/out,java/com/google/Bla.java", - }; + Joiner.on(':').join( + ",java/com/google/Foo.java,/usr/local/google/code", + "bin,java/com/google/Bla.java,/usr/local/_tmp/code/bin" + )}; PackageParser.PackageParserOptions options = PackageParser.parseArgs(args); assertThat(options.outputManifest.toString()) .isEqualTo(Paths.get("/tmp/out.manifest").toString()); @@ -339,7 +267,7 @@ public class PackageParserTest { assertThat(options.sources.get(1)) .isEqualTo( ArtifactLocation.newBuilder() - .setRootExecutionPathFragment(Paths.get("bin/out").toString()) + .setRootExecutionPathFragment(Paths.get("bin").toString()) .setRelativePath(Paths.get("java/com/google/Bla.java").toString()) .setIsSource(false) .build()); diff --git a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java index 0a375a2666..34c380aa17 100644 --- a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java +++ b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java @@ -26,7 +26,6 @@ import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo. import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.JavaRuleIdeInfo; import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo; import com.google.devtools.build.lib.ideinfo.androidstudio.AndroidStudioIdeInfo.RuleIdeInfo.Kind; -import com.google.devtools.build.lib.vfs.Path; import com.google.protobuf.ByteString; import com.google.protobuf.ProtocolStringList; import java.nio.file.Paths; @@ -45,13 +44,12 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testSimpleJavaLibrary() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "java_library(", - " name = 'simple',", - " srcs = ['simple/Simple.java']", - ")"); + scratch.file( + "com/google/example/BUILD", + "java_library(", + " name = 'simple',", + " srcs = ['simple/Simple.java']", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); @@ -59,12 +57,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); assertThat(location.getIsSource()).isTrue(); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleIdeInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - assertThat(ruleIdeInfo.getKind()).isEqualTo(Kind.JAVA_LIBRARY); - } assertThat(ruleIdeInfo.getKindString()).isEqualTo("java_library"); assertThat(relativePathsForJavaSourcesOf(ruleIdeInfo)) .containsExactly("com/google/example/simple/Simple.java"); @@ -982,19 +974,12 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase // todo(dslomov): Skylark aspect implementation does not yet return a correct root path. assertThat(ruleIdeInfo.getJavaRuleIdeInfo().getSourcesList()).containsExactly( ArtifactLocation.newBuilder() - .setRootPath( - testLegacyAswbPluginVersionCompatibility() - ? targetConfig.getGenfilesDirectory(RepositoryName.MAIN).getPath() - .getPathString() - : "") .setRootExecutionPathFragment( targetConfig.getGenfilesDirectory(RepositoryName.MAIN).getExecPathString()) .setRelativePath("com/google/example/gen.java") .setIsSource(false) .build(), ArtifactLocation.newBuilder() - .setRootPath(testLegacyAswbPluginVersionCompatibility() - ? directories.getWorkspace().getPathString() : "") .setRelativePath("com/google/example/Test.java") .setIsSource(true) .build()); @@ -1114,16 +1099,15 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testSimpleCCLibraryForCCToolchainExistence() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "cc_library(", - " name = 'simple',", - " srcs = ['simple/simple.cc'],", - " hdrs = ['simple/simple.h'],", - ")"); + scratch.file( + "com/google/example/BUILD", + "cc_library(", + " name = 'simple',", + " srcs = ['simple/simple.cc'],", + " hdrs = ['simple/simple.h'],", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos @@ -1134,11 +1118,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase ArtifactLocation location = ruleInfo.getBuildFileArtifactLocation(); assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - } assertThat(ruleInfo.hasCRuleIdeInfo()).isTrue(); assertThat(ruleInfo.getDependenciesList()).hasSize(1); @@ -1147,27 +1126,20 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testSimpleCCLibrary() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "cc_library(", - " name = 'simple',", - " srcs = ['simple/simple.cc'],", - " hdrs = ['simple/simple.h'],", - ")"); + scratch.file( + "com/google/example/BUILD", + "cc_library(", + " name = 'simple',", + " srcs = ['simple/simple.cc'],", + " hdrs = ['simple/simple.h'],", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); ArtifactLocation location = ruleIdeInfo.getBuildFileArtifactLocation(); assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleIdeInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - assertThat(ruleIdeInfo.getKind()).isEqualTo(Kind.CC_LIBRARY); - } assertThat(ruleIdeInfo.getKindString()).isEqualTo("cc_library"); assertThat(ruleIdeInfo.getDependenciesCount()).isEqualTo(1); @@ -1204,7 +1176,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " includes = ['foo/bar'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); @@ -1250,7 +1222,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " copts = ['-DGOPT', '-Ifoo/baz/'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); @@ -1289,7 +1261,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " defines = ['VERSION2'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); @@ -1305,26 +1277,19 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testSimpleCCBinary() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "cc_binary(", - " name = 'simple',", - " srcs = ['simple/simple.cc'],", - ")"); + scratch.file( + "com/google/example/BUILD", + "cc_binary(", + " name = 'simple',", + " srcs = ['simple/simple.cc'],", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); ArtifactLocation location = ruleIdeInfo.getBuildFileArtifactLocation(); assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleIdeInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - assertThat(ruleIdeInfo.getKind()).isEqualTo(Kind.CC_BINARY); - } assertThat(ruleIdeInfo.getKindString()).isEqualTo("cc_binary"); assertThat(ruleIdeInfo.getDependenciesCount()).isEqualTo(1); @@ -1347,26 +1312,19 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testSimpleCCTest() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "cc_test(", - " name = 'simple',", - " srcs = ['simple/simple.cc'],", - ")"); + scratch.file( + "com/google/example/BUILD", + "cc_test(", + " name = 'simple',", + " srcs = ['simple/simple.cc'],", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); ArtifactLocation location = ruleIdeInfo.getBuildFileArtifactLocation(); assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleIdeInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - assertThat(ruleIdeInfo.getKind()).isEqualTo(Kind.CC_TEST); - } assertThat(ruleIdeInfo.getKindString()).isEqualTo("cc_test"); assertThat(ruleIdeInfo.getDependenciesCount()).isEqualTo(1); @@ -1403,7 +1361,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " deps = [':lib'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(3); + assertThat(ruleIdeInfos).hasSize(3); RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos); @@ -1454,7 +1412,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " deps = [':lib2'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:lib1"); - assertThat(ruleIdeInfos.size()).isEqualTo(3); + assertThat(ruleIdeInfos).hasSize(3); RuleIdeInfo lib1 = getRuleInfoAndVerifyLabel( "//com/google/example:lib1", ruleIdeInfos); @@ -1515,7 +1473,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " deps = [':lib2'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:lib1"); - assertThat(ruleIdeInfos.size()).isEqualTo(3); + assertThat(ruleIdeInfos).hasSize(3); RuleIdeInfo lib1 = getRuleInfoAndVerifyLabel( "//com/google/example:lib1", ruleIdeInfos); @@ -1567,7 +1525,7 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase " deps = [':lib2'],", ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:lib1"); - assertThat(ruleIdeInfos.size()).isEqualTo(3); + assertThat(ruleIdeInfos).hasSize(3); RuleIdeInfo lib1 = getRuleInfoAndVerifyLabel( "//com/google/example:lib1", ruleIdeInfos); @@ -1624,16 +1582,15 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase @Test public void testCcToolchainInfoIsOnlyPresentForToolchainRules() throws Exception { - Path buildFilePath = - scratch.file( - "com/google/example/BUILD", - "cc_library(", - " name = 'simple',", - " srcs = ['simple/simple.cc'],", - " hdrs = ['simple/simple.h'],", - ")"); + scratch.file( + "com/google/example/BUILD", + "cc_library(", + " name = 'simple',", + " srcs = ['simple/simple.cc'],", + " hdrs = ['simple/simple.h'],", + ")"); Map<String, RuleIdeInfo> ruleIdeInfos = buildRuleIdeInfo("//com/google/example:simple"); - assertThat(ruleIdeInfos.size()).isEqualTo(2); + assertThat(ruleIdeInfos).hasSize(2); RuleIdeInfo ruleInfo = getRuleInfoAndVerifyLabel( "//com/google/example:simple", ruleIdeInfos @@ -1644,11 +1601,6 @@ public class AndroidStudioInfoAspectTest extends AndroidStudioInfoAspectTestBase ArtifactLocation location = ruleInfo.getBuildFileArtifactLocation(); assertThat(Paths.get(location.getRelativePath()).toString()) .isEqualTo(Paths.get("com/google/example/BUILD").toString()); - if (testLegacyAswbPluginVersionCompatibility()) { - assertThat(ruleInfo.getBuildFile()).isEqualTo(buildFilePath.toString()); - assertThat(Paths.get(location.getRootPath(), location.getRelativePath()).toString()) - .isEqualTo(Paths.get(buildFilePath.toString()).toString()); - } assertThat(ruleInfo.hasCToolchainIdeInfo()).isFalse(); assertThat(toolchainInfo.hasCToolchainIdeInfo()).isTrue(); 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<ArtifactLocation> { 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<ArtifactLocation> { 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<Path> 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<ArtifactLocation, String> 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<ArtifactLocation, String> sourceToPackageMap, - Path outputFile, - boolean oldFormat) + Path outputFile) throws IOException { PackageManifest.Builder builder = PackageManifest.newBuilder(); for (Entry<ArtifactLocation, String> 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()); } |