Ejemplo n.º 1
0
  private void openConfigurationDialog() {
    final CompilerConfigurationImpl configuration =
        (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myProject);
    final Collection<BackendCompiler> compilers = configuration.getRegisteredJavaCompilers();
    final BackendCompiler defaultCompiler = configuration.getDefaultCompiler();
    final JavaCompilersTab compilersTab =
        new JavaCompilersTab(myProject, compilers, defaultCompiler);

    ShowSettingsUtil.getInstance().editConfigurable(myProject, compilersTab);
  }
Ejemplo n.º 2
0
 public boolean isModified() {
   if (!Comparing.equal(mySelectedCompiler, myCompilerConfiguration.getDefaultCompiler())) {
     return true;
   }
   for (Configurable configurable : myConfigurables) {
     if (configurable.isModified()) {
       return true;
     }
   }
   return false;
 }
  private void excludeFromCompilationArchetypeResources() {
    VirtualFile directoryFile = myMavenProject.getDirectoryFile();

    VirtualFile archetypeResourcesDir =
        VfsUtil.findRelativeFile(directoryFile, "src", "main", "resources", "archetype-resources");

    if (archetypeResourcesDir != null) {
      Project project = myModule.getProject();

      CompilerConfigurationImpl compilerConfiguration =
          (CompilerConfigurationImpl) CompilerConfiguration.getInstance(project);

      if (!compilerConfiguration.isExcludedFromCompilation(archetypeResourcesDir)) {
        ExcludedEntriesConfiguration cfg = compilerConfiguration.getExcludedEntriesConfiguration();

        cfg.addExcludeEntryDescription(
            new ExcludeEntryDescription(archetypeResourcesDir, true, false, project));
      }
    }
  }
Ejemplo n.º 4
0
 public void reset() {
   for (Configurable configurable : myConfigurables) {
     configurable.reset();
   }
   selectCompiler(myCompilerConfiguration.getDefaultCompiler());
 }
Ejemplo n.º 5
0
 public void apply() throws ConfigurationException {
   for (Configurable configurable : myConfigurables) {
     configurable.apply();
   }
   myCompilerConfiguration.setDefaultCompiler(mySelectedCompiler);
 }
  private void configAnnotationProcessors() {
    if (Boolean.parseBoolean(System.getProperty("idea.maven.keep.annotation.processors"))) return;

    Sdk sdk = ModuleRootManager.getInstance(myModule).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;
        }
      }
    }

    CompilerConfigurationImpl compilerConfiguration =
        (CompilerConfigurationImpl) CompilerConfiguration.getInstance(myModule.getProject());

    ProcessorConfigProfile currentProfile =
        compilerConfiguration.getAnnotationProcessingConfiguration(myModule);

    String moduleProfileName = PROFILE_PREFIX + myModule.getName();

    if (currentProfile != compilerConfiguration.getDefaultProcessorProfile()
        && !MAVEN_DEFAULT_ANNOTATION_PROFILE.equals(currentProfile.getName())
        && !moduleProfileName.equals(currentProfile.getName())) {
      return;
    }

    ProcessorConfigProfile moduleProfile =
        compilerConfiguration.findModuleProcessorProfile(moduleProfileName);

    ProcessorConfigProfile defaultMavenProfile =
        compilerConfiguration.findModuleProcessorProfile(MAVEN_DEFAULT_ANNOTATION_PROFILE);

    if (shouldEnableAnnotationProcessors()) {
      String annotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(false);
      if (annotationProcessorDirectory == null) {
        annotationProcessorDirectory = DEFAULT_ANNOTATION_PATH_OUTPUT;
      }

      String testAnnotationProcessorDirectory = getRelativeAnnotationProcessorDirectory(true);
      if (testAnnotationProcessorDirectory == null) {
        testAnnotationProcessorDirectory = DEFAULT_TEST_ANNOTATION_OUTPUT;
      }

      Map<String, String> options = myMavenProject.getAnnotationProcessorOptions();

      List<String> processors = myMavenProject.getDeclaredAnnotationProcessors();

      if (processors == null
          && options.isEmpty()
          && DEFAULT_ANNOTATION_PATH_OUTPUT.equals(annotationProcessorDirectory.replace('\\', '/'))
          && DEFAULT_TEST_ANNOTATION_OUTPUT.equals(
              testAnnotationProcessorDirectory.replace('\\', '/'))) {
        if (moduleProfile != null) {
          compilerConfiguration.removeModuleProcessorProfile(moduleProfile);
        }

        if (defaultMavenProfile == null) {
          defaultMavenProfile = new ProcessorConfigProfileImpl(MAVEN_DEFAULT_ANNOTATION_PROFILE);
          defaultMavenProfile.setEnabled(true);
          defaultMavenProfile.setOutputRelativeToContentRoot(true);
          defaultMavenProfile.setObtainProcessorsFromClasspath(true);
          defaultMavenProfile.setGeneratedSourcesDirectoryName(
              DEFAULT_ANNOTATION_PATH_OUTPUT, false);
          defaultMavenProfile.setGeneratedSourcesDirectoryName(
              DEFAULT_TEST_ANNOTATION_OUTPUT, true);
          compilerConfiguration.addModuleProcessorProfile(defaultMavenProfile);
        }

        defaultMavenProfile.addModuleName(myModule.getName());
      } else {
        if (defaultMavenProfile != null) {
          defaultMavenProfile.removeModuleName(myModule.getName());

          if (defaultMavenProfile.getModuleNames().isEmpty()) {
            compilerConfiguration.removeModuleProcessorProfile(defaultMavenProfile);
          }
        }

        if (moduleProfile == null) {
          moduleProfile = new ProcessorConfigProfileImpl(moduleProfileName);
          moduleProfile.setOutputRelativeToContentRoot(true);
          moduleProfile.setEnabled(true);
          moduleProfile.setObtainProcessorsFromClasspath(true);
          moduleProfile.addModuleName(myModule.getName());
          compilerConfiguration.addModuleProcessorProfile(moduleProfile);
        }

        moduleProfile.setGeneratedSourcesDirectoryName(annotationProcessorDirectory, false);
        moduleProfile.setGeneratedSourcesDirectoryName(testAnnotationProcessorDirectory, true);

        moduleProfile.clearProcessorOptions();
        for (Map.Entry<String, String> entry : options.entrySet()) {
          moduleProfile.setOption(entry.getKey(), entry.getValue());
        }

        moduleProfile.clearProcessors();

        if (processors != null) {
          for (String processor : processors) {
            moduleProfile.addProcessor(processor);
          }
        }
      }
    } else {
      if (defaultMavenProfile != null) {
        defaultMavenProfile.removeModuleName(myModule.getName());

        if (defaultMavenProfile.getModuleNames().isEmpty()) {
          compilerConfiguration.removeModuleProcessorProfile(defaultMavenProfile);
        }
      }

      if (moduleProfile != null) {
        compilerConfiguration.removeModuleProcessorProfile(moduleProfile);
      }
    }
  }