Search in sources :

Example 6 with CompileContext

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

the class PrepareToDeployAction method doPrepare.

public void doPrepare(final List<Module> pluginModules, final Project project) {
    final List<String> errorMessages = new ArrayList<>();
    final List<String> successMessages = new ArrayList<>();
    final CompilerManager compilerManager = CompilerManager.getInstance(project);
    compilerManager.make(compilerManager.createModulesCompileScope(pluginModules.toArray(new Module[pluginModules.size()]), true), new CompileStatusNotification() {

        public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
            if (aborted || errors != 0)
                return;
            ApplicationManager.getApplication().invokeLater(() -> {
                for (Module aModule : pluginModules) {
                    if (!doPrepare(aModule, errorMessages, successMessages)) {
                        return;
                    }
                }
                if (!errorMessages.isEmpty()) {
                    Messages.showErrorDialog(errorMessages.iterator().next(), DevKitBundle.message("error.occurred"));
                } else if (!successMessages.isEmpty()) {
                    StringBuilder messageBuf = new StringBuilder();
                    for (String message : successMessages) {
                        if (messageBuf.length() != 0) {
                            messageBuf.append('\n');
                        }
                        messageBuf.append(message);
                    }
                    final String title = pluginModules.size() == 1 ? DevKitBundle.message("success.deployment.message", pluginModules.get(0).getName()) : DevKitBundle.message("success.deployment.message.all");
                    NOTIFICATION_GROUP.createNotification(title, messageBuf.toString(), NotificationType.INFORMATION, null).notify(project);
                }
            }, project.getDisposed());
        }
    });
}
Also used : CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) CompilerManager(com.intellij.openapi.compiler.CompilerManager) Module(com.intellij.openapi.module.Module) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 7 with CompileContext

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

the class AppEngineUploader method compileAndUpload.

private void compileAndUpload() {
    final Runnable startUploading = () -> ApplicationManager.getApplication().invokeLater(() -> startUploadingProcess());
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    final CompileScope moduleScope = compilerManager.createModuleCompileScope(myAppEngineFacet.getModule(), true);
    final CompileScope compileScope = ArtifactCompileScope.createScopeWithArtifacts(moduleScope, Collections.singletonList(myArtifact));
    ApplicationManager.getApplication().invokeLater(() -> compilerManager.make(compileScope, new CompileStatusNotification() {

        public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
            if (!aborted && errors == 0) {
                startUploading.run();
            }
        }
    }));
}
Also used : CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) CompileScope(com.intellij.openapi.compiler.CompileScope) ArtifactCompileScope(com.intellij.packaging.impl.compiler.ArtifactCompileScope) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 8 with CompileContext

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

the class AirPackageAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return;
    final AirPackageDialog dialog = new AirPackageDialog(project);
    if (!dialog.showAndGet()) {
        return;
    }
    final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCs = dialog.getSelectedBCs();
    final Set<Module> modules = new THashSet<>();
    for (Pair<Module, FlexBuildConfiguration> bc : modulesAndBCs) {
        modules.add(bc.first);
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(project);
    final CompileScope compileScope = compilerManager.createModulesCompileScope(modules.toArray(new Module[modules.size()]), false);
    FlexResourceBuildTargetScopeProvider.setBCsToCompileForPackaging(compileScope, modulesAndBCs);
    compilerManager.make(compileScope, new CompileStatusNotification() {

        public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
            if (!aborted && errors == 0) {
                createPackages(project, modulesAndBCs, dialog.getPasswords());
            }
        }
    });
}
Also used : CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext) THashSet(gnu.trove.THashSet) Project(com.intellij.openapi.project.Project) CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) CompileScope(com.intellij.openapi.compiler.CompileScope) Module(com.intellij.openapi.module.Module) Pair(com.intellij.openapi.util.Pair)

Example 9 with CompileContext

use of com.intellij.openapi.compiler.CompileContext 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 10 with CompileContext

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

the class ClassFilesIndexFeaturesHolder method projectOpened.

@Override
public final void projectOpened() {
    for (final ClassFilesIndexFeature feature : ClassFilesIndexFeature.values()) {
        final RegistryValue registryValue = feature.getRegistryValue();
        registryValue.addListener(new RegistryValueListener.Adapter() {

            @Override
            public void afterValueChanged(final RegistryValue rawValue) {
                if (!rawValue.asBoolean() && myEnabledFeatures.containsKey(feature)) {
                    disposeFeature(feature);
                }
            }
        }, myProject);
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    compilerManager.addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(final CompileContext context) {
            close();
            return true;
        }
    });
}
Also used : CompileTask(com.intellij.openapi.compiler.CompileTask) RegistryValue(com.intellij.openapi.util.registry.RegistryValue) CompilerManager(com.intellij.openapi.compiler.CompilerManager) RegistryValueListener(com.intellij.openapi.util.registry.RegistryValueListener) CompileContext(com.intellij.openapi.compiler.CompileContext)

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