Search in sources :

Example 1 with CompilerConfigurationImpl

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

the class MavenAnnotationProcessorConfigurer method configure.

@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
    if (module == null)
        return;
    Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (sdk != null) {
        String versionString = sdk.getVersionString();
        if (versionString != null) {
            if (versionString.contains("1.5") || versionString.contains("1.4") || versionString.contains("1.3") || versionString.contains("1.2")) {
                return;
            }
        }
    }
    final CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
    final MavenProject rootProject = ObjectUtils.notNull(MavenProjectsManager.getInstance(project).findRootProject(mavenProject), mavenProject);
    if (shouldEnableAnnotationProcessors(mavenProject)) {
        final String moduleProfileName;
        String annotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(mavenProject, false);
        if (annotationProcessorDirectory == null) {
            annotationProcessorDirectory = DEFAULT_ANNOTATION_PATH_OUTPUT;
        }
        String testAnnotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(mavenProject, true);
        if (testAnnotationProcessorDirectory == null) {
            testAnnotationProcessorDirectory = DEFAULT_TEST_ANNOTATION_OUTPUT;
        }
        final boolean isDefault;
        if (isMavenDefaultAnnotationProcessorConfiguration(annotationProcessorDirectory, testAnnotationProcessorDirectory, mavenProject)) {
            moduleProfileName = MAVEN_DEFAULT_ANNOTATION_PROFILE;
            isDefault = true;
        } else if (isMavenProcessorPluginDefaultConfiguration(annotationProcessorDirectory, testAnnotationProcessorDirectory, mavenProject)) {
            moduleProfileName = MAVEN_BSC_DEFAULT_ANNOTATION_PROFILE;
            isDefault = true;
        } else {
            moduleProfileName = PROFILE_PREFIX + module.getName();
            isDefault = false;
        }
        ProcessorConfigProfile moduleProfile = compilerConfiguration.findModuleProcessorProfile(moduleProfileName);
        if (moduleProfile == null) {
            moduleProfile = new ProcessorConfigProfileImpl(moduleProfileName);
            compilerConfiguration.addModuleProcessorProfile(moduleProfile);
        }
        moduleProfile.setOutputRelativeToContentRoot(true);
        moduleProfile.setEnabled(true);
        moduleProfile.setObtainProcessorsFromClasspath(true);
        moduleProfile.setGeneratedSourcesDirectoryName(annotationProcessorDirectory, false);
        moduleProfile.setGeneratedSourcesDirectoryName(testAnnotationProcessorDirectory, true);
        moduleProfile.clearProcessorOptions();
        for (Map.Entry<String, String> entry : mavenProject.getAnnotationProcessorOptions().entrySet()) {
            moduleProfile.setOption(entry.getKey(), entry.getValue());
        }
        moduleProfile.clearProcessors();
        final List<String> processors = mavenProject.getDeclaredAnnotationProcessors();
        if (processors != null) {
            for (String processor : processors) {
                moduleProfile.addProcessor(processor);
            }
        }
        moduleProfile.addModuleName(module.getName());
        cleanAndMergeModuleProfiles(rootProject, compilerConfiguration, moduleProfile, isDefault, module);
    } else {
        cleanAndMergeModuleProfiles(rootProject, compilerConfiguration, null, false, module);
    }
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile) Sdk(com.intellij.openapi.projectRoots.Sdk) ProcessorConfigProfileImpl(org.jetbrains.jps.model.java.impl.compiler.ProcessorConfigProfileImpl) Map(java.util.Map)

Example 2 with CompilerConfigurationImpl

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

the class AnnotationProcessorsConfigurable method isModified.

public boolean isModified() {
    final CompilerConfigurationImpl config = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
    if (!config.getDefaultProcessorProfile().equals(myMainPanel.getDefaultProfile())) {
        return true;
    }
    final Map<String, ProcessorConfigProfile> configProfiles = new java.util.HashMap<>();
    for (ProcessorConfigProfile profile : config.getModuleProcessorProfiles()) {
        configProfiles.put(profile.getName(), profile);
    }
    final List<ProcessorConfigProfile> panelProfiles = myMainPanel.getModuleProfiles();
    if (configProfiles.size() != panelProfiles.size()) {
        return true;
    }
    for (ProcessorConfigProfile panelProfile : panelProfiles) {
        final ProcessorConfigProfile configProfile = configProfiles.get(panelProfile.getName());
        if (configProfile == null || !configProfile.equals(panelProfile)) {
            return true;
        }
    }
    return false;
}
Also used : CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl) ProcessorConfigProfile(org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)

Example 3 with CompilerConfigurationImpl

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

the class AnnotationProcessorsConfigurable method reset.

public void reset() {
    final CompilerConfigurationImpl config = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
    myMainPanel.initProfiles(config.getDefaultProcessorProfile(), config.getModuleProcessorProfiles());
}
Also used : CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl)

Example 4 with CompilerConfigurationImpl

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

the class CompilerUIConfigurable method reset.

public void reset() {
    final CompilerConfigurationImpl configuration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
    final CompilerWorkspaceConfiguration workspaceConfiguration = CompilerWorkspaceConfiguration.getInstance(myProject);
    myCbAutoShowFirstError.setSelected(workspaceConfiguration.AUTO_SHOW_ERRORS_IN_EDITOR);
    myCbDisplayNotificationPopup.setSelected(workspaceConfiguration.DISPLAY_NOTIFICATION_POPUP);
    myCbClearOutputDirectory.setSelected(workspaceConfiguration.CLEAR_OUTPUT_DIRECTORY);
    myCbAssertNotNull.setSelected(configuration.isAddNotNullAssertions());
    myCbEnableAutomake.setSelected(workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
    myCbParallelCompilation.setSelected(workspaceConfiguration.PARALLEL_COMPILATION);
    myCbRebuildOnDependencyChange.setSelected(workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
    // for compatibility with older projects
    final int javacPreferred = JavacConfiguration.getOptions(myProject, JavacConfiguration.class).MAXIMUM_HEAP_SIZE;
    myHeapSizeField.setText(String.valueOf(configuration.getBuildProcessHeapSize(javacPreferred)));
    final String options = workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
    myVMOptionsField.setText(options == null ? "" : options.trim());
    mySharedVMOptionsField.setText(configuration.getBuildProcessVMOptions());
    configuration.convertPatterns();
    myResourcePatternsField.setText(patternsToString(configuration.getResourceFilePatterns()));
    if (PowerSaveMode.isEnabled()) {
        myEnableAutomakeLegendLabel.setText("(disabled in Power Save mode)");
        myEnableAutomakeLegendLabel.setFont(myEnableAutomakeLegendLabel.getFont().deriveFont(Font.BOLD));
    } else {
        myEnableAutomakeLegendLabel.setText("(only works while not running / debugging)");
        myEnableAutomakeLegendLabel.setFont(myEnableAutomakeLegendLabel.getFont().deriveFont(Font.PLAIN));
    }
}
Also used : CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl) JavacConfiguration(com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration) CompilerWorkspaceConfiguration(com.intellij.compiler.CompilerWorkspaceConfiguration)

Example 5 with CompilerConfigurationImpl

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

the class CompilerExcludes method isAvailable.

public static boolean isAvailable(Project project) {
    final CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);
    final ExcludeEntryDescription[] excludeEntryDescriptions = compilerConfiguration.getExcludedEntriesConfiguration().getExcludeEntryDescriptions();
    return excludeEntryDescriptions.length > 0;
}
Also used : ExcludeEntryDescription(com.intellij.openapi.compiler.options.ExcludeEntryDescription) CompilerConfigurationImpl(com.intellij.compiler.CompilerConfigurationImpl)

Aggregations

CompilerConfigurationImpl (com.intellij.compiler.CompilerConfigurationImpl)11 CompilerWorkspaceConfiguration (com.intellij.compiler.CompilerWorkspaceConfiguration)3 ExcludeEntryDescription (com.intellij.openapi.compiler.options.ExcludeEntryDescription)2 ProcessorConfigProfile (org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile)2 BackendCompiler (com.intellij.compiler.impl.javaCompiler.BackendCompiler)1 JavacConfiguration (com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration)1 ExcludesConfiguration (com.intellij.openapi.compiler.options.ExcludesConfiguration)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 Map (java.util.Map)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1 ProcessorConfigProfileImpl (org.jetbrains.jps.model.java.impl.compiler.ProcessorConfigProfileImpl)1