Search in sources :

Example 1 with MockArtifactCache

use of com.google.idea.blaze.android.filecache.MockArtifactCache 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()));
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) MockArtifactCache(com.google.idea.blaze.android.filecache.MockArtifactCache) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) File(java.io.File) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) RenderJarCache(com.google.idea.blaze.android.libraries.RenderJarCache) Before(org.junit.Before)

Aggregations

MockArtifactCache (com.google.idea.blaze.android.filecache.MockArtifactCache)1 RenderJarCache (com.google.idea.blaze.android.libraries.RenderJarCache)1 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)1 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)1 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)1 MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)1 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)1 File (java.io.File)1 Before (org.junit.Before)1