Search in sources :

Example 1 with AndroidGradleBuildConfiguration

use of com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration in project android by JetBrains.

the class IdeFrameFixture method invokeProjectMakeUsingJps.

@NotNull
public CompileContext invokeProjectMakeUsingJps() {
    Project project = getProject();
    AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
    buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = false;
    AtomicReference<CompileContext> contextRef = new AtomicReference<>();
    CompilerManager compilerManager = CompilerManager.getInstance(project);
    Disposable disposable = new NoOpDisposable();
    compilerManager.addCompilationStatusListener(new CompilationStatusListener() {

        @Override
        public void compilationFinished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
            contextRef.set(compileContext);
        }
    }, disposable);
    try {
        selectProjectMakeAction();
        Wait.seconds(10).expecting("Build (" + COMPILE_JAVA + ") for project " + quote(project.getName()) + " to finish'").until(() -> contextRef.get() != null);
        return contextRef.get();
    } finally {
        Disposer.dispose(disposable);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) Project(com.intellij.openapi.project.Project) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompilationStatusListener(com.intellij.openapi.compiler.CompilationStatusListener) AndroidGradleBuildConfiguration(com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) CompileContext(com.intellij.openapi.compiler.CompileContext) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with AndroidGradleBuildConfiguration

use of com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration in project android by JetBrains.

the class IdeFrameFixture method waitForGradleProjectSyncToFinish.

private void waitForGradleProjectSyncToFinish(boolean expectSyncFailure) {
    Project project = getProject();
    // ensure GradleInvoker (in-process build) is always enabled.
    AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
    buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = true;
    Wait.seconds(10).expecting("Syncing project " + quote(project.getName()) + " to finish").until(() -> {
        GradleSyncState syncState = GradleSyncState.getInstance(project);
        boolean syncFinished = (myGradleProjectEventListener.isSyncFinished() || syncState.isSyncNeeded() != ThreeState.YES) && !syncState.isSyncInProgress();
        if (expectSyncFailure) {
            syncFinished = syncFinished && myGradleProjectEventListener.hasSyncError();
        }
        return syncFinished;
    });
    waitForGradleSyncAction();
    if (myGradleProjectEventListener.hasSyncError()) {
        RuntimeException syncError = myGradleProjectEventListener.getSyncError();
        myGradleProjectEventListener.reset();
        throw syncError;
    }
    if (!myGradleProjectEventListener.isSyncSkipped()) {
        waitForBuildToFinish(SOURCE_GEN);
    }
    GuiTests.waitForBackgroundTasks(robot());
}
Also used : Project(com.intellij.openapi.project.Project) AndroidGradleBuildConfiguration(com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState)

Aggregations

AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)2 Project (com.intellij.openapi.project.Project)2 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)1 Disposable (com.intellij.openapi.Disposable)1 CompilationStatusListener (com.intellij.openapi.compiler.CompilationStatusListener)1 CompileContext (com.intellij.openapi.compiler.CompileContext)1 CompilerManager (com.intellij.openapi.compiler.CompilerManager)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assert.assertNotNull (junit.framework.Assert.assertNotNull)1 NotNull (org.jetbrains.annotations.NotNull)1