Search in sources :

Example 1 with GradleSyncSummary

use of com.android.tools.idea.gradle.project.sync.GradleSyncSummary in project android by JetBrains.

the class GradleVersionsTest method simulateGradleSyncStateReturnNullGradleVersion.

private void simulateGradleSyncStateReturnNullGradleVersion() {
    GradleSyncState syncState = mock(GradleSyncState.class);
    IdeComponents.replaceService(getProject(), GradleSyncState.class, syncState);
    GradleSyncSummary summary = mock(GradleSyncSummary.class);
    when(summary.getGradleVersion()).thenReturn(null);
    when(syncState.getSummary()).thenReturn(summary);
}
Also used : GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 2 with GradleSyncSummary

use of com.android.tools.idea.gradle.project.sync.GradleSyncSummary in project android by JetBrains.

the class GradleModuleSetup method setUpModule.

public void setUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull GradleModuleModel model) {
    GradleFacet facet = findFacet(module, ideModelsProvider, GradleFacet.getFacetTypeId());
    if (facet == null) {
        ModifiableFacetModel facetModel = ideModelsProvider.getModifiableFacetModel(module);
        GradleFacetType facetType = GradleFacet.getFacetType();
        facet = facetType.createFacet(module, GradleFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
        facetModel.addFacet(facet);
    }
    facet.setGradleModuleModel(model);
    String gradleVersion = model.getGradleVersion();
    GradleSyncSummary syncReport = GradleSyncState.getInstance(module.getProject()).getSummary();
    if (isNotEmpty(gradleVersion) && syncReport.getGradleVersion() == null) {
        syncReport.setGradleVersion(GradleVersion.parse(gradleVersion));
    }
}
Also used : ModifiableFacetModel(com.intellij.facet.ModifiableFacetModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) GradleFacetType(com.android.tools.idea.gradle.project.facet.gradle.GradleFacetType) GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary)

Example 3 with GradleSyncSummary

use of com.android.tools.idea.gradle.project.sync.GradleSyncSummary in project android by JetBrains.

the class GradleProjectInfoTest method registerLastSyncTimestamp.

private void registerLastSyncTimestamp(long timestamp) {
    GradleSyncSummary summary = mock(GradleSyncSummary.class);
    when(summary.getSyncTimestamp()).thenReturn(timestamp);
    GradleSyncState syncState = IdeComponents.replaceServiceWithMock(getProject(), GradleSyncState.class);
    when(syncState.getSummary()).thenReturn(summary);
}
Also used : GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Example 4 with GradleSyncSummary

use of com.android.tools.idea.gradle.project.sync.GradleSyncSummary in project android by JetBrains.

the class JdkModuleSetupStepTest method testSetUpInAndroidStudio.

public void testSetUpInAndroidStudio() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
    assertNotNull(androidModel);
    Sdk jdk = mock(Sdk.class);
    when(myIdeSdks.getJdk()).thenReturn(jdk);
    when(myJdks.isApplicableJdk(jdk, JDK_1_7)).thenReturn(false);
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
    mySetupStep.setUpInAndroidStudio(appModule, androidModel);
    SyncMessage message = syncMessages.getFirstReportedMessage();
    assertNotNull(message);
    String[] text = message.getText();
    assertThat(text).isNotEmpty();
    assertThat(text[0]).matches("compileSdkVersion (.*) requires compiling with JDK 7 or newer.");
    GradleSyncSummary summary = GradleSyncState.getInstance(getProject()).getSummary();
    assertTrue(summary.hasSyncErrors());
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 5 with GradleSyncSummary

use of com.android.tools.idea.gradle.project.sync.GradleSyncSummary in project android by JetBrains.

the class GradleModuleSetupTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initMocks(this);
    Project project = getProject();
    IdeComponents.replaceService(project, GradleSyncState.class, mySyncState);
    String moduleName = "app";
    myModule = createModule(moduleName);
    IdeaProjectStub projectModel = new IdeaProjectStub(project.getName());
    myModuleModel = projectModel.addModule(moduleName, "task1", "task2");
    mySyncSummary = new GradleSyncSummary(project);
    when(mySyncState.getSummary()).thenReturn(mySyncSummary);
    myModelsProvider = new IdeModifiableModelsProviderImpl(project);
    myModuleSetup = new GradleModuleSetup();
}
Also used : Project(com.intellij.openapi.project.Project) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) IdeaProjectStub(com.android.tools.idea.gradle.stubs.gradle.IdeaProjectStub)

Aggregations

GradleSyncSummary (com.android.tools.idea.gradle.project.sync.GradleSyncSummary)6 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)2 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)2 Project (com.intellij.openapi.project.Project)2 AndroidPluginVersionUpdater (com.android.tools.idea.gradle.plugin.AndroidPluginVersionUpdater)1 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)1 GradleFacetType (com.android.tools.idea.gradle.project.facet.gradle.GradleFacetType)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)1 IdeaProjectStub (com.android.tools.idea.gradle.stubs.gradle.IdeaProjectStub)1 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)1 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)1 Module (com.intellij.openapi.module.Module)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1