Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2014-03-30 11:16:32 -0400
committerAnton Tanasenko2014-03-30 17:29:07 -0400
commiteaff16254c06fad6fa85da0750b5e5f2fe2348e5 (patch)
tree3a26a8a192a61c73dbfbd93d825ae2768f6a40f3
parentf2f4c1ed4d9469101a122e32fa8e51fab8c0fb63 (diff)
downloadm2e-core-eaff16254c06fad6fa85da0750b5e5f2fe2348e5.tar.gz
m2e-core-eaff16254c06fad6fa85da0750b5e5f2fe2348e5.tar.xz
m2e-core-eaff16254c06fad6fa85da0750b5e5f2fe2348e5.zip
431580 - Importing projects with name templates fails for projects with
properties in corresponding values. Added Matcher#quoteReplacement() for corresponding values. Change-Id: Ie5da4b23bb5959abf5c9c75e9d653aa22b15ca9d Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ProjectImportConfiguration.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ProjectImportConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ProjectImportConfiguration.java
index 9deaf7a8..883f8ce0 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ProjectImportConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ProjectImportConfiguration.java
@@ -11,6 +11,8 @@
package org.eclipse.m2e.core.project;
+import java.util.regex.Matcher;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
@@ -76,7 +78,7 @@ public class ProjectImportConfiguration {
public String getProjectName(Model model) {
// XXX should use resolved MavenProject or Model
if(projectNameTemplate.length() == 0) {
- return model.getArtifactId();
+ return cleanProjectNameComponent(model.getArtifactId(), false);
}
String artifactId = model.getArtifactId();
@@ -90,8 +92,18 @@ public class ProjectImportConfiguration {
}
// XXX needs MavenProjectManager update to resolve groupId and version
- return projectNameTemplate.replaceAll(GROUP_ID, groupId).replaceAll(ARTIFACT_ID, artifactId)
- .replaceAll(VERSION, version == null ? "" : version); //$NON-NLS-1$
+ return projectNameTemplate.replaceAll(GROUP_ID, cleanProjectNameComponent(groupId, true))
+ .replaceAll(ARTIFACT_ID, cleanProjectNameComponent(artifactId, true))
+ .replaceAll(VERSION, version == null ? "" : cleanProjectNameComponent(version, true)); //$NON-NLS-1$
+ }
+
+ private static final String cleanProjectNameComponent(String value, boolean quote) {
+ // remove property placeholders
+ value = value.replaceAll("\\$\\{[^\\}]++\\}", ""); //$NON-NLS-1$ $NON-NLS-2$
+ if(quote) {
+ value = Matcher.quoteReplacement(value);
+ }
+ return value;
}
/**

Back to the top