Search in sources :

Example 1 with BlazeAndroidSyncPlugin

use of com.google.idea.blaze.android.sync.BlazeAndroidSyncPlugin 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());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeAndroidSyncPlugin(com.google.idea.blaze.android.sync.BlazeAndroidSyncPlugin) BlazeArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) IOException(java.io.IOException) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) FileCache(com.google.idea.blaze.base.filecache.FileCache) FileCacheAdapter(com.google.idea.blaze.android.libraries.UnpackedAars.FileCacheAdapter) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) DefaultPrefetcher(com.google.idea.blaze.base.prefetch.DefaultPrefetcher) File(java.io.File)

Aggregations

FileCacheAdapter (com.google.idea.blaze.android.libraries.UnpackedAars.FileCacheAdapter)1 BlazeAndroidSyncPlugin (com.google.idea.blaze.android.sync.BlazeAndroidSyncPlugin)1 BlazeArtifact (com.google.idea.blaze.base.command.buildresult.BlazeArtifact)1 FileCache (com.google.idea.blaze.base.filecache.FileCache)1 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)1 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 DefaultPrefetcher (com.google.idea.blaze.base.prefetch.DefaultPrefetcher)1 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)1 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)1 BlazeSyncPlugin (com.google.idea.blaze.base.sync.BlazeSyncPlugin)1 MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)1 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)1 File (java.io.File)1 IOException (java.io.IOException)1