Search in sources :

Example 1 with ArtifactLocation

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;
}
Also used : ArtifactLocation(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation) JavaSourcePackage(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.JavaSourcePackage) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with ArtifactLocation

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;
}
Also used : ArtifactLocation(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Callable(java.util.concurrent.Callable) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Nonnull(javax.annotation.Nonnull)

Example 3 with ArtifactLocation

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());
}
Also used : ArtifactLocation(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation) Test(org.junit.Test)

Example 4 with ArtifactLocation

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());
}
Also used : ArtifactLocation(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation) Test(org.junit.Test)

Example 5 with ArtifactLocation

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());
}
Also used : ArtifactLocation(com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation) Test(org.junit.Test)

Aggregations

ArtifactLocation (com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.ArtifactLocation)5 Test (org.junit.Test)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 JavaSourcePackage (com.google.devtools.build.lib.ideinfo.androidstudio.PackageManifestOuterClass.JavaSourcePackage)1 Callable (java.util.concurrent.Callable)1 Nonnull (javax.annotation.Nonnull)1