IDEA-138564 Maven: removed configuration/target element in maven-compiler-plugin does not update target bytecode version in Settings

IDEA-138571 Maven+AspectJ: if for the same module both maven-compiler-plugin and aspectj-maven-plugin set the target bytecode version, use aspectj one
This commit is contained in:
Vladislav.Soroka
2015-04-01 19:29:10 +03:00
parent 838c6f2301
commit 7440dad232
2 changed files with 15 additions and 2 deletions
@@ -20,6 +20,7 @@ import com.intellij.openapi.compiler.options.ExcludeEntryDescription;
import com.intellij.openapi.compiler.options.ExcludesConfiguration;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ObjectUtils;
@@ -31,16 +32,21 @@ import org.jetbrains.idea.maven.project.MavenProject;
* @author Sergey Evdokimov
*/
public class MavenCompilerConfigurer extends MavenModuleConfigurer {
public static final Key<Boolean> IGNORE_MAVEN_COMPILER_TARGET_KEY = Key.create("idea.maven.skip.compiler.target.level");
@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
if (module == null) return;
CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
String targetLevel = mavenProject.getTargetLevel();
if (targetLevel != null || configuration.getBytecodeTargetLevel(module) == null) {
Boolean ignoreMavenCompilerTargetOption = module.getUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY);
if (ignoreMavenCompilerTargetOption == null || !ignoreMavenCompilerTargetOption.booleanValue()) {
String targetLevel = mavenProject.getTargetLevel();
// default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
configuration.setBytecodeTargetLevel(module, ObjectUtils.notNull(targetLevel, "1.5"));
}
module.putUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY, Boolean.FALSE);
// Exclude src/main/archetype-resources
VirtualFile dir = VfsUtil.findRelativeFile(mavenProject.getDirectoryFile(), "src", "main", "resources", "archetype-resources");
@@ -292,6 +292,13 @@ public class ReimportingTest extends MavenImportingTestCase {
importProject();
assertEquals("1.6", CompilerConfiguration.getInstance(myProject).getBytecodeTargetLevel(getModule("m1")));
// after configuration/target element delete in maven-compiler-plugin CompilerConfiguration#getBytecodeTargetLevel should be also updated
createModulePom("m1", "<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
importProject();
assertEquals("1.5", CompilerConfiguration.getInstance(myProject).getBytecodeTargetLevel(getModule("m1")));
}
private static String createPomXmlWithModuleDependency(final String dependencyType) {