use of com.google.idea.blaze.android.projectsystem.MavenArtifactLocator in project intellij by bazelbuild.
the class BlazeModuleSystemDependentLibrariesIntegrationTest method setup.
@Before
public void setup() {
final String recyclerView = "//third_party/recyclerview:recyclerview";
final String constraintLayout = "//third_party/constraint_layout:constraint_layout";
final String quantum = "//third_party/quantum:values";
final String aarFile = "//third_party/aar:an_aar";
final String individualLibrary = "//third_party/individualLibrary:values";
final String guava = "//third_party/guava:java";
final String main = "//java/com/google:app";
final String intermediateDependency = "//java/com/google/intermediate:intermediate";
// BlazeAndroidRunConfigurationCommonState.isNativeDebuggingEnabled() always
// returns false if this experiment is false. Enable it by setting it to true.
MockExperimentService experimentService = new MockExperimentService();
registerApplicationComponent(ExperimentService.class, experimentService);
registerExtension(MavenArtifactLocator.EP_NAME, new MavenArtifactLocator() {
@Override
public Label labelFor(GradleCoordinate coordinate) {
switch(GoogleMavenArtifactId.forCoordinate(coordinate)) {
case RECYCLERVIEW_V7:
return Label.create("//third_party/recyclerview:recyclerview");
case CONSTRAINT_LAYOUT:
return Label.create("//third_party/constraint_layout:constraint_layout");
default:
return null;
}
}
@Override
public BuildSystemName buildSystem() {
return BuildSystemName.Blaze;
}
});
// This MainActivity.java file is needed because blaze sync will fail if the source
// directory is empty, so we put something there. The fact that it's MainActivity.java
// doesn't mean anything.
workspace.createFile(new WorkspacePath("java/com/google/app/MainActivity.java"), "package com.google.app", "import android.app.Activity;", "public class MainActivity extends Activity {", "}");
// Make JARs appear nonempty so that they aren't filtered out
registerApplicationService(FileOperationProvider.class, new FileOperationProvider() {
@Override
public long getFileSize(File file) {
return file.getName().endsWith("jar") ? 500L : super.getFileSize(file);
}
});
setProjectView("directories:", " java/com/google", "targets:", " //java/com/google:app", "android_sdk_platform: android-27");
MockSdkUtil.registerSdk(workspace, "27");
NbAarTarget aarTarget = aar_import(aarFile).aar("lib_aar.aar").generated_jar("_aar/an_aar/classes_and_libs_merged.jar");
AarLibraryFileBuilder.aar(workspaceRoot, aarTarget.getAar().getRelativePath()).src("res/values/colors.xml", ImmutableList.of("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "<resources>", " <color name=\"aarColor\">#ffffff</color>", "</resources>")).build();
NbAndroidTarget binaryTarget = android_binary(main).source_jar("app.jar").res("res").res_folder("//third_party/shared/res", "app-third_party-shared-res.aar").src("app/MainActivity.java").dep(guava, quantum, aarFile, intermediateDependency);
binaryTarget.getAarList().forEach(aar -> AarLibraryFileBuilder.aar(workspaceRoot, aar.getRelativePath()).build());
NbAndroidTarget quantumTarget = android_library(quantum).res_folder("//third_party/quantum/res", "values-third_party-quantum-res.aar");
quantumTarget.getAarList().forEach(aar -> AarLibraryFileBuilder.aar(workspaceRoot, aar.getRelativePath()).build());
NbAndroidTarget constraintLayoutTarget = android_library(constraintLayout).res_folder("//third_party/constraint_layout/res", "constraint_layout-third_party-constraint_layout-res.aar");
constraintLayoutTarget.getAarList().forEach(aar -> AarLibraryFileBuilder.aar(workspaceRoot, aar.getRelativePath()).build());
setTargetMap(binaryTarget, android_library(individualLibrary).res("res"), java_library(guava).source_jar("//third_party/guava-21.jar"), quantumTarget, aarTarget, android_library(recyclerView).res("res"), android_library(intermediateDependency).res("res").dep(constraintLayout), constraintLayoutTarget);
runFullBlazeSyncWithNoIssues();
Module appModule = ModuleManager.getInstance(getProject()).findModuleByName("java.com.google.app");
appModuleSystem = BlazeModuleSystem.getInstance(appModule);
Module workspaceModule = ModuleManager.getInstance(getProject()).findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME);
workspaceModuleSystem = BlazeModuleSystem.getInstance(workspaceModule);
}
use of com.google.idea.blaze.android.projectsystem.MavenArtifactLocator in project intellij by bazelbuild.
the class BlazeModuleSystemExternalDependencyIntegrationTest method setupSourcesAndProjectView.
@Before
public void setupSourcesAndProjectView() {
registerExtension(MavenArtifactLocator.EP_NAME, new MavenArtifactLocator() {
private final ImmutableMap<GradleCoordinate, Label> knownArtifacts = new ImmutableMap.Builder<GradleCoordinate, Label>().put(CONSTRAINT_LAYOUT_COORDINATE, Label.create(CONSTRAINT_LAYOUT_LABEL)).build();
@Override
public Label labelFor(GradleCoordinate coordinate) {
return knownArtifacts.get(new GradleCoordinate(coordinate.getGroupId(), coordinate.getArtifactId(), "+"));
}
@Override
public BuildSystemName buildSystem() {
return BuildSystemName.Bazel;
}
});
setProjectView("directories:", " java/com/foo/gallery/activities", "targets:", " //java/com/foo/gallery/activities:activities", "android_sdk_platform: android-27");
MockSdkUtil.registerSdk(workspace, "27");
workspace.createFile(new WorkspacePath("java/com/foo/gallery/activities/MainActivity.java"), "package com.foo.gallery.activities", "import android.app.Activity;", "public class MainActivity extends Activity {}");
workspace.createFile(new WorkspacePath("java/com/foo/libs/res/values/styles.xml"), "<?xml version=\"1.0\" encoding=\"utf-8\"?>", "<resources></resources>");
}
Aggregations