Search in sources :

Example 1 with CompilerMessage

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

the class ExecutionTestCase method setUp.

@Override
protected void setUp() throws Exception {
    if (ourOutputRoot == null) {
        ourOutputRoot = FileUtil.createTempDirectory("ExecutionTestCase", null, true);
    }
    myModuleOutputDir = new File(ourOutputRoot, PathUtil.getFileName(getTestAppPath()));
    myChecker = initOutputChecker();
    EdtTestUtil.runInEdtAndWait(() -> super.setUp());
    if (!myModuleOutputDir.exists()) {
        VirtualFile vDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ourOutputRoot);
        assertNotNull(ourOutputRoot.getAbsolutePath(), vDir);
        //we need this to load children to VFS to fire VFileCreatedEvent for the output directory
        vDir.getChildren();
        myCompilerTester = new CompilerTester(myProject, Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
        List<CompilerMessage> messages = myCompilerTester.rebuild();
        for (CompilerMessage message : messages) {
            if (message.getCategory() == CompilerMessageCategory.ERROR) {
                FileUtil.delete(myModuleOutputDir);
                fail("Compilation failed: " + message);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CompilerMessage(com.intellij.openapi.compiler.CompilerMessage) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 2 with CompilerMessage

use of com.intellij.openapi.compiler.CompilerMessage 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)

Example 3 with CompilerMessage

use of com.intellij.openapi.compiler.CompilerMessage in project intellij-plugins by JetBrains.

the class FlexCompilationManager method checkFinishedTasks.

private void checkFinishedTasks() {
    final Iterator<FlexCompilationTask> iterator = myInProgressTasks.iterator();
    while (iterator.hasNext()) {
        FlexCompilationTask task = iterator.next();
        if (task.isFinished()) {
            iterator.remove();
            myFinishedTasks.add(task);
            if (task.isCompilationFailed()) {
                final Collection<FlexCompilationTask> cancelledTasks = cancelNotStartedDependentTasks(task);
                if (cancelledTasks.isEmpty()) {
                    addMessage(task, CompilerMessageCategory.INFORMATION, FlexCommonBundle.message("compilation.failed"), null, -1, -1);
                } else {
                    addMessage(task, CompilerMessageCategory.INFORMATION, FlexCommonBundle.message("compilation.failed.dependent.will.be.skipped"), null, -1, -1);
                    for (final FlexCompilationTask cancelledTask : cancelledTasks) {
                        addMessage(cancelledTask, CompilerMessageCategory.INFORMATION, FlexBundle.message("compilation.skipped"), null, -1, -1);
                    }
                }
            } else {
                addMessage(task, CompilerMessageCategory.INFORMATION, FlexCommonBundle.message("compilation.successful"), null, -1, -1);
                final String prefix = getMessagePrefix(task);
                final List<String> taskMessages = new ArrayList<>();
                for (CompilerMessage message : myCompileContext.getMessages(CompilerMessageCategory.INFORMATION)) {
                    if (message.getMessage().startsWith(prefix)) {
                        taskMessages.add(message.getMessage().substring(prefix.length()));
                    }
                }
                try {
                    FlexCompilationUtils.performPostCompileActions(task.getModule(), task.getBC(), taskMessages);
                } catch (FlexCompilerException e) {
                    addMessage(task, CompilerMessageCategory.ERROR, e.getMessage(), e.getUrl(), e.getLine(), e.getColumn());
                }
            }
            if (task.isCompilationFailed()) {
                myCompilerDependenciesCache.markBCDirty(task.getModule(), task.getBC());
            } else {
                //noinspection SynchronizeOnThis
                synchronized (this) {
                    myCompilerDependenciesCache.cacheBC(task.getModule(), task.getBC(), task.getConfigFiles());
                }
            }
        }
    }
}
Also used : CompilerMessage(com.intellij.openapi.compiler.CompilerMessage)

Example 4 with CompilerMessage

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

the class MavenCompilingTestCase method compile.

private void compile(final CompileScope scope) {
    try {
        CompilerTester tester = new CompilerTester(myProject, Arrays.asList(scope.getAffectedModules()));
        UIUtil.invokeAndWaitIfNeeded(new Runnable() {

            @Override
            public void run() {
                new MavenResourceCompilerConfigurationGenerator(myProject, MavenProjectsManager.getInstance(myProject).getProjectsTreeForTests()).generateBuildConfiguration(false);
            }
        });
        try {
            List<CompilerMessage> messages = tester.make(scope);
            for (CompilerMessage message : messages) {
                if (message.getCategory() == CompilerMessageCategory.ERROR) {
                    fail("Compilation failed with error: " + message.getMessage());
                }
            }
        } finally {
            tester.tearDown();
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MavenResourceCompilerConfigurationGenerator(org.jetbrains.idea.maven.project.MavenResourceCompilerConfigurationGenerator) CompilerMessage(com.intellij.openapi.compiler.CompilerMessage) CompilerTester(com.intellij.testFramework.CompilerTester) IOException(java.io.IOException)

Aggregations

CompilerMessage (com.intellij.openapi.compiler.CompilerMessage)4 CompileContext (com.intellij.openapi.compiler.CompileContext)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 CompilerTester (com.intellij.testFramework.CompilerTester)1 File (java.io.File)1 IOException (java.io.IOException)1 Matcher (java.util.regex.Matcher)1 MavenResourceCompilerConfigurationGenerator (org.jetbrains.idea.maven.project.MavenResourceCompilerConfigurationGenerator)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1