Search in sources :

Example 6 with CompilerManager

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

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

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

the class AndroidProjectComponent method projectOpened.

@Override
public void projectOpened() {
    final CompilerManager manager = CompilerManager.getInstance(myProject);
    manager.addBeforeTask(new AndroidPrecompileTask());
    myDisposable = Disposer.newDisposable(getClass().getName());
    if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
        if (ProjectFacetManager.getInstance(myProject).hasFacets(AndroidFacet.ID)) {
            createAndroidSpecificComponents();
        } else {
            final MessageBusConnection connection = myProject.getMessageBus().connect(myDisposable);
            connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {

                @Override
                public void facetAdded(@NotNull Facet facet) {
                    if (facet instanceof AndroidFacet) {
                        createAndroidSpecificComponents();
                        connection.disconnect();
                    }
                }
            });
        }
    }
}
Also used : AndroidPrecompileTask(org.jetbrains.android.compiler.AndroidPrecompileTask) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) CompilerManager(com.intellij.openapi.compiler.CompilerManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) FacetManagerAdapter(com.intellij.facet.FacetManagerAdapter) Facet(com.intellij.facet.Facet) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 9 with CompilerManager

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

the class AndroidCompileUtil method isExcludedFromCompilation.

public static boolean isExcludedFromCompilation(VirtualFile child, @Nullable Project project) {
    final CompilerManager compilerManager = project != null ? CompilerManager.getInstance(project) : null;
    if (compilerManager == null) {
        return false;
    }
    if (!compilerManager.isExcludedFromCompilation(child)) {
        return false;
    }
    final Module module = ModuleUtil.findModuleForFile(child, project);
    if (module == null) {
        return true;
    }
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null || facet.isAppProject()) {
        return true;
    }
    final AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
    if (platform == null) {
        return true;
    }
    // we exclude sources of library modules automatically for tools r7 or previous
    return platform.getSdkData().getPlatformToolsRevision() > 7;
}
Also used : CompilerManager(com.intellij.openapi.compiler.CompilerManager) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 10 with CompilerManager

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

Aggregations

CompilerManager (com.intellij.openapi.compiler.CompilerManager)22 CompileContext (com.intellij.openapi.compiler.CompileContext)9 Module (com.intellij.openapi.module.Module)6 CompileScope (com.intellij.openapi.compiler.CompileScope)5 CompileStatusNotification (com.intellij.openapi.compiler.CompileStatusNotification)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NotNull (org.jetbrains.annotations.NotNull)5 CompileTask (com.intellij.openapi.compiler.CompileTask)3 Project (com.intellij.openapi.project.Project)3 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 FileType (com.intellij.openapi.fileTypes.FileType)2 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)2 PsiFile (com.intellij.psi.PsiFile)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JavaArtifact (com.android.builder.model.JavaArtifact)1 AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1