use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspect method makeAndroidIdeInfo.
private static AndroidIdeInfo makeAndroidIdeInfo(AndroidIdeInfoProvider androidIdeInfoProvider, DependenciesResult dependenciesResult, NestedSetBuilder<Artifact> ideResolveArtifacts) {
AndroidIdeInfo.Builder builder = AndroidIdeInfo.newBuilder();
if (androidIdeInfoProvider.getSignedApk() != null) {
builder.setApk(makeArtifactLocation(androidIdeInfoProvider.getSignedApk()));
}
Artifact manifest = androidIdeInfoProvider.getManifest();
if (manifest != null) {
builder.setManifest(makeArtifactLocation(manifest));
addResolveArtifact(ideResolveArtifacts, manifest);
}
for (Artifact artifact : androidIdeInfoProvider.getApksUnderTest()) {
builder.addDependencyApk(makeArtifactLocation(artifact));
}
for (SourceDirectory resourceDir : androidIdeInfoProvider.getResourceDirs()) {
ArtifactLocation artifactLocation = makeArtifactLocation(resourceDir);
builder.addResources(artifactLocation);
}
if (androidIdeInfoProvider.getJavaPackage() != null) {
builder.setJavaPackage(androidIdeInfoProvider.getJavaPackage());
}
String idlImportRoot = androidIdeInfoProvider.getIdlImportRoot();
if (idlImportRoot != null) {
builder.setIdlImportRoot(idlImportRoot);
}
boolean hasIdlSources = !androidIdeInfoProvider.getIdlSrcs().isEmpty();
builder.setHasIdlSources(hasIdlSources);
if (hasIdlSources) {
LibraryArtifact idlLibraryArtifact = makeLibraryArtifact(ideResolveArtifacts, androidIdeInfoProvider.getIdlClassJar(), null, androidIdeInfoProvider.getIdlSourceJar());
if (idlLibraryArtifact != null) {
builder.setIdlJar(idlLibraryArtifact);
}
}
builder.setGenerateResourceClass(androidIdeInfoProvider.definesAndroidResources());
if (dependenciesResult.resources != null) {
builder.setLegacyResources(dependenciesResult.resources.toString());
}
OutputJar resourceJar = androidIdeInfoProvider.getResourceJar();
if (resourceJar != null) {
LibraryArtifact resourceLibraryArtifact = makeLibraryArtifact(ideResolveArtifacts, resourceJar.getClassJar(), resourceJar.getIJar(), resourceJar.getSrcJar());
if (resourceLibraryArtifact != null) {
builder.setResourceJar(resourceLibraryArtifact);
}
}
return builder.build();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testSimpleCCTest.
@Test
public void testSimpleCCTest() throws Exception {
scratch.file("com/google/example/BUILD", "cc_test(", " name = 'simple',", " srcs = ['simple/simple.cc'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
assertThat(targetIdeInfos).hasSize(2);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(targetIdeInfo.getKindString()).isEqualTo("cc_test");
assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
assertThat(relativePathsForCSourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.cc");
assertThat(targetIdeInfo.hasCIdeInfo()).isTrue();
assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
CIdeInfo cTargetIdeInfo = targetIdeInfo.getCIdeInfo();
assertThat(cTargetIdeInfo.getTargetCoptList()).isEmpty();
assertThat(cTargetIdeInfo.getTargetDefineList()).isEmpty();
assertThat(cTargetIdeInfo.getTargetIncludeList()).isEmpty();
assertThat(targetIdeInfo.getJavaIdeInfo().getJarsList()).isEmpty();
assertThat(getIdeResolveFiles()).isEmpty();
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testPyTestWithDeps.
@Test
public void testPyTestWithDeps() throws Exception {
scratch.file("com/google/example/BUILD", "py_library(", " name = 'lib',", " srcs = ['lib.py'],", ")", "py_test(", " name = 'test',", " srcs = ['test.py'],", " deps = [':lib'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:test");
assertThat(targetIdeInfos).hasSize(3);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:test", targetIdeInfos);
ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(targetIdeInfo.getKindString()).isEqualTo("py_test");
assertThat(targetIdeInfo.getDependenciesList()).contains("//com/google/example:lib");
assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(2);
assertThat(relativePathsForPySourcesOf(targetIdeInfo)).containsExactly("com/google/example/test.py");
assertThat(targetIdeInfo.hasPyIdeInfo()).isTrue();
assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/test.py", "com/google/example/lib.py");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testPackageManifestCreated.
@Test
public void testPackageManifestCreated() throws Exception {
scratch.file("com/google/example/BUILD", "java_library(", " name = 'simple',", " srcs = ['simple/Simple.java']", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
ArtifactLocation packageManifest = targetIdeInfo.getJavaIdeInfo().getPackageManifest();
assertNotNull(packageManifest);
assertEquals(packageManifest.getRelativePath(), "com/google/example/simple.manifest");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.ArtifactLocation in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testSimplePyTest.
@Test
public void testSimplePyTest() throws Exception {
scratch.file("com/google/example/BUILD", "py_test(", " name = 'simple',", " srcs = ['simple/simple.py'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//com/google/example:simple");
assertThat(targetIdeInfos).hasSize(2);
TargetIdeInfo targetIdeInfo = getTargetIdeInfoAndVerifyLabel("//com/google/example:simple", targetIdeInfos);
ArtifactLocation location = targetIdeInfo.getBuildFileArtifactLocation();
assertThat(Paths.get(location.getRelativePath()).toString()).isEqualTo(Paths.get("com/google/example/BUILD").toString());
assertThat(targetIdeInfo.getKindString()).isEqualTo("py_test");
assertThat(targetIdeInfo.getDependenciesCount()).isEqualTo(1);
assertThat(relativePathsForPySourcesOf(targetIdeInfo)).containsExactly("com/google/example/simple/simple.py");
assertThat(targetIdeInfo.hasPyIdeInfo()).isTrue();
assertThat(targetIdeInfo.hasJavaIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasCIdeInfo()).isFalse();
assertThat(targetIdeInfo.hasAndroidIdeInfo()).isFalse();
assertThat(getIdeResolveFiles()).containsExactly("com/google/example/simple/simple.py");
}
Aggregations