use of com.google.idea.blaze.base.prefetch.DefaultPrefetcher in project intellij by bazelbuild.
the class LocalArtifactCacheTest method initTest.
@Before
public void initTest() throws IOException {
intellijRule.registerApplicationService(FileOperationProvider.class, new FileOperationProvider());
intellijRule.registerApplicationService(RemoteArtifactPrefetcher.class, new DefaultPrefetcher());
workspaceRoot = new WorkspaceRoot(temporaryFolder.getRoot());
ArtifactLocationDecoder artifactLocationDecoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
return new File(workspaceRoot.directory(), artifactLocation.getRelativePath());
}
};
intellijRule.registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder().setArtifactLocationDecoder(artifactLocationDecoder).build()));
blazeContext = BlazeContext.create();
artifactCache = new LocalArtifactCache(intellijRule.getProject(), "TestArtifactCache", cacheDirectory.getRoot().toPath());
}
use of com.google.idea.blaze.base.prefetch.DefaultPrefetcher in project intellij by bazelbuild.
the class UnpackedAarsTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
writingOutputSink = new WritingOutputSink();
context = BlazeContext.create();
context.addOutputSink(PrintOutput.class, writingOutputSink);
workspaceRoot = new WorkspaceRoot(folder.getRoot());
localArtifactLocationDecoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
return new File(workspaceRoot.directory(), artifactLocation.getRelativePath());
}
};
remoteArtifactLocationDecoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
return new File(workspaceRoot.directory(), artifactLocation.getRelativePath());
}
@Override
public BlazeArtifact resolveOutput(ArtifactLocation artifact) {
if (!artifact.isSource()) {
File file = new File(workspaceRoot.directory(), artifact.getRelativePath());
// when the remote artifact cannot be resolved, it will guess it as local artifact.
return file.exists() ? new FakeRemoteOutputArtifact(file) : super.resolveOutput(artifact);
}
return super.resolveOutput(artifact);
}
};
projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
try {
File projectDataDirectory = folder.newFolder("projectdata");
BlazeImportSettings dummyImportSettings = new BlazeImportSettings("", "", projectDataDirectory.getAbsolutePath(), "", BuildSystemName.Bazel);
BlazeImportSettingsManager.getInstance(project).setImportSettings(dummyImportSettings);
} catch (IOException e) {
throw new AssertionError("Fail to create directory for test", e);
}
applicationServices.register(FileOperationProvider.class, new FileOperationProvider());
applicationServices.register(RemoteArtifactPrefetcher.class, new DefaultPrefetcher());
projectServices.register(UnpackedAars.class, new UnpackedAars(project));
registerExtensionPoint(FileCache.EP_NAME, FileCache.class).registerExtension(new FileCacheAdapter());
registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class).registerExtension(new BlazeAndroidSyncPlugin());
registerExtensionPoint(BlazeLibrarySorter.EP_NAME, BlazeLibrarySorter.class);
applicationServices.register(ExperimentService.class, new MockExperimentService());
}
use of com.google.idea.blaze.base.prefetch.DefaultPrefetcher in project intellij by bazelbuild.
the class JarCacheTest method initTest.
@Override
protected void initTest(Container applicationServices, Container projectServices) {
context = BlazeContext.create();
context.addOutputSink(PrintOutput.class, new WritingOutputSink());
workspaceRoot = new WorkspaceRoot(folder.getRoot());
fakeJarRepackager = new FakeJarRepackager();
BlazeImportSettingsManager blazeImportSettingsManager = new BlazeImportSettingsManager(project);
try {
File projectDataDirectory = folder.newFolder("projectdata");
BlazeImportSettings dummyImportSettings = new BlazeImportSettings("", "", projectDataDirectory.getAbsolutePath(), "", BuildSystemName.Blaze);
blazeImportSettingsManager.setImportSettings(dummyImportSettings);
} catch (IOException e) {
throw new AssertionError("Failed to create a directory for test", e);
}
projectServices.register(BlazeImportSettingsManager.class, blazeImportSettingsManager);
applicationServices.register(FileOperationProvider.class, new FileOperationProvider());
applicationServices.register(RemoteArtifactPrefetcher.class, new DefaultPrefetcher());
projectServices.register(JarCacheFolderProvider.class, new JarCacheFolderProvider(project));
applicationServices.register(JarRepackager.class, fakeJarRepackager);
JarCache jarCache = new JarCache(project);
jarCache.enableForTest();
projectServices.register(JarCache.class, jarCache);
registerExtensionPoint(FileCache.EP_NAME, FileCache.class).registerExtension(new JarCache.FileCacheAdapter(), testDisposable);
registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class).registerExtension(new BlazeJavaSyncPlugin(), testDisposable);
registerExtensionPoint(BlazeLibrarySorter.EP_NAME, BlazeLibrarySorter.class);
applicationServices.register(BlazeJavaUserSettings.class, new BlazeJavaUserSettings());
applicationServices.register(ExperimentService.class, new MockExperimentService());
applicationServices.register(BlazeExecutor.class, new MockBlazeExecutor());
}
use of com.google.idea.blaze.base.prefetch.DefaultPrefetcher in project intellij by bazelbuild.
the class RenderJarCacheTest method initTest.
@Before
public void initTest() throws IOException {
errorCollector = new ErrorCollector();
outputSink = new WritingOutputSink();
context = BlazeContext.create();
context.addOutputSink(PrintOutput.class, outputSink);
workspaceRoot = new WorkspaceRoot(temporaryFolder.getRoot());
artifactLocationDecoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
return new File(workspaceRoot.directory(), artifactLocation.getRelativePath());
}
};
registerMockBlazeImportSettings();
mockedArtifactCache = Mockito.mock(ArtifactCache.class);
intellijRule.registerProjectService(RenderJarCache.class, new RenderJarCache(intellijRule.getProject(), RenderJarCache.getCacheDirForProject(intellijRule.getProject()), mockedArtifactCache));
intellijRule.registerApplicationService(FileOperationProvider.class, new FileOperationProvider());
intellijRule.registerApplicationService(RemoteArtifactPrefetcher.class, new DefaultPrefetcher());
intellijRule.registerExtensionPoint(FileCache.EP_NAME, FileCache.class);
intellijRule.registerExtension(FileCache.EP_NAME, new FileCacheAdapter());
// Required to enable RenderJarClassFileFinder
MockExperimentService experimentService = new MockExperimentService();
experimentService.setExperiment(RenderResolveOutputGroupProvider.buildOnSync, true);
intellijRule.registerApplicationService(ExperimentService.class, experimentService);
// Setup needed for setting a projectview
intellijRule.registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
intellijRule.registerExtension(BlazeSyncPlugin.EP_NAME, new BlazeJavaSyncPlugin());
// RenderJarCache looks at targets of `Kind`s with LanguageClass.ANDROID
// so we need to setup the framework for fetching a target's `Kind`
intellijRule.registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
intellijRule.registerExtension(Kind.Provider.EP_NAME, new AndroidBlazeRules());
intellijRule.registerApplicationService(ApplicationState.class, new ApplicationState());
// registered because `RenderJarCache` uses it to filter source targets
projectViewManager = new MockProjectViewManager();
intellijRule.registerProjectService(ProjectViewManager.class, projectViewManager);
intellijRule.registerApplicationService(BlazeExecutor.class, new MockBlazeExecutor());
setupProjectData();
setProjectView("directories:", " com/foo/bar/baz", " com/foo/bar/qux", "targets:", " //com/foo/bar/baz:baz", " //com/foo/bar/qux:quz");
}
Aggregations