diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index fb496a8ac20e..cdb7688d8cea 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -252,6 +252,17 @@ public def layoutCommunityPlugins(String home) {
module("maven3-server-impl")
}
+ jar("artifact-resolver-m2.jar") {
+ module("maven-artifact-resolver-m2")
+ }
+
+ jar("artifact-resolver-m3.jar") {
+ module("maven-artifact-resolver-m3")
+ module("maven-artifact-resolver-m2") {
+ include(name: 'org/jetbrains/idea/maven/artifactResolver/common/*')
+ }
+ }
+
dir("maven3") {
fileset(dir: "$home/plugins/maven/maven3-server-impl/lib") {include(name: "*.jar")}
fileset(dir: "$home/plugins/maven/maven3-server-impl/lib/maven3/lib") {include(name: "*.jar")}
diff --git a/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml b/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml
new file mode 100644
index 000000000000..8d43bd44ea76
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m2/maven-artifact-resolver-m2.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/maven/artifact-resolver-m2/src/META-INF/plexus/components.xml b/plugins/maven/artifact-resolver-m2/src/META-INF/plexus/components.xml
new file mode 100644
index 000000000000..f9581b8db442
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m2/src/META-INF/plexus/components.xml
@@ -0,0 +1,22 @@
+
+
+
+ org.apache.maven.artifact.resolver.ArtifactResolver
+ org.jetbrains.idea.maven.artifactResolver.MyArtifactResolver
+
+
+ org.apache.maven.artifact.manager.WagonManager
+
+
+ org.apache.maven.artifact.transform.ArtifactTransformationManager
+
+
+ org.apache.maven.artifact.factory.ArtifactFactory
+
+
+ org.apache.maven.artifact.resolver.ArtifactCollector
+
+
+
+
+
diff --git a/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM2RtMarker.java b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM2RtMarker.java
new file mode 100644
index 000000000000..ca5755c86bad
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM2RtMarker.java
@@ -0,0 +1,22 @@
+/*
+ * 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.artifactResolver;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenArtifactResolvedM2RtMarker {
+}
diff --git a/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactResolver.java b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactResolver.java
new file mode 100644
index 000000000000..11507da4857b
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactResolver.java
@@ -0,0 +1,48 @@
+/*
+ * 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.artifactResolver;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
+import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
+
+import java.util.List;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MyArtifactResolver extends DefaultArtifactResolver {
+
+ @Override
+ public void resolve(Artifact artifact, List remoteRepositories, ArtifactRepository localRepository)
+ throws ArtifactResolutionException, ArtifactNotFoundException {
+ if (!MavenModuleMap.getInstance().resolveToModule(artifact)) {
+ super.resolve(artifact, remoteRepositories, localRepository);
+ }
+ }
+
+ @Override
+ public void resolveAlways(Artifact artifact, List remoteRepositories, ArtifactRepository localRepository)
+ throws ArtifactResolutionException, ArtifactNotFoundException {
+ if (!MavenModuleMap.getInstance().resolveToModule(artifact)) {
+ super.resolveAlways(artifact, remoteRepositories, localRepository);
+ }
+ }
+
+}
diff --git a/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/common/MavenModuleMap.java b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/common/MavenModuleMap.java
new file mode 100644
index 000000000000..f9246328b8c1
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m2/src/org/jetbrains/idea/maven/artifactResolver/common/MavenModuleMap.java
@@ -0,0 +1,86 @@
+/*
+ * 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.artifactResolver.common;
+
+import org.apache.maven.artifact.Artifact;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenModuleMap {
+
+ private static final MavenModuleMap ourInstance = new MavenModuleMap();
+
+ public static final String PATHS_FILE_PROPERTY = "idea.modules.paths.file";
+
+ private final Properties myMap = new Properties();
+
+ private MavenModuleMap() {
+ String path = System.getProperty(PATHS_FILE_PROPERTY);
+ if(path != null) {
+ try {
+ BufferedInputStream in = new BufferedInputStream(new FileInputStream(path));
+ try {
+ myMap.load(in);
+ } finally {
+ in.close();
+ }
+ } catch(IOException e) {
+ // XXX log
+ }
+ }
+ }
+
+ public static MavenModuleMap getInstance() {
+ return ourInstance;
+ }
+
+ public boolean resolveToModule(Artifact artifact) {
+ String extension = artifact.getArtifactHandler().getExtension();
+ File file = findArtifact(artifact.getGroupId(), artifact.getArtifactId(), extension, artifact.getBaseVersion());
+
+ if(file == null) {
+ return false;
+ }
+
+ artifact.setFile(file);
+ artifact.setResolved(true);
+ return true;
+ }
+
+ public File findArtifact(String groupId, String artifactId, String type, String baseVersion) {
+ String key = groupId + ':' + artifactId + ':' + type + ':' + baseVersion;
+ String value = myMap.getProperty(key);
+
+ if(value == null || value.length() == 0) {
+ return null;
+ }
+
+ File file = new File(value);
+ if(!file.exists()) {
+ return null;
+ }
+
+ return file;
+ }
+
+}
diff --git a/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml b/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml
new file mode 100644
index 000000000000..7acb3dfd9759
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m3/maven-artifact-resolver-m3.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/maven/artifact-resolver-m3/src/META-INF/plexus/components.xml b/plugins/maven/artifact-resolver-m3/src/META-INF/plexus/components.xml
new file mode 100644
index 000000000000..0ef451fd1f95
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m3/src/META-INF/plexus/components.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ org.apache.maven.repository.LocalArtifactRepository
+ ide-workspace
+ org.jetbrains.idea.maven.artifactResolver.MyArtifactRepository
+
+ false
+
+
+ org.sonatype.aether.repository.WorkspaceReader
+ ide
+ org.jetbrains.idea.maven.artifactResolver.MyWorkspaceReader
+
+ false
+
+
+
diff --git a/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM3RtMarker.java b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM3RtMarker.java
new file mode 100644
index 000000000000..e671f26f0dbf
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MavenArtifactResolvedM3RtMarker.java
@@ -0,0 +1,22 @@
+/*
+ * 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.artifactResolver;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MavenArtifactResolvedM3RtMarker {
+}
diff --git a/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactRepository.java b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactRepository.java
new file mode 100644
index 000000000000..d8ac2fe678ab
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyArtifactRepository.java
@@ -0,0 +1,53 @@
+/*
+ * 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.artifactResolver;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.repository.LocalArtifactRepository;
+import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MyArtifactRepository extends LocalArtifactRepository {
+
+ protected boolean resolveAsModule(Artifact artifact) {
+ if (artifact == null) {
+ return false;
+ }
+
+ return MavenModuleMap.getInstance().resolveToModule(artifact);
+ }
+
+ public Artifact find(Artifact artifact) {
+ resolveAsModule(artifact);
+ return artifact;
+ }
+
+ public boolean hasLocalMetadata() {
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof MyArtifactRepository;
+ }
+}
diff --git a/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyWorkspaceReader.java b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyWorkspaceReader.java
new file mode 100644
index 000000000000..d67fcc9f0a12
--- /dev/null
+++ b/plugins/maven/artifact-resolver-m3/src/org/jetbrains/idea/maven/artifactResolver/MyWorkspaceReader.java
@@ -0,0 +1,62 @@
+/*
+ * 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.artifactResolver;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.repository.WorkspaceReader;
+import org.sonatype.aether.repository.WorkspaceRepository;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Sergey Evdokimov
+ */
+@Component(role = WorkspaceReader.class, hint = "ide")
+public class MyWorkspaceReader implements WorkspaceReader {
+
+ private final WorkspaceRepository myWorkspaceRepository;
+
+ public MyWorkspaceReader() {
+ myWorkspaceRepository = new WorkspaceRepository("ide", getClass());
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return o instanceof MyWorkspaceReader;
+ }
+
+ public WorkspaceRepository getRepository() {
+ return myWorkspaceRepository;
+ }
+
+ public File findArtifact(Artifact artifact) {
+ return MavenModuleMap.getInstance().findArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(),
+ artifact.getBaseVersion());
+ }
+
+ public List findVersions(Artifact artifact) {
+ return Collections.emptyList();
+ }
+}
diff --git a/plugins/maven/maven.iml b/plugins/maven/maven.iml
index b5926712e059..99893724046e 100644
--- a/plugins/maven/maven.iml
+++ b/plugins/maven/maven.iml
@@ -58,6 +58,7 @@
+
diff --git a/plugins/maven/maven2-server-impl/maven2-server-impl.iml b/plugins/maven/maven2-server-impl/maven2-server-impl.iml
index 092e457efd1f..7d8e3f61474a 100644
--- a/plugins/maven/maven2-server-impl/maven2-server-impl.iml
+++ b/plugins/maven/maven2-server-impl/maven2-server-impl.iml
@@ -28,48 +28,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -101,6 +59,7 @@
+
diff --git a/plugins/maven/maven3-server-impl/maven3-server-impl.iml b/plugins/maven/maven3-server-impl/maven3-server-impl.iml
index 0c898b2790d0..388f13381013 100644
--- a/plugins/maven/maven3-server-impl/maven3-server-impl.iml
+++ b/plugins/maven/maven3-server-impl/maven3-server-impl.iml
@@ -149,6 +149,7 @@
+
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
index dff5a8759e83..93b046cb45db 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java
@@ -25,6 +25,8 @@ import com.intellij.execution.configurations.ParametersList;
import com.intellij.execution.impl.EditConfigurationsDialog;
import com.intellij.execution.impl.RunManagerImpl;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.JavaSdk;
@@ -33,29 +35,37 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.encoding.EncodingManager;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
+import com.intellij.util.PathUtil;
+import com.intellij.util.io.ZipUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.idea.maven.artifactResolver.MavenArtifactResolvedM2RtMarker;
+import org.jetbrains.idea.maven.artifactResolver.MavenArtifactResolvedM3RtMarker;
+import org.jetbrains.idea.maven.artifactResolver.common.MavenModuleMap;
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
+import org.jetbrains.idea.maven.project.MavenProject;
import org.jetbrains.idea.maven.project.MavenProjectsManager;
import org.jetbrains.idea.maven.utils.MavenSettings;
import org.jetbrains.idea.maven.utils.MavenUtil;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.io.*;
+import java.util.*;
+import java.util.zip.ZipOutputStream;
/**
* @author Ralf Quebbemann
*/
public class MavenExternalParameters {
+
+ private static final Logger LOG = Logger.getInstance(MavenExternalParameters.class);
+
public static final String MAVEN_LAUNCHER_CLASS = "org.codehaus.classworlds.Launcher";
@NonNls private static final String JAVA_HOME = "JAVA_HOME";
@NonNls private static final String MAVEN_OPTS = "MAVEN_OPTS";
@@ -107,6 +117,27 @@ public class MavenExternalParameters {
addVMParameters(params.getVMParametersList(), mavenHome, runnerSettings);
+ File confFile = MavenUtil.getMavenConfFile(new File(mavenHome));
+ if (!confFile.isFile()) {
+ throw new ExecutionException("Configuration file is not exists in maven home: " + confFile.getAbsolutePath());
+ }
+
+ if (project != null && parameters.isResolveToWorkspace()) {
+ try {
+ String resolverJar = getArtifactResolverJar(MavenUtil.isMaven3(mavenHome));
+ confFile = patchConfFile(confFile, resolverJar);
+
+ File modulesPathsFile = dumpModulesPaths(project);
+ params.getVMParametersList().addProperty(MavenModuleMap.PATHS_FILE_PROPERTY, modulesPathsFile.getAbsolutePath());
+ }
+ catch (IOException e) {
+ LOG.error(e);
+ throw new ExecutionException("Failed to run maven configuration", e);
+ }
+ }
+
+ params.getVMParametersList().addProperty("classworlds.conf", confFile.getPath());
+
for (String path : getMavenClasspathEntries(mavenHome)) {
params.getClassPath().add(path);
}
@@ -122,6 +153,112 @@ public class MavenExternalParameters {
return params;
}
+ private static File patchConfFile(File conf, String library) throws IOException {
+ File tmpConf = File.createTempFile("idea-", "-mvn.conf");
+ tmpConf.deleteOnExit();
+ patchConfFile(conf, tmpConf, library);
+
+ return tmpConf;
+ }
+
+ private static void patchConfFile(File originalConf, File dest, String library) throws IOException {
+ Scanner sc = new Scanner(originalConf);
+
+ try {
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest)));
+
+ try {
+ boolean patched = false;
+
+ while (sc.hasNextLine()) {
+ String line = sc.nextLine();
+
+ out.append(line);
+ out.newLine();
+
+ if (!patched && "[plexus.core]".equals(line)) {
+ out.append("load ").append(library);
+ out.newLine();
+
+ patched = true;
+ }
+ }
+ }
+ finally {
+ out.close();
+ }
+ }
+ finally {
+ sc.close();
+ }
+
+ }
+
+ private static String getArtifactResolverJar(boolean isMaven3) throws IOException {
+ Class marker = isMaven3 ? MavenArtifactResolvedM3RtMarker.class : MavenArtifactResolvedM2RtMarker.class;
+
+ File classDirOrJar = new File(PathUtil.getJarPathForClass(marker));
+
+ if (!classDirOrJar.isDirectory()) {
+ return classDirOrJar.getAbsolutePath(); // it's a jar in IDEA installation.
+ }
+
+ // it's a classes directory, we are in development mode.
+ File tempFile = FileUtil.createTempFile("idea-", "-artifactResolver.jar");
+ tempFile.deleteOnExit();
+
+ ZipOutputStream zipOutput = new ZipOutputStream(new FileOutputStream(tempFile));
+ try {
+ ZipUtil.addDirToZipRecursively(zipOutput, null, classDirOrJar, "", null, null);
+
+ if (isMaven3) {
+ File m2Module = new File(PathUtil.getJarPathForClass(MavenModuleMap.class));
+
+ String commonClassesPath = MavenModuleMap.class.getPackage().getName().replace('.', '/');
+ ZipUtil.addDirToZipRecursively(zipOutput, null, new File(m2Module, commonClassesPath), commonClassesPath, null, null);
+ }
+ } finally {
+ zipOutput.close();
+ }
+
+ return tempFile.getAbsolutePath();
+ }
+
+ private static File dumpModulesPaths(@NotNull Project project) throws IOException {
+ ApplicationManager.getApplication().assertReadAccessAllowed();
+
+ Properties res = new Properties();
+
+ MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
+
+ for (MavenProject mavenProject : manager.getProjects()) {
+ res.setProperty(mavenProject.getMavenId().getGroupId()
+ + ':' + mavenProject.getMavenId().getArtifactId()
+ + ":pom"
+ + ':' + mavenProject.getMavenId().getVersion(),
+ mavenProject.getFile().getPath());
+
+ res.setProperty(mavenProject.getMavenId().getGroupId()
+ + ':' + mavenProject.getMavenId().getArtifactId()
+ + ':' + mavenProject.getPackaging()
+ + ':' + mavenProject.getMavenId().getVersion(),
+ mavenProject.getOutputDirectory());
+ }
+
+ File file = new File(PathManager.getSystemPath(), "Maven/idea-projects-state-" + project.getLocationHash() + ".properties");
+ file.getParentFile().mkdirs();
+
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
+ try {
+ res.store(out, null);
+ }
+ finally {
+ out.close();
+ }
+
+ return file;
+ }
+
@NotNull
private static Sdk getJdk(@Nullable Project project, MavenRunnerSettings runnerSettings, boolean isGlobalRunnerSettings) throws ExecutionException {
String name = runnerSettings.getJreName();
@@ -177,8 +314,6 @@ public class MavenExternalParameters {
parametersList.addParametersString(runnerSettings.getVmOptions());
- parametersList.addProperty("classworlds.conf", MavenUtil.getMavenConfFile(new File(mavenHome)).getPath());
-
parametersList.addProperty("maven.home", mavenHome);
}
@@ -310,8 +445,8 @@ public class MavenExternalParameters {
if (coreSettings.isWorkOffline()) {
cmdList.add("--offline");
}
- String version = MavenUtil.getMavenVersion(mavenHome);
- boolean atLeastMaven3 = version != null && version.compareTo("3.0.0") >= 0;
+
+ boolean atLeastMaven3 = MavenUtil.isMaven3(mavenHome);
if (!atLeastMaven3) {
addIfNotEmpty(cmdList, coreSettings.getPluginUpdatePolicy().getCommandLineOption());
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParameters.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParameters.java
index d0dc2a0c922f..c04f2d344e51 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParameters.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParameters.java
@@ -33,6 +33,8 @@ public class MavenRunnerParameters implements Cloneable {
private Path myWorkingDirPath;
private final List myGoals = new ArrayList();
+ private boolean myResolveToWorkspace;
+
private final Map myProfilesMap = new LinkedHashMap();
private final Collection myEnabledProfilesForXmlSerializer = new TreeSet();
@@ -81,6 +83,7 @@ public class MavenRunnerParameters implements Cloneable {
public MavenRunnerParameters(MavenRunnerParameters that) {
this(that.getWorkingDirPath(), that.isPomExecution, that.myGoals, that.myProfilesMap);
+ myResolveToWorkspace = that.myResolveToWorkspace;
}
public boolean isPomExecution() {
@@ -180,6 +183,14 @@ public class MavenRunnerParameters implements Cloneable {
}
}
+ public boolean isResolveToWorkspace() {
+ return myResolveToWorkspace;
+ }
+
+ public void setResolveToWorkspace(boolean resolveToWorkspace) {
+ myResolveToWorkspace = resolveToWorkspace;
+ }
+
public MavenRunnerParameters clone() {
return new MavenRunnerParameters(this);
}
@@ -191,6 +202,7 @@ public class MavenRunnerParameters implements Cloneable {
final MavenRunnerParameters that = (MavenRunnerParameters)o;
if (isPomExecution != that.isPomExecution) return false;
+ if (myResolveToWorkspace != that.myResolveToWorkspace) return false;
if (!myGoals.equals(that.myGoals)) return false;
if (myWorkingDirPath != null ? !myWorkingDirPath.equals(that.myWorkingDirPath) : that.myWorkingDirPath != null) return false;
if (!myProfilesMap.equals(that.myProfilesMap)) return false;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form
index 9290e9c77e41..501a0aa5632b 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.form
@@ -1,6 +1,6 @@
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
index 882d0bec4ea4..037b30bb1a3c 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenRunnerParametersConfigurable.java
@@ -27,6 +27,7 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorTextField;
import com.intellij.ui.PanelWithAnchor;
+import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.TextFieldCompletionProvider;
import com.intellij.util.execution.ParametersListUtil;
@@ -50,6 +51,7 @@ public abstract class MavenRunnerParametersConfigurable implements Configurable,
protected LabeledComponent goalsComponent;
private LabeledComponent profilesComponent;
private JBLabel myFakeLabel;
+ private JCheckBox myResolveToWorkspaceCheckBox;
private JComponent anchor;
public MavenRunnerParametersConfigurable(@NotNull final Project project) {
@@ -126,6 +128,7 @@ public abstract class MavenRunnerParametersConfigurable implements Configurable,
private void setData(final MavenRunnerParameters data) {
data.setWorkingDirPath(workingDirComponent.getComponent().getText());
data.setGoals(ParametersListUtil.parse(goalsComponent.getComponent().getText()));
+ data.setResolveToWorkspace(myResolveToWorkspaceCheckBox.isSelected());
Map profilesMap = new LinkedHashMap();
@@ -146,6 +149,7 @@ public abstract class MavenRunnerParametersConfigurable implements Configurable,
private void getData(final MavenRunnerParameters data) {
workingDirComponent.getComponent().setText(data.getWorkingDirPath());
goalsComponent.getComponent().setText(ParametersList.join(data.getGoals()));
+ myResolveToWorkspaceCheckBox.setSelected(data.isResolveToWorkspace());
StringBuilder sb = new StringBuilder();
for (Map.Entry entry : data.getProfilesMap().entrySet()) {
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
index 3d2dc88636ac..cb58f3d15cb2 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
@@ -615,6 +615,11 @@ public class MavenUtil {
return null;
}
+ public static boolean isMaven3(String mavenHome) {
+ String version = getMavenVersion(mavenHome);
+ return version != null && version.compareTo("3.0.0") >= 0;
+ }
+
@Nullable
public static File resolveGlobalSettingsFile(@Nullable String overriddenMavenHome) {
File directory = resolveMavenHomeDirectory(overriddenMavenHome);