From 1c059d3fef2ba8ed7259eff61685654861447431 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 12 Feb 2013 12:35:26 +0400 Subject: [PATCH 1/3] don't instantiate httpRequestHandlers if we don't need it --- .../org/jetbrains/ide/HttpRequestHandler.java | 7 ++--- .../org/jetbrains/ide/WebServerManager.java | 5 ++++ .../com/intellij/ide/XmlRpcServerImpl.java | 4 +-- .../jetbrains/ide/WebServerManagerImpl.java | 12 ++++----- .../src/org/jetbrains/io/WebServer.java | 27 +++++++------------ 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/platform/platform-api/src/org/jetbrains/ide/HttpRequestHandler.java b/platform/platform-api/src/org/jetbrains/ide/HttpRequestHandler.java index 62082dcc684a..4745524a01b9 100644 --- a/platform/platform-api/src/org/jetbrains/ide/HttpRequestHandler.java +++ b/platform/platform-api/src/org/jetbrains/ide/HttpRequestHandler.java @@ -23,13 +23,10 @@ import org.jboss.netty.handler.codec.http.QueryStringDecoder; import java.io.IOException; public abstract class HttpRequestHandler { - public boolean isSupported(HttpMethod method) { - return method == HttpMethod.GET; + public boolean isSupported(HttpRequest request) { + return request.getMethod() == HttpMethod.GET; } public abstract boolean process(QueryStringDecoder urlDecoder, HttpRequest request, ChannelHandlerContext context) throws IOException; - - public void serverStopping() { - } } diff --git a/platform/platform-api/src/org/jetbrains/ide/WebServerManager.java b/platform/platform-api/src/org/jetbrains/ide/WebServerManager.java index a2fa6e0802fb..c33154ef57bb 100644 --- a/platform/platform-api/src/org/jetbrains/ide/WebServerManager.java +++ b/platform/platform-api/src/org/jetbrains/ide/WebServerManager.java @@ -15,8 +15,10 @@ */ package org.jetbrains.ide; +import com.intellij.openapi.Disposable; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.Nullable; public abstract class WebServerManager { // Your handler will be instantiated on first user request @@ -29,4 +31,7 @@ public abstract class WebServerManager { public abstract int getPort(); public abstract WebServerManager waitForStart(); + + @Nullable + public abstract Disposable getServerDisposable(); } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java index b904be2001bb..aa17b7806f69 100644 --- a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java @@ -79,8 +79,8 @@ public class XmlRpcServerImpl implements XmlRpcServer { static final class XmlRpcRequestHandler extends HttpRequestHandler { @Override - public boolean isSupported(HttpMethod method) { - return method == HttpMethod.POST || method == HttpMethod.OPTIONS; + public boolean isSupported(HttpRequest request) { + return request == HttpMethod.POST || request == HttpMethod.OPTIONS; } @Override diff --git a/platform/platform-impl/src/org/jetbrains/ide/WebServerManagerImpl.java b/platform/platform-impl/src/org/jetbrains/ide/WebServerManagerImpl.java index ca859a3a762b..854374c04033 100644 --- a/platform/platform-impl/src/org/jetbrains/ide/WebServerManagerImpl.java +++ b/platform/platform-impl/src/org/jetbrains/ide/WebServerManagerImpl.java @@ -12,6 +12,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.startup.StartupActivity; +import com.intellij.openapi.util.Disposer; import org.jboss.netty.channel.ChannelException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -21,7 +22,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; -class WebServerManagerImpl extends WebServerManager implements Disposable { +class WebServerManagerImpl extends WebServerManager { private static final Logger LOG = Logger.getInstance(WebServerManager.class); @NonNls @@ -102,6 +103,7 @@ class WebServerManagerImpl extends WebServerManager implements Disposable { return; } + Disposer.register(ApplicationManager.getApplication(), server); detectedPortNumber = server.start(getDefaultPort(), PORTS_COUNT, true); if (detectedPortNumber == -1) { LOG.info("web server cannot be started, cannot bind to port"); @@ -114,10 +116,8 @@ class WebServerManagerImpl extends WebServerManager implements Disposable { } @Override - public void dispose() { - if (started.get() && server != null) { - server.stop(); - LOG.info("web server stopped"); - } + @Nullable + public Disposable getServerDisposable() { + return server; } } \ No newline at end of file diff --git a/platform/platform-impl/src/org/jetbrains/io/WebServer.java b/platform/platform-impl/src/org/jetbrains/io/WebServer.java index e3398f6babb7..90d89cbd1ca0 100644 --- a/platform/platform-impl/src/org/jetbrains/io/WebServer.java +++ b/platform/platform-impl/src/org/jetbrains/io/WebServer.java @@ -15,6 +15,7 @@ */ package org.jetbrains.io; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; @@ -46,7 +47,7 @@ import static org.jboss.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; import static org.jboss.netty.handler.codec.http.HttpResponseStatus.OK; import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1; -public class WebServer { +public class WebServer implements Disposable { private static final String START_TIME_PATH = "/startTime"; private final ChannelGroup openChannels = new DefaultChannelGroup("web-server"); @@ -247,25 +248,15 @@ public class WebServer { } } - public void stop() { + @Override + public void dispose() { try { - for (HttpRequestHandler handler : WebServerManager.EP_NAME.getExtensions()) { - try { - handler.serverStopping(); - } - catch (Exception e) { - LOG.error(e); - } - } + openChannels.close().awaitUninterruptibly(); } finally { - try { - openChannels.close().awaitUninterruptibly(); - } - finally { - channelFactory.releaseExternalResources(); - } + channelFactory.releaseExternalResources(); } + LOG.info("web server stopped"); } public static void replaceDefaultHandler(@NotNull ChannelHandlerContext context, @NotNull SimpleChannelUpstreamHandler messageChannelHandler) { @@ -321,7 +312,7 @@ public class WebServer { if (connectedHandler == null) { for (HttpRequestHandler handler : WebServerManager.EP_NAME.getExtensions()) { try { - if (handler.isSupported(request.getMethod()) && handler.process(urlDecoder, request, context)) { + if (handler.isSupported(request) && handler.process(urlDecoder, request, context)) { if (context.getAttachment() == null) { context.setAttachment(handler); } @@ -333,7 +324,7 @@ public class WebServer { } } } - else if (connectedHandler.isSupported(request.getMethod())) { + else if (connectedHandler.isSupported(request)) { connectedHandler.process(urlDecoder, request, context); return; } From faec7ad408cdb4433035ae6f793a9a1747efdc60 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 12 Feb 2013 12:54:46 +0400 Subject: [PATCH 2/3] fix isSupported after last commit --- .../src/com/intellij/ide/XmlRpcServerImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java index aa17b7806f69..eaf066b3bea0 100644 --- a/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java @@ -80,7 +80,7 @@ public class XmlRpcServerImpl implements XmlRpcServer { static final class XmlRpcRequestHandler extends HttpRequestHandler { @Override public boolean isSupported(HttpRequest request) { - return request == HttpMethod.POST || request == HttpMethod.OPTIONS; + return request.getMethod() == HttpMethod.POST || request.getMethod() == HttpMethod.OPTIONS; } @Override @@ -103,7 +103,7 @@ public class XmlRpcServerImpl implements XmlRpcServer { } private boolean process(QueryStringDecoder urlDecoder, HttpRequest request, ChannelHandlerContext context) throws IOException { - if (!(urlDecoder.getPath().isEmpty() || urlDecoder.getPath().equals("/") || urlDecoder.getPath().equalsIgnoreCase("/RPC2"))) { + if (!isXmlRpcRequest(urlDecoder.getPath())) { return false; } @@ -138,6 +138,10 @@ public class XmlRpcServerImpl implements XmlRpcServer { return false; } + private static boolean isXmlRpcRequest(String path) { + return path.isEmpty() || (path.length() == 1 && path.charAt(0) == '/') || path.equalsIgnoreCase("/RPC2"); + } + private static class XmlRpcHandlerMappingImpl implements XmlRpcHandlerMapping { protected final THashMap handlers = new THashMap(); From d683b1ba48815a88f6ab6a82b6c21230ad429b2f Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Tue, 12 Feb 2013 13:21:42 +0400 Subject: [PATCH 3/3] Change configuration in the write action only! --- .../MavenDefaultModifiableModelsProvider.java | 58 +++--- .../maven/importing/MavenModuleImporter.java | 159 ---------------- .../maven/importing/MavenProjectImporter.java | 83 ++++---- .../MavenUIModifiableModelsProvider.java | 6 +- .../MavenAnnotationProcessorConfigurer.java | 179 ++++++++++++++++++ .../configurers/MavenCompilerConfigurer.java | 59 ++++++ .../configurers/MavenEncodingConfigurer.java | 44 +++++ .../configurers/MavenModuleConfigurer.java | 57 ++++++ .../AnnotationProcessorImportingTest.groovy | 27 +-- 9 files changed, 411 insertions(+), 261 deletions(-) create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenCompilerConfigurer.java create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenEncodingConfigurer.java create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenModuleConfigurer.java diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenDefaultModifiableModelsProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenDefaultModifiableModelsProvider.java index 81ddd7cbdc2b..2599d5861775 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenDefaultModifiableModelsProvider.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenDefaultModifiableModelsProvider.java @@ -106,47 +106,39 @@ public class MavenDefaultModifiableModelsProvider extends MavenBaseModifiableMod } public void commit() { - MavenUtil.invokeAndWaitWriteAction(myProject, new Runnable() { + ((ProjectRootManagerEx)ProjectRootManager.getInstance(myProject)).mergeRootsChangesDuring(new Runnable() { public void run() { - ((ProjectRootManagerEx)ProjectRootManager.getInstance(myProject)).mergeRootsChangesDuring(new Runnable() { - public void run() { - processExternalArtifactDependencies(); - for (Library.ModifiableModel each : myLibraryModels.values()) { - each.commit(); - } - myLibrariesModel.commit(); - Collection rootModels = myRootModels.values(); + processExternalArtifactDependencies(); + for (Library.ModifiableModel each : myLibraryModels.values()) { + each.commit(); + } + myLibrariesModel.commit(); + Collection rootModels = myRootModels.values(); - ModifiableRootModel[] rootModels1 = rootModels.toArray(new ModifiableRootModel[rootModels.size()]); - for (ModifiableRootModel model : rootModels1) { - assert !model.isDisposed() : "Already disposed: " + model; - } - ModifiableModelCommitter.multiCommit(rootModels1, myModuleModel); + ModifiableRootModel[] rootModels1 = rootModels.toArray(new ModifiableRootModel[rootModels.size()]); + for (ModifiableRootModel model : rootModels1) { + assert !model.isDisposed() : "Already disposed: " + model; + } + ModifiableModelCommitter.multiCommit(rootModels1, myModuleModel); - for (ModifiableFacetModel each : myFacetModels.values()) { - each.commit(); - } - if (myArtifactModel != null) { - myArtifactModel.commit(); - } - } - }); + for (ModifiableFacetModel each : myFacetModels.values()) { + each.commit(); + } + if (myArtifactModel != null) { + myArtifactModel.commit(); + } } }); } public void dispose() { - MavenUtil.invokeAndWaitWriteAction(myProject, new Runnable() { - public void run() { - for (ModifiableRootModel each : myRootModels.values()) { - each.dispose(); - } - myModuleModel.dispose(); - if (myArtifactModel != null) { - myArtifactModel.dispose(); - } - } - }); + for (ModifiableRootModel each : myRootModels.values()) { + each.dispose(); + } + myModuleModel.dispose(); + if (myArtifactModel != null) { + myArtifactModel.dispose(); + } } public ModalityState getModalityStateForQuestionDialogs() { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java index f7e2e59ea715..ee7fc3d3d821 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenModuleImporter.java @@ -48,13 +48,7 @@ import java.util.Map; public class MavenModuleImporter { - public static final String PROFILE_PREFIX = "Annotation profile for "; - - public static final String MAVEN_DEFAULT_ANNOTATION_PROFILE = "Maven default annotation processors profile"; - public static final String SUREFIRE_PLUGIN_LIBRARY_NAME = "maven-surefire-plugin urls"; - public static final String DEFAULT_ANNOTATION_PATH_OUTPUT = "target/generated-sources/annotations"; - public static final String DEFAULT_TEST_ANNOTATION_OUTPUT = "target/generated-test-sources/test-annotations"; private final Module myModule; private final MavenProjectsTree myMavenTree; @@ -94,26 +88,6 @@ public class MavenModuleImporter { configFolders(); configDependencies(); configLanguageLevel(); - configAnnotationProcessors(); - excludeFromCompilationArchetypeResources(); - } - - 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)); - } - } } public void preConfigFacets() { @@ -267,139 +241,6 @@ public class MavenModuleImporter { } } - 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 options = myMavenProject.getAnnotationProcessorOptions(); - - List 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 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); - } - } - } - - @Nullable - private String getRelativeAnnotationProcessorDirectory(boolean isTest) { - String annotationProcessorDirectory = myMavenProject.getAnnotationProcessorDirectory(isTest); - File annotationProcessorDirectoryFile = new File(annotationProcessorDirectory); - if (!annotationProcessorDirectoryFile.isAbsolute()) { - return annotationProcessorDirectory; - } - - String absoluteProjectDirectory = myMavenProject.getDirectory(); - return FileUtil.getRelativePath(new File(absoluteProjectDirectory), annotationProcessorDirectoryFile); - } - - private boolean shouldEnableAnnotationProcessors() { - if ("pom".equals(myMavenProject.getPackaging())) return false; - - return myMavenProject.getProcMode() != MavenProject.ProcMode.NONE || myMavenProject.getPluginConfiguration("org.bsc.maven", "maven-processor-plugin") != null; - } - @NotNull private static DependencyScope selectScope(String mavenScope) { if (MavenConstants.SCOPE_RUNTIME.equals(mavenScope)) return DependencyScope.RUNTIME; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java index 33889304badf..de4cd5f4c22f 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenProjectImporter.java @@ -15,8 +15,6 @@ */ package org.jetbrains.idea.maven.importing; -import com.intellij.compiler.CompilerConfiguration; -import com.intellij.compiler.CompilerConfigurationImpl; import com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.ModifiableModuleModel; @@ -33,13 +31,13 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.vfs.encoding.EncodingProjectManager; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.intellij.util.containers.Stack; import gnu.trove.THashMap; import gnu.trove.THashSet; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.importing.configurers.MavenModuleConfigurer; import org.jetbrains.idea.maven.model.MavenArtifact; import org.jetbrains.idea.maven.project.*; import org.jetbrains.idea.maven.utils.MavenLog; @@ -50,9 +48,6 @@ import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions; import java.io.File; import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; -import java.nio.charset.UnsupportedCharsetException; import java.util.*; public class MavenProjectImporter { @@ -95,20 +90,20 @@ public class MavenProjectImporter { public List importProject() { List postTasks = new ArrayList(); - boolean hasChanges = false; + boolean hasChanges; // in the case projects are changed during importing we must memorise them myAllProjects = new LinkedHashSet(myProjectsTree.getProjects()); myAllProjects.addAll(myProjectsToImportWithChanges.keySet()); // some projects may already have been removed from the tree - hasChanges |= deleteIncompatibleModules(); + hasChanges = deleteIncompatibleModules(); myProjectsToImportWithChanges = collectProjectsToImport(myProjectsToImportWithChanges); mapMavenProjectsToModulesAndNames(); if (myProject.isDisposed()) return null; - boolean projectsHaveChanges = projectsToImportHaveChanges(); + final boolean projectsHaveChanges = projectsToImportHaveChanges(); if (projectsHaveChanges) { hasChanges = true; importModules(postTasks); @@ -128,16 +123,30 @@ public class MavenProjectImporter { removeUnusedProjectLibraries(); } - if (hasChanges) { - myModelsProvider.commit(); + final boolean finalHasChanges = hasChanges; - if (projectsHaveChanges) { - configSettings(); + MavenUtil.invokeAndWaitWriteAction(myProject, new Runnable() { + public void run() { + if (finalHasChanges) { + myModelsProvider.commit(); + + if (projectsHaveChanges) { + removeOutdatedCompilerConfigSettings(); + + for (MavenProject mavenProject : myAllProjects) { + Module module = myMavenProjectToModule.get(mavenProject); + + for (MavenModuleConfigurer configurer : MavenModuleConfigurer.getConfigurers()) { + configurer.configure(mavenProject, myProject, module); + } + } + } + } + else { + myModelsProvider.dispose(); + } } - } - else { - myModelsProvider.dispose(); - } + }); return postTasks; } @@ -381,41 +390,13 @@ public class MavenProjectImporter { myImportingSettings.getDedicatedModuleDir()); } - private void configSettings() { - MavenUtil.invokeAndWaitWriteAction(myProject, new Runnable() { - public void run() { - CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject); + private void removeOutdatedCompilerConfigSettings() { + ApplicationManager.getApplication().assertWriteAccessAllowed(); - MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject); - - for (MavenProject project : myAllProjects) { - String targetLevel = project.getTargetLevel(); - - if (targetLevel != null) { - Module module = projectsManager.findModule(project); - if (module != null) { - configuration.setBytecodeTargetLevel(module, targetLevel); - } - } - - if (!Boolean.parseBoolean(System.getProperty("maven.disable.encode.import"))) { - String encoding = project.getEncoding(); - if (encoding != null) { - try { - EncodingProjectManager.getInstance(myProject).setEncoding(project.getDirectoryFile(), Charset.forName(encoding)); - } - catch (UnsupportedCharsetException ignored) {/**/} - catch (IllegalCharsetNameException ignored) {/**/} - } - } - } - - final JpsJavaCompilerOptions javacOptions = JavacConfiguration.getOptions(myProject, JavacConfiguration.class); - String options = javacOptions.ADDITIONAL_OPTIONS_STRING; - options = options.replaceFirst("(-target (\\S+))", ""); // Old IDEAs saved - javacOptions.ADDITIONAL_OPTIONS_STRING = options; - } - }); + final JpsJavaCompilerOptions javacOptions = JavacConfiguration.getOptions(myProject, JavacConfiguration.class); + String options = javacOptions.ADDITIONAL_OPTIONS_STRING; + options = options.replaceFirst("(-target (\\S+))", ""); // Old IDEAs saved + javacOptions.ADDITIONAL_OPTIONS_STRING = options; } private void importModules(final List postTasks) { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenUIModifiableModelsProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenUIModifiableModelsProvider.java index f0ec25c6f429..a35f2f6fecfa 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenUIModifiableModelsProvider.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/MavenUIModifiableModelsProvider.java @@ -95,11 +95,7 @@ public class MavenUIModifiableModelsProvider extends MavenBaseModifiableModelsPr } public void commit() { - MavenUtil.invokeAndWaitWriteAction(myProject, new Runnable() { - public void run() { - processExternalArtifactDependencies(); - } - }); + processExternalArtifactDependencies(); } public void dispose() { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java new file mode 100644 index 000000000000..f1604575ff51 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenAnnotationProcessorConfigurer.java @@ -0,0 +1,179 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.importing.configurers; + +import com.intellij.compiler.CompilerConfiguration; +import com.intellij.compiler.CompilerConfigurationImpl; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.util.io.FileUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.project.MavenProject; +import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile; +import org.jetbrains.jps.model.java.impl.compiler.ProcessorConfigProfileImpl; + +import java.io.File; +import java.util.List; +import java.util.Map; + +/** + * @author Sergey Evdokimov + */ +public class MavenAnnotationProcessorConfigurer extends MavenModuleConfigurer { + + public static final String PROFILE_PREFIX = "Annotation profile for "; + public static final String MAVEN_DEFAULT_ANNOTATION_PROFILE = "Maven default annotation processors profile"; + public static final String DEFAULT_ANNOTATION_PATH_OUTPUT = "target/generated-sources/annotations"; + public static final String DEFAULT_TEST_ANNOTATION_OUTPUT = "target/generated-test-sources/test-annotations"; + + @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; + } + } + } + + CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(project); + + ProcessorConfigProfile currentProfile = compilerConfiguration.getAnnotationProcessingConfiguration(module); + + String moduleProfileName = PROFILE_PREFIX + module.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(mavenProject)) { + 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; + } + + Map options = mavenProject.getAnnotationProcessorOptions(); + + List processors = mavenProject.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(module.getName()); + } + else { + if (defaultMavenProfile != null) { + defaultMavenProfile.removeModuleName(module.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(module.getName()); + compilerConfiguration.addModuleProcessorProfile(moduleProfile); + } + + moduleProfile.setGeneratedSourcesDirectoryName(annotationProcessorDirectory, false); + moduleProfile.setGeneratedSourcesDirectoryName(testAnnotationProcessorDirectory, true); + + moduleProfile.clearProcessorOptions(); + for (Map.Entry 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(module.getName()); + + if (defaultMavenProfile.getModuleNames().isEmpty()) { + compilerConfiguration.removeModuleProcessorProfile(defaultMavenProfile); + } + } + + if (moduleProfile != null) { + compilerConfiguration.removeModuleProcessorProfile(moduleProfile); + } + } + } + + @Nullable + private String getRelativeAnnotationProcessorDirectory(MavenProject mavenProject, boolean isTest) { + String annotationProcessorDirectory = mavenProject.getAnnotationProcessorDirectory(isTest); + File annotationProcessorDirectoryFile = new File(annotationProcessorDirectory); + if (!annotationProcessorDirectoryFile.isAbsolute()) { + return annotationProcessorDirectory; + } + + String absoluteProjectDirectory = mavenProject.getDirectory(); + return FileUtil.getRelativePath(new File(absoluteProjectDirectory), annotationProcessorDirectoryFile); + } + + private static boolean shouldEnableAnnotationProcessors(MavenProject mavenProject) { + if ("pom".equals(mavenProject.getPackaging())) return false; + + return mavenProject.getProcMode() != MavenProject.ProcMode.NONE + || mavenProject.getPluginConfiguration("org.bsc.maven", "maven-processor-plugin") != null; + } + +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenCompilerConfigurer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenCompilerConfigurer.java new file mode 100644 index 000000000000..afd4bc786fef --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenCompilerConfigurer.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.importing.configurers; + +import com.intellij.compiler.CompilerConfiguration; +import com.intellij.compiler.CompilerConfigurationImpl; +import com.intellij.openapi.compiler.options.ExcludeEntryDescription; +import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.project.MavenProject; + +/** + * @author Sergey Evdokimov + */ +public class MavenCompilerConfigurer extends MavenModuleConfigurer { + @Override + public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) { + if (module == null) return; + + String targetLevel = mavenProject.getTargetLevel(); + if (targetLevel != null) { + CompilerConfigurationImpl configuration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(project); + configuration.setBytecodeTargetLevel(module, targetLevel); + } + + VirtualFile directoryFile = mavenProject.getDirectoryFile(); + + // Exclude src/main/archetype-resources + VirtualFile archetypeResourcesDir = VfsUtil.findRelativeFile(directoryFile, "src", "main", "resources", "archetype-resources"); + + if (archetypeResourcesDir != null) { + CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(project); + + if (!compilerConfiguration.isExcludedFromCompilation(archetypeResourcesDir)) { + ExcludedEntriesConfiguration cfg = compilerConfiguration.getExcludedEntriesConfiguration(); + + cfg.addExcludeEntryDescription(new ExcludeEntryDescription(archetypeResourcesDir, true, false, project)); + } + } + } +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenEncodingConfigurer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenEncodingConfigurer.java new file mode 100644 index 000000000000..cb05f6b3b028 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenEncodingConfigurer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.importing.configurers; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.encoding.EncodingProjectManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.project.MavenProject; + +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.UnsupportedCharsetException; + +/** + * @author Sergey Evdokimov + */ +public class MavenEncodingConfigurer extends MavenModuleConfigurer { + @Override + public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) { + String encoding = mavenProject.getEncoding(); + if (encoding != null) { + try { + EncodingProjectManager.getInstance(project).setEncoding(mavenProject.getDirectoryFile(), Charset.forName(encoding)); + } + catch (UnsupportedCharsetException ignored) {/**/} + catch (IllegalCharsetNameException ignored) {/**/} + } + } +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenModuleConfigurer.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenModuleConfigurer.java new file mode 100644 index 000000000000..eb60d8253c2c --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/importing/configurers/MavenModuleConfigurer.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.importing.configurers; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.project.MavenProject; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Sergey Evdokimov + */ +public abstract class MavenModuleConfigurer { + + private static volatile List ourConfigurersList; + + public abstract void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module); + + public static List getConfigurers() { + List configurers = ourConfigurersList; + if (configurers == null) { + configurers = new ArrayList(); + + for (MavenModuleConfigurer configurer : new MavenModuleConfigurer[]{ + new MavenCompilerConfigurer(), + new MavenEncodingConfigurer(), + new MavenAnnotationProcessorConfigurer()}) { + + if (!Boolean.parseBoolean(System.getProperty("idea.maven.disable." + configurer.getClass().getSimpleName()))) { + configurers.add(configurer); + } + } + + ourConfigurersList = configurers; + } + + return configurers; + } + +} diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy index e5c4ec6a8386..097b891adcbc 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/AnnotationProcessorImportingTest.groovy @@ -18,7 +18,8 @@ package org.jetbrains.idea.maven.compiler import com.intellij.compiler.CompilerConfiguration import com.intellij.compiler.CompilerConfigurationImpl import org.jetbrains.idea.maven.MavenImportingTestCase -import org.jetbrains.idea.maven.importing.MavenModuleImporter +import org.jetbrains.idea.maven.importing.configurers.MavenAnnotationProcessorConfigurer + /** * @author Sergey Evdokimov */ @@ -125,10 +126,10 @@ class AnnotationProcessorImportingTest extends MavenImportingTestCase { def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject)) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.MAVEN_DEFAULT_ANNOTATION_PROFILE).getModuleNames() == new HashSet(["module1"]) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + 'module2').getProcessors() == new HashSet(["com.test.SourceCodeGeneratingAnnotationProcessor2"]) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + 'module3') == null - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + 'module3_1') == null + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.MAVEN_DEFAULT_ANNOTATION_PROFILE).getModuleNames() == new HashSet(["module1"]) + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + 'module2').getProcessors() == new HashSet(["com.test.SourceCodeGeneratingAnnotationProcessor2"]) + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + 'module3') == null + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + 'module3_1') == null } public void testOverrideGeneratedOutputDir() { @@ -152,8 +153,8 @@ class AnnotationProcessorImportingTest extends MavenImportingTestCase { def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject)) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + "project").getGeneratedSourcesDirectoryName(false).replace('\\', '/').endsWith("out/generated") + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + "project").getGeneratedSourcesDirectoryName(false).replace('\\', '/').endsWith("out/generated") } public void testImportAnnotationProcessorOptions() { @@ -180,8 +181,8 @@ class AnnotationProcessorImportingTest extends MavenImportingTestCase { def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject)) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null - def processorOptions = compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + "project").getProcessorOptions() + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null + def processorOptions = compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + "project").getProcessorOptions() assert new HashMap(processorOptions) == ['opt1': '111', 'opt2': '222', 'opt3': '333'] } @@ -226,8 +227,8 @@ class AnnotationProcessorImportingTest extends MavenImportingTestCase { def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject)) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null - def profile = compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + "project") + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null + def profile = compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + "project") assert profile.getGeneratedSourcesDirectoryName(false).replace('\\', '/').endsWith("target/metamodel") assert profile.getGeneratedSourcesDirectoryName(true).replace('\\', '/').endsWith("target/metamodelTest") } @@ -284,8 +285,8 @@ class AnnotationProcessorImportingTest extends MavenImportingTestCase { def compilerConfiguration = ((CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject)) - assert compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null - def profile = compilerConfiguration.findModuleProcessorProfile(MavenModuleImporter.PROFILE_PREFIX + "project") + assert compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.MAVEN_DEFAULT_ANNOTATION_PROFILE) == null + def profile = compilerConfiguration.findModuleProcessorProfile(MavenAnnotationProcessorConfigurer.PROFILE_PREFIX + "project") assert profile.getGeneratedSourcesDirectoryName(false).replace('\\', '/').endsWith("target/metamodel") assert profile.getGeneratedSourcesDirectoryName(true).replace('\\', '/').endsWith("target/metamodelTest") }