use of com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation in project bazel by bazelbuild.
the class JarFilter method parsePackageManifest.
@VisibleForTesting
static List<String> parsePackageManifest(PackageManifest packageManifest) {
List<String> result = Lists.newArrayList();
for (JavaSourcePackage javaSourcePackage : packageManifest.getSourcesList()) {
ArtifactLocation artifactLocation = javaSourcePackage.getArtifactLocation();
String packageString = javaSourcePackage.getPackageString();
String archiveFileNamePrefix = getArchiveFileNamePrefix(artifactLocation.getRelativePath(), packageString);
result.add(archiveFileNamePrefix);
}
return result;
}
use of com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation in project bazel by bazelbuild.
the class PackageParser method parsePackageStrings.
@Nonnull
@VisibleForTesting
public Map<ArtifactLocation, String> parsePackageStrings(@Nonnull List<ArtifactLocation> sources) throws Exception {
ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
Map<ArtifactLocation, ListenableFuture<String>> futures = Maps.newHashMap();
for (final ArtifactLocation source : sources) {
futures.put(source, executorService.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return getDeclaredPackageOfJavaFile(source);
}
}));
}
Map<ArtifactLocation, String> map = Maps.newHashMap();
for (Entry<ArtifactLocation, ListenableFuture<String>> entry : futures.entrySet()) {
String value = entry.getValue().get();
if (value != null) {
map.put(entry.getKey(), value);
}
}
return map;
}
use of com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation in project bazel by bazelbuild.
the class ArtifactLocationConverterTest method testConverterSourceArtifact.
@Test
public void testConverterSourceArtifact() throws Exception {
ArtifactLocation parsed = converter.convert(Joiner.on(',').join("", "test.java"));
assertThat(parsed).isEqualTo(ArtifactLocation.newBuilder().setRelativePath(Paths.get("test.java").toString()).setIsSource(true).build());
}
use of com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation in project bazel by bazelbuild.
the class ArtifactLocationConverterTest method testConverterExternal.
@Test
public void testConverterExternal() throws Exception {
ArtifactLocation externalArtifact = converter.convert(Joiner.on(',').join("", "test.java", "1"));
assertThat(externalArtifact).isEqualTo(ArtifactLocation.newBuilder().setRelativePath(Paths.get("test.java").toString()).setIsSource(true).setIsExternal(true).build());
ArtifactLocation nonExternalArtifact = converter.convert(Joiner.on(',').join("", "test.java", "0"));
assertThat(nonExternalArtifact).isEqualTo(ArtifactLocation.newBuilder().setRelativePath(Paths.get("test.java").toString()).setIsSource(true).setIsExternal(false).build());
}
use of com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation in project bazel by bazelbuild.
the class ArtifactLocationConverterTest method testConverterDerivedArtifact.
@Test
public void testConverterDerivedArtifact() throws Exception {
ArtifactLocation parsed = converter.convert(Joiner.on(',').join("bin", "java/com/test.java"));
assertThat(parsed).isEqualTo(ArtifactLocation.newBuilder().setRootExecutionPathFragment(Paths.get("bin").toString()).setRelativePath(Paths.get("java/com/test.java").toString()).setIsSource(false).build());
}
Aggregations