use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.
the class JarCacheTest method refresh_fllSync_localArtifact_lintJarCached.
@Test
public void refresh_fllSync_localArtifact_lintJarCached() throws IOException {
ArtifactLocationDecoder localArtifactLocationDecoder = new MockArtifactLocationDecoder(workspaceRoot.directory(), /* isRemote= */
false);
testRefreshLintJarCached(localArtifactLocationDecoder, SyncMode.FULL);
}
use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder 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.sync.workspace.MockArtifactLocationDecoder 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.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.
the class RenderJarClassFileFinderTest method initTest.
@Before
public void initTest() throws ArtifactNotFoundException {
TargetMap targetMap = buildTargetMap();
setTargetMap(targetMap);
// Since this is not a light test, the ArtifactLocationDecoder points to the actual file in the
// File System
artifactLocationDecoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
File f = new File(fileSystem.getRootDir(), artifactLocation.getExecutionRootRelativePath());
// Create the artifact if it does not exist
// This allows us to set fileModifiedTime for the file which is used by RenderJarCache
FileOperationProvider.getInstance().mkdirs(f);
// Set last modified time for RenderJarCache to use
FileOperationProvider.getInstance().setFileModifiedTime(f, 1000L);
return f;
}
};
registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(MockBlazeProjectDataBuilder.builder(workspaceRoot).setTargetMap(targetMap).setArtifactLocationDecoder(artifactLocationDecoder).build()));
setProjectView("targets:", " //com/google/example/simple/bin_a:bin_a", " //com/google/example/simple/bin_b:bin_b", " //com/google/example/simple/bin_c:bin_c");
MockExperimentService experimentService = new MockExperimentService();
registerApplicationComponent(ExperimentService.class, experimentService);
experimentService.setExperiment(RenderResolveOutputGroupProvider.buildOnSync, true);
// Disable resource resolution from Render Jars
experimentService.setExperiment(RenderJarClassFileFinder.resolveResourceClasses, false);
ApplicationManager.getApplication().runWriteAction(this::createAndRegisterModules);
artifactCache = new MockArtifactCache();
registerExtension(FileCache.EP_NAME, new RenderJarCache.FileCacheAdapter());
registerProjectService(RenderJarCache.class, new RenderJarCache(getProject(), RenderJarCache.getCacheDirForProject(getProject()), artifactCache));
createBinaryJars();
FileCache.EP_NAME.extensions().forEach(ep -> ep.initialize(getProject()));
}
use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.
the class FastBuildCompilerFactoryImplTest method setUp.
@Before
public void setUp() {
BlazeProjectData projectData = MockBlazeProjectDataBuilder.builder().setArtifactLocationDecoder(new MockArtifactLocationDecoder()).build();
BlazeProjectDataManager projectDataManager = new MockBlazeProjectDataManager(projectData);
compilerFactory = FastBuildCompilerFactoryImpl.createForTest(projectDataManager, FAST_BUILD_JAVAC_JAR);
}
Aggregations