use of com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo in project intellij by bazelbuild.
the class BlazeImportFixture method buildTargetMap.
private TargetMapBuilder buildTargetMap() {
Label recyclerView = Label.create("//third_party/recyclerview:recyclerview");
Label constraintLayout = Label.create("//third_party/constraint_layout:constraint_layout");
Label quantum = Label.create("//third_party/quantum:values");
Label aarFile = Label.create("//third_party/aar:an_aar");
Label individualLibrary = Label.create("//third_party/individualLibrary:values");
Label guava = Label.create("//third_party/guava:java");
Label main = Label.create("//java/com/google:app");
Label intermediateDependency = Label.create("//java/com/google/intermediate:intermediate");
return TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(main).setKind(AndroidBlazeRules.RuleTypes.ANDROID_BINARY.getKind()).setBuildFile(source("java/com/google/BUILD")).setJavaInfo(javaInfoWithJars("app.jar")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/com/google/AndroidManifest.xml")).addResource(source("java/com/google/res")).addResource(source("third_party/shared/res")).setGenerateResourceClass(true).setResourceJavaPackage("java.com.google.app")).addSource(source("java/com/google/app/MainActivity.java")).addDependency(guava).addDependency(quantum).addDependency(aarFile).addDependency(intermediateDependency)).addTarget(TargetIdeInfo.builder().setLabel(individualLibrary).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/individualLibrary/BUILD")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/individualLibrary/AndroidManifest.xml")).addResource(source("third_party/individualLibrary/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.individualLibrary"))).addTarget(TargetIdeInfo.builder().setLabel(quantum).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/quantum/BUILD")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/quantum/AndroidManifest.xml")).addResource(AndroidResFolder.builder().setRoot(source("third_party/quantum/res")).setAar(source("third_party/quantum/values.aar")).build()).setGenerateResourceClass(true).setResourceJavaPackage("third_party.quantum"))).addTarget(TargetIdeInfo.builder().setLabel(guava).setKind(JavaBlazeRules.RuleTypes.JAVA_LIBRARY.getKind()).setJavaInfo(javaInfoWithJars("third_party/guava-21.jar"))).addTarget(TargetIdeInfo.builder().setLabel(aarFile).setBuildFile(source("third_party/aar/BUILD")).setKind(AndroidBlazeRules.RuleTypes.AAR_IMPORT.getKind()).setAndroidAarInfo(new AndroidAarIdeInfo(source("third_party/aar/lib_aar.aar"), /*customJavaPackage=*/
null)).setJavaInfo(javaInfoWithJars("third_party/aar/_aar/an_aar/classes_and_libs_merged.jar")).build()).addTarget(TargetIdeInfo.builder().setLabel(recyclerView).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/recyclerview/BUILD")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/recyclerview/AndroidManifest.xml")).addResource(source("third_party/recyclerview/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.recyclerview"))).addTarget(TargetIdeInfo.builder().setLabel(intermediateDependency).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("java/com/google/intermediate/BUILD")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/com/google/intermediate/AndroidManifest.xml")).addResource(source("java/com/google/intermediate/res")).setGenerateResourceClass(true).setResourceJavaPackage("java.com.google.intermediate")).addDependency(constraintLayout)).addTarget(TargetIdeInfo.builder().setLabel(constraintLayout).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/constraint_layout/BUILD")).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/constraint_layout/AndroidManifest.xml")).addResource(source("third_party/constraint_layout/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.constraint_layout")));
}
use of com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo in project intellij by bazelbuild.
the class BlazeAndroidWorkspaceImporterTest method testAarImport_outsideSourcesAndNoJdeps_keepsAarLibrary.
@Test
public void testAarImport_outsideSourcesAndNoJdeps_keepsAarLibrary() {
ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("java/example")))).build();
TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//java/example:lib").setBuildFile(source("java/example/BUILD")).setKind(Kind.ANDROID_LIBRARY).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/example/AndroidManifest.xml")).addResource(source("java/example/res")).setGenerateResourceClass(true).setResourceJavaPackage("example")).setJavaInfo(JavaIdeInfo.builder()).addSource(source("java/example/Source.java")).addDependency("//third_party/lib:an_aar").build()).addTarget(TargetIdeInfo.builder().setLabel("//third_party/lib:an_aar").setBuildFile(source("third_party/lib/BUILD")).setKind(Kind.AAR_IMPORT).setAndroidAarInfo(new AndroidAarIdeInfo(source("third_party/lib/lib_aar.aar"))).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setClassJar(gen("third_party/lib/_aar/an_aar/" + "classes_and_libs_merged.jar")))).build());
BlazeJavaImportResult javaResult = importJavaWorkspace(workspaceRoot, targetMapBuilder, projectView);
BlazeAndroidImportResult androidResult = importWorkspace(workspaceRoot, targetMapBuilder, projectView);
errorCollector.assertNoIssues();
// The java importer performs jdeps optimization, but the android one does not.
assertThat(javaResult.libraries).isEmpty();
assertThat(androidResult.aarLibraries.stream().map(BlazeAndroidWorkspaceImporterTest::aarName).collect(Collectors.toList())).containsExactly("lib_aar.aar");
}
use of com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo in project intellij by bazelbuild.
the class IdeInfoFromProtobuf method makeTargetIdeInfo.
@Nullable
public static TargetIdeInfo makeTargetIdeInfo(IntellijIdeInfo.TargetIdeInfo message) {
Kind kind = getKind(message);
if (kind == null) {
return null;
}
TargetKey key = getKey(message);
ArtifactLocation buildFile = getBuildFile(message);
final Collection<Dependency> dependencies;
if (message.getDepsCount() > 0) {
dependencies = message.getDepsList().stream().map(IdeInfoFromProtobuf::makeDependency).collect(toList());
} else {
dependencies = Lists.newArrayListWithCapacity(message.getDependenciesCount() + message.getRuntimeDepsCount());
dependencies.addAll(makeDependencyListFromLabelList(message.getDependenciesList(), DependencyType.COMPILE_TIME));
dependencies.addAll(makeDependencyListFromLabelList(message.getRuntimeDepsList(), DependencyType.RUNTIME));
}
Collection<String> tags = ImmutableList.copyOf(message.getTagsList());
Collection<ArtifactLocation> sources = Lists.newArrayList();
CIdeInfo cIdeInfo = null;
if (message.hasCIdeInfo()) {
cIdeInfo = makeCIdeInfo(message.getCIdeInfo());
sources.addAll(cIdeInfo.sources);
sources.addAll(cIdeInfo.headers);
sources.addAll(cIdeInfo.textualHeaders);
}
CToolchainIdeInfo cToolchainIdeInfo = null;
if (message.hasCToolchainIdeInfo()) {
cToolchainIdeInfo = makeCToolchainIdeInfo(message.getCToolchainIdeInfo());
}
JavaIdeInfo javaIdeInfo = null;
if (message.hasJavaIdeInfo()) {
javaIdeInfo = makeJavaIdeInfo(message.getJavaIdeInfo());
Collection<ArtifactLocation> javaSources = makeArtifactLocationList(message.getJavaIdeInfo().getSourcesList());
sources.addAll(javaSources);
}
AndroidIdeInfo androidIdeInfo = null;
if (message.hasAndroidIdeInfo()) {
androidIdeInfo = makeAndroidIdeInfo(message.getAndroidIdeInfo());
}
AndroidSdkIdeInfo androidSdkIdeInfo = null;
if (message.hasAndroidSdkIdeInfo()) {
androidSdkIdeInfo = makeAndroidSdkIdeInfo(message.getAndroidSdkIdeInfo());
}
AndroidAarIdeInfo androidAarIdeInfo = null;
if (message.hasAndroidAarIdeInfo()) {
androidAarIdeInfo = makeAndroidAarIdeInfo(message.getAndroidAarIdeInfo());
}
PyIdeInfo pyIdeInfo = null;
if (message.hasPyIdeInfo()) {
pyIdeInfo = makePyIdeInfo(message.getPyIdeInfo());
sources.addAll(pyIdeInfo.sources);
}
GoIdeInfo goIdeInfo = null;
if (message.hasGoIdeInfo()) {
goIdeInfo = makeGoIdeInfo(message.getGoIdeInfo());
sources.addAll(goIdeInfo.sources);
}
JsIdeInfo jsIdeInfo = null;
if (message.hasJsIdeInfo()) {
jsIdeInfo = makeJsIdeInfo(message.getJsIdeInfo());
sources.addAll(jsIdeInfo.sources);
}
TsIdeInfo tsIdeInfo = null;
if (message.hasTsIdeInfo()) {
tsIdeInfo = makeTsIdeInfo(message.getTsIdeInfo());
sources.addAll(tsIdeInfo.sources);
}
DartIdeInfo dartIdeInfo = null;
if (message.hasDartIdeInfo()) {
dartIdeInfo = makeDartIdeInfo(message.getDartIdeInfo());
sources.addAll(dartIdeInfo.sources);
}
TestIdeInfo testIdeInfo = null;
if (message.hasTestInfo()) {
testIdeInfo = makeTestIdeInfo(message.getTestInfo());
}
ProtoLibraryLegacyInfo protoLibraryLegacyInfo = null;
if (message.hasProtoLibraryLegacyJavaIdeInfo()) {
protoLibraryLegacyInfo = makeProtoLibraryLegacyInfo(message.getProtoLibraryLegacyJavaIdeInfo());
}
JavaToolchainIdeInfo javaToolchainIdeInfo = null;
if (message.hasJavaToolchainIdeInfo()) {
javaToolchainIdeInfo = makeJavaToolchainIdeInfo(message.getJavaToolchainIdeInfo());
}
return new TargetIdeInfo(key, kind, buildFile, dependencies, tags, sources, cIdeInfo, cToolchainIdeInfo, javaIdeInfo, androidIdeInfo, androidSdkIdeInfo, androidAarIdeInfo, pyIdeInfo, goIdeInfo, jsIdeInfo, tsIdeInfo, dartIdeInfo, testIdeInfo, protoLibraryLegacyInfo, javaToolchainIdeInfo);
}
use of com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo in project intellij by bazelbuild.
the class NbTargetMapBuilderTest method testComplexAndroidTargetMap.
@Test
public void testComplexAndroidTargetMap() throws Exception {
String recyclerView = "//third_party/recyclerview:recyclerview";
String constraintLayout = "//third_party/constraint_layout:constraint_layout";
String quantum = "//third_party/quantum:values";
String aarFile = "//third_party/aar:an_aar";
String individualLibrary = "//third_party/individualLibrary:values";
String guava = "//third_party/guava:java";
String main = "//java/com/google:app";
String intermediateDependency = "//java/com/google/intermediate:intermediate";
TargetMap oldTargetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(main).setKind(AndroidBlazeRules.RuleTypes.ANDROID_BINARY.getKind()).setBuildFile(source("java/com/google/BUILD")).setJavaInfo(javaInfoWithJars("java/com/google/app.jar").setJdepsFile(gen("java/com/google/app.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/com/google/AndroidManifest.xml")).addResource(source("java/com/google/res")).addResource(source("third_party/shared/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google")).addSource(source("java/com/google/app/MainActivity.java")).addDependency(guava).addDependency(quantum).addDependency(aarFile).addDependency(intermediateDependency)).addTarget(TargetIdeInfo.builder().setLabel(individualLibrary).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/individualLibrary/BUILD")).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("third_party/individualLibrary/values.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/individualLibrary/AndroidManifest.xml")).addResource(source("third_party/individualLibrary/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.individualLibrary"))).addTarget(TargetIdeInfo.builder().setLabel(quantum).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/quantum/BUILD")).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("third_party/quantum/values.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/quantum/manifest/AndroidManifest.xml")).addResource(AndroidResFolder.builder().setRoot(source("third_party/quantum/res")).setAar(source("third_party/quantum/resources.aar")).build()).setGenerateResourceClass(true).setResourceJavaPackage("third_party.quantum"))).addTarget(TargetIdeInfo.builder().setLabel(guava).setBuildFile(source("third_party/guava/BUILD")).setKind(JavaBlazeRules.RuleTypes.JAVA_LIBRARY.getKind()).setJavaInfo(javaInfoWithJars("third_party/guava-21.jar").setJdepsFile(gen("third_party/guava/java.jdeps")))).addTarget(TargetIdeInfo.builder().setLabel(aarFile).setBuildFile(source("third_party/aar/BUILD")).setKind(AndroidBlazeRules.RuleTypes.AAR_IMPORT.getKind()).setAndroidAarInfo(new AndroidAarIdeInfo(source("third_party/aar/lib_aar.aar"), /*customJavaPackage=*/
null)).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("third_party/aar/an_aar.jdeps")).addJar(LibraryArtifact.builder().setClassJar(gen("third_party/aar/" + "_aar/an_aar/classes_and_libs_merged.jar"))))).addTarget(TargetIdeInfo.builder().setLabel(recyclerView).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/recyclerview/BUILD")).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("third_party/recyclerview/recyclerview.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/recyclerview/AndroidManifest.xml")).addResource(source("third_party/recyclerview/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.recyclerview"))).addTarget(TargetIdeInfo.builder().setLabel(intermediateDependency).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("java/com/google/intermediate/BUILD")).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("java/com/google/intermediate/intermediate.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("java/com/google/intermediate/AndroidManifest.xml")).addResource(source("java/com/google/intermediate/res")).setGenerateResourceClass(true).setResourceJavaPackage("com.google.intermediate")).addDependency(constraintLayout)).addTarget(TargetIdeInfo.builder().setLabel(constraintLayout).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(source("third_party/constraint_layout/BUILD")).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("third_party/constraint_layout/constraint_layout.jdeps"))).setAndroidInfo(AndroidIdeInfo.builder().setManifestFile(source("third_party/constraint_layout/AndroidManifest.xml")).addResource(source("third_party/constraint_layout/res")).setGenerateResourceClass(true).setResourceJavaPackage("third_party.constraint_layout"))).build();
// New target map construction.
TargetMap newTargetMap = targetMap(android_binary(main).source_jar("app.jar").res("res", "//third_party/shared/res").src("app/MainActivity.java").dep(guava, quantum, aarFile, intermediateDependency), android_library(individualLibrary).res("res"), android_library(quantum).manifest("manifest/AndroidManifest.xml").res_folder("//third_party/quantum/res", "resources.aar"), java_library(guava).source_jar("//third_party/guava-21.jar"), aar_import(aarFile).aar("lib_aar.aar").generated_jar("_aar/an_aar/classes_and_libs_merged.jar"), android_library(recyclerView).res("res"), android_library(intermediateDependency).res("res").dep(constraintLayout), android_library(constraintLayout).res("res"));
assertTargetMapEquivalence(newTargetMap, oldTargetMap);
}
use of com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo in project intellij by bazelbuild.
the class NbTargetMapBuilderTest method testAarTargetMap.
@Test
public void testAarTargetMap() throws Exception {
TargetMap oldTargetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//import:aar").setBuildFile(source("import/BUILD")).setKind(AndroidBlazeRules.RuleTypes.AAR_IMPORT.getKind()).setAndroidAarInfo(new AndroidAarIdeInfo(ArtifactLocation.builder().setRelativePath("import/lib_aar.aar").setIsSource(true).build(), /*customJavaPackage=*/
null)).setJavaInfo(JavaIdeInfo.builder().setJdepsFile(gen("import/aar.jdeps")).addJar(LibraryArtifact.builder().setClassJar(gen("import/classes.jar"))))).build();
TargetMap newTargetMap = targetMap(aar_import("//import:aar").aar("lib_aar.aar").generated_jar("classes.jar"));
assertTargetMapEquivalence(newTargetMap, oldTargetMap);
}
Aggregations