use of com.google.idea.blaze.base.settings.BuildSystemName in project intellij by bazelbuild.
the class FastBuildServiceImpl method getBlazeInfo.
private BlazeInfo getBlazeInfo(BlazeContext context, FastBuildParameters buildParameters) {
BuildSystemName buildSystemName = Blaze.getBuildSystemName(project);
ListenableFuture<BlazeInfo> blazeInfoFuture = BlazeInfoRunner.getInstance().runBlazeInfo(context, buildSystemName, buildParameters.blazeBinary(), WorkspaceRoot.fromProject(project), buildParameters.infoFlags());
BlazeInfo info = FutureUtil.waitForFuture(context, blazeInfoFuture).timed(buildSystemName.getName() + "Info", EventType.BlazeInvocation).withProgressMessage(String.format("Running %s info...", buildSystemName.getLowerCaseName())).onError(String.format("Could not run %s info", buildSystemName.getLowerCaseName())).run().result();
if (info == null) {
throw new RuntimeException(String.format("%s info failed", buildSystemName.getLowerCaseName()));
}
return info;
}
use of com.google.idea.blaze.base.settings.BuildSystemName in project intellij by bazelbuild.
the class BlazeInfo method createMockBlazeInfo.
/**
* Creates a mock blaze info with the minimum information required for syncing.
*/
@VisibleForTesting
public static BlazeInfo createMockBlazeInfo(String outputBase, String executionRoot, String blazeBin, String blazeGenFiles, String blazeTestlogs) {
BuildSystemName buildSystemName = BuildSystemName.Bazel;
ImmutableMap.Builder<String, String> blazeInfoMap = ImmutableMap.<String, String>builder().put(OUTPUT_BASE_KEY, outputBase).put(EXECUTION_ROOT_KEY, executionRoot).put(blazeBinKey(buildSystemName), blazeBin).put(blazeGenfilesKey(buildSystemName), blazeGenFiles).put(blazeTestlogsKey(buildSystemName), blazeTestlogs);
return BlazeInfo.create(buildSystemName, blazeInfoMap.build());
}
use of com.google.idea.blaze.base.settings.BuildSystemName in project intellij by bazelbuild.
the class BlazeTypeScriptConfig method parsePaths.
private void parsePaths(JsonObject json) {
String runfilesPrefix = null;
List<String> alternativePrefixes = new ArrayList<>();
VirtualFile base = baseUrlFile.getValue();
if (base != null) {
Path baseUrlPath = VfsUtil.virtualToIoFile(base).toPath();
BuildSystemName buildSystem = Blaze.getBuildSystemName(project);
File workspaceRoot = WorkspaceRoot.fromProject(project).directory();
File blazeBin = new File(workspaceRoot, BlazeInfo.blazeBinKey(buildSystem));
File blazeGenfiles = new File(workspaceRoot, BlazeInfo.blazeGenfilesKey(buildSystem));
// modules are resolved in this order
alternativePrefixes.add(baseUrlPath.relativize(workspaceRoot.toPath()).toString());
alternativePrefixes.add(baseUrlPath.relativize(blazeBin.toPath()).toString());
alternativePrefixes.add(baseUrlPath.relativize(blazeGenfiles.toPath()).toString());
FileOperationProvider fOps = FileOperationProvider.getInstance();
if (fOps.isSymbolicLink(blazeBin)) {
try {
alternativePrefixes.add(baseUrlPath.relativize(fOps.readSymbolicLink(blazeBin).toPath()).toString());
} catch (IOException e) {
logger.warn(e);
}
}
if (fOps.isSymbolicLink(blazeGenfiles)) {
try {
alternativePrefixes.add(baseUrlPath.relativize(fOps.readSymbolicLink(blazeGenfiles).toPath()).toString());
} catch (IOException e) {
logger.warn(e);
}
}
runfilesPrefix = "./" + label.targetName() + ".runfiles/" + workspaceRoot.getName();
}
for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
String name = entry.getKey();
List<String> mappings = new ArrayList<>();
for (JsonElement path : entry.getValue().getAsJsonArray()) {
String pathString = path.getAsString();
if (pathString.startsWith(workspaceRelativePathPrefix)) {
pathString = workspaceRelativePathReplacement + pathString.substring(workspaceRelativePathPrefix.length());
}
mappings.add(pathString);
}
paths.add(new PathSubstitution(name, mappings, alternativePrefixes, runfilesPrefix));
}
}
use of com.google.idea.blaze.base.settings.BuildSystemName in project intellij by bazelbuild.
the class BlazeNewProjectBuilder method commit.
/**
* Commits the project. May report errors.
*/
public void commit() throws BlazeProjectCommitException {
this.workspaceRoot = workspaceData.workspaceRoot();
projectViewOption.commit();
BuildSystemName buildSystemName = workspaceData.buildSystem();
writeWorkspaceHistory(buildSystemName, workspaceRoot.toString());
if (!StringUtil.isEmpty(projectDataDirectory)) {
File projectDataDir = new File(projectDataDirectory);
if (!projectDataDir.exists()) {
if (!projectDataDir.mkdirs()) {
throw new BlazeProjectCommitException("Unable to create the project directory: " + projectDataDirectory);
}
}
}
try {
logger.assertTrue(projectViewFile != null);
ProjectViewStorageManager.getInstance().writeProjectView(ProjectViewParser.projectViewToString(projectView), projectViewFile);
} catch (IOException e) {
throw new BlazeProjectCommitException("Could not create project view file", e);
}
BlazeImportSettingsManager.setPendingProjectSettings(getImportSettings());
}
use of com.google.idea.blaze.base.settings.BuildSystemName 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);
}
Aggregations