Search in sources :

Example 16 with CompileContext

use of com.intellij.openapi.compiler.CompileContext in project intellij-community by JetBrains.

the class GradleCompilingTestCase method setUpInWriteAction.

@Override
protected void setUpInWriteAction() throws Exception {
    super.setUpInWriteAction();
    final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(myProject);
    CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            AccessToken token = ReadAction.start();
            try {
                buildConfigurationGenerator.generateBuildConfiguration(context);
            } finally {
                token.finish();
            }
            return true;
        }
    });
}
Also used : GradleResourceCompilerConfigurationGenerator(org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator) CompileTask(com.intellij.openapi.compiler.CompileTask) AccessToken(com.intellij.openapi.application.AccessToken) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 17 with CompileContext

use of com.intellij.openapi.compiler.CompileContext in project android by JetBrains.

the class AndroidCompileUtil method doGenerate.

public static boolean doGenerate(AndroidFacet facet, final AndroidAutogeneratorMode mode) {
    assert !ApplicationManager.getApplication().isDispatchThread();
    final CompileContext[] contextWrapper = new CompileContext[1];
    final Module module = facet.getModule();
    final Project project = module.getProject();
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            if (project.isDisposed())
                return;
            CompilerTask task = new CompilerTask(project, "Android auto-generation", true, false, true, true);
            CompileScope scope = new ModuleCompileScope(module, false);
            contextWrapper[0] = new CompileContextImpl(project, task, scope, false, false);
        }
    });
    CompileContext context = contextWrapper[0];
    if (context == null) {
        return false;
    }
    generate(facet, mode, context, false);
    return context.getMessages(CompilerMessageCategory.ERROR).length == 0;
}
Also used : Project(com.intellij.openapi.project.Project) ModuleCompileScope(com.intellij.compiler.impl.ModuleCompileScope) CompileScope(com.intellij.openapi.compiler.CompileScope) ArtifactCompileScope(com.intellij.packaging.impl.compiler.ArtifactCompileScope) CompilerTask(com.intellij.compiler.progress.CompilerTask) CompileContextImpl(com.intellij.compiler.impl.CompileContextImpl) Module(com.intellij.openapi.module.Module) CompileContext(com.intellij.openapi.compiler.CompileContext) ModuleCompileScope(com.intellij.compiler.impl.ModuleCompileScope)

Example 18 with CompileContext

use of com.intellij.openapi.compiler.CompileContext in project android by JetBrains.

the class MultipleModuleTypeCompilationTest method testAssembleTaskIsNotInvokedForLocalAarModuleOnJps.

@Ignore("failed in http://go/aj/job/studio-ui-test/345 and from IDEA")
@Test
public void testAssembleTaskIsNotInvokedForLocalAarModuleOnJps() throws IOException {
    guiTest.importProjectAndWaitForProjectSyncToFinish("MultipleModuleTypes");
    CompileContext context = guiTest.ideFrame().invokeProjectMakeUsingJps();
    String[] invokedTasks = null;
    for (CompilerMessage msg : context.getMessages(INFORMATION)) {
        String text = msg.getMessage();
        Matcher matcher = JPS_EXECUTING_TASKS_MSG_PATTERN.matcher(text);
        if (matcher.matches()) {
            String allTasks = matcher.group(1);
            invokedTasks = allTasks.split(", ");
            break;
        }
    }
    // In JPS we cannot call "compileJava" because in JPS "Make" means "assemble".
    assertThat(invokedTasks).asList().containsExactly(":app:assembleDebug", ":javaLib:assemble");
    int errorCount = context.getMessageCount(ERROR);
    assertEquals(0, errorCount);
}
Also used : CompilerMessage(com.intellij.openapi.compiler.CompilerMessage) Matcher(java.util.regex.Matcher) CompileContext(com.intellij.openapi.compiler.CompileContext) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CompileContext (com.intellij.openapi.compiler.CompileContext)18 CompilerManager (com.intellij.openapi.compiler.CompilerManager)9 CompileStatusNotification (com.intellij.openapi.compiler.CompileStatusNotification)8 CompileTask (com.intellij.openapi.compiler.CompileTask)6 Module (com.intellij.openapi.module.Module)5 Project (com.intellij.openapi.project.Project)5 CompileScope (com.intellij.openapi.compiler.CompileScope)4 AccessToken (com.intellij.openapi.application.AccessToken)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)3 FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)2 CompilationStatusListener (com.intellij.openapi.compiler.CompilationStatusListener)2 NotNull (org.jetbrains.annotations.NotNull)2 GradleResourceCompilerConfigurationGenerator (org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator)2 AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)1 PsiClassWriter (com.intellij.compiler.PsiClassWriter)1 CompileContextImpl (com.intellij.compiler.impl.CompileContextImpl)1 ModuleCompileScope (com.intellij.compiler.impl.ModuleCompileScope)1 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)1 CompilerTask (com.intellij.compiler.progress.CompilerTask)1