aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2011-11-07 14:22:35 (EST)
committerIgor Fedorenko2011-12-21 17:51:29 (EST)
commitb54eb3513fe7e2270ed4c8413c09a5d05b35b5fd (patch)
tree1cfe8360f6c7f832c0841f076f62de3c530dba7c
parent3ecc071ad0eb0950c0369613b20e1fce4fc35cd2 (diff)
downloadm2e-core-b54eb3513fe7e2270ed4c8413c09a5d05b35b5fd.zip
m2e-core-b54eb3513fe7e2270ed4c8413c09a5d05b35b5fd.tar.gz
m2e-core-b54eb3513fe7e2270ed4c8413c09a5d05b35b5fd.tar.bz2
Bug 337353 : properly parse active and inactive profiles, used when building Maven requests
Signed-off-by: Fred Bricon <fbricon@gmail.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenProjectPreferencePage.java12
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ResolverConfigurationIO.java7
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java53
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java6
8 files changed, 64 insertions, 25 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
index d697c60..7be7e4e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
@@ -128,7 +128,7 @@ public class EnableNatureAction implements IObjectActionDelegate, IExecutableExt
try {
ResolverConfiguration configuration = new ResolverConfiguration();
configuration.setResolveWorkspaceProjects(workspaceProjects);
- configuration.setActiveProfiles(""); //$NON-NLS-1$
+ configuration.setSelectedProfiles(""); //$NON-NLS-1$
boolean hasMavenNature = project.hasNature(IMavenConstants.NATURE_ID);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenProjectPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenProjectPreferencePage.java
index b691df1..36cb144 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenProjectPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenProjectPreferencePage.java
@@ -49,7 +49,7 @@ public class MavenProjectPreferencePage extends PropertyPage {
private Button resolveWorspaceProjectsButton;
// private Button includeModulesButton;
- private Text activeProfilesText;
+ private Text selectedProfilesText;
public MavenProjectPreferencePage() {
setTitle(Messages.MavenProjectPreferencePage_title);
@@ -64,8 +64,8 @@ public class MavenProjectPreferencePage extends PropertyPage {
profilesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
profilesLabel.setText(Messages.MavenProjectPreferencePage_lblProfiles);
- activeProfilesText = new Text(composite, SWT.BORDER);
- activeProfilesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ selectedProfilesText = new Text(composite, SWT.BORDER);
+ selectedProfilesText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
resolveWorspaceProjectsButton = new Button(composite, SWT.CHECK);
GridData resolveWorspaceProjectsButtonData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
@@ -105,7 +105,7 @@ public class MavenProjectPreferencePage extends PropertyPage {
resolveWorspaceProjectsButton.setSelection(configuration.shouldResolveWorkspaceProjects());
// includeModulesButton.setSelection(configuration.shouldIncludeModules());
- activeProfilesText.setText(configuration.getActiveProfiles());
+ selectedProfilesText.setText(configuration.getSelectedProfiles());
}
public boolean performOk() {
@@ -120,7 +120,7 @@ public class MavenProjectPreferencePage extends PropertyPage {
}
final ResolverConfiguration configuration = getResolverConfiguration();
- if(configuration.getActiveProfiles().equals(activeProfilesText.getText()) &&
+ if(configuration.getSelectedProfiles().equals(selectedProfilesText.getText()) &&
// configuration.shouldIncludeModules()==includeModulesButton.getSelection() &&
configuration.shouldResolveWorkspaceProjects()==resolveWorspaceProjectsButton.getSelection()) {
return true;
@@ -128,7 +128,7 @@ public class MavenProjectPreferencePage extends PropertyPage {
configuration.setResolveWorkspaceProjects(resolveWorspaceProjectsButton.getSelection());
// configuration.setIncludeModules(includeModulesButton.getSelection());
- configuration.setActiveProfiles(activeProfilesText.getText());
+ configuration.setSelectedProfiles(selectedProfilesText.getText());
IProjectConfigurationManager projectManager = MavenPlugin.getProjectConfigurationManager();
boolean isSet = projectManager.setResolverConfiguration(getProject(), configuration);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
index 8306bcd..690a5ea 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/ResolverConfigurationComponent.java
@@ -101,7 +101,7 @@ public class ResolverConfigurationComponent extends ExpandableComposite {
profiles.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
profiles.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- resolverConfiguration.setActiveProfiles(profiles.getText());
+ resolverConfiguration.setSelectedProfiles(profiles.getText());
}
});
@@ -126,7 +126,7 @@ public class ResolverConfigurationComponent extends ExpandableComposite {
public void loadData() {
resolveWorkspaceProjects.setSelection(resolverConfiguration.shouldResolveWorkspaceProjects());
- profiles.setText(resolverConfiguration.getActiveProfiles());
+ profiles.setText(resolverConfiguration.getSelectedProfiles());
if(template != null) {
template.setText(projectImportConfiguration.getProjectNameTemplate());
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java
index 74bd7b5..ae7fc95 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java
@@ -275,6 +275,7 @@ public class LifecycleMappingConfiguration {
request.setPom(projectInfo.getPomFile());
request.addActiveProfiles(importConfiguration.getResolverConfiguration().getActiveProfileList());
+ request.addInactiveProfiles(importConfiguration.getResolverConfiguration().getInactiveProfileList());
// jdk-based profile activation
Properties systemProperties = new Properties();
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ResolverConfigurationIO.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ResolverConfigurationIO.java
index f379d26..afd76f5 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ResolverConfigurationIO.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ResolverConfigurationIO.java
@@ -42,7 +42,8 @@ public class ResolverConfigurationIO {
/**
* Active profiles project preference key. Value is comma-separated list of enabled profiles.
*/
- private static final String P_ACTIVE_PROFILES = "activeProfiles"; //$NON-NLS-1$
+ //FIXME Bug 337353 Can't rename the preference key as it would break existing projects
+ private static final String P_SELECTED_PROFILES = "activeProfiles"; //$NON-NLS-1$
/**
* Current configuration version value. See {@link #P_VERSION}
@@ -57,7 +58,7 @@ public class ResolverConfigurationIO {
projectNode.putBoolean(P_RESOLVE_WORKSPACE_PROJECTS, configuration.shouldResolveWorkspaceProjects());
- projectNode.put(P_ACTIVE_PROFILES, configuration.getActiveProfiles());
+ projectNode.put(P_SELECTED_PROFILES, configuration.getSelectedProfiles());
try {
projectNode.flush();
@@ -86,7 +87,7 @@ public class ResolverConfigurationIO {
ResolverConfiguration configuration = new ResolverConfiguration();
configuration.setResolveWorkspaceProjects(projectNode.getBoolean(P_RESOLVE_WORKSPACE_PROJECTS, false));
- configuration.setActiveProfiles(projectNode.get(P_ACTIVE_PROFILES, "")); //$NON-NLS-1$
+ configuration.setSelectedProfiles(projectNode.get(P_SELECTED_PROFILES, "")); //$NON-NLS-1$
return configuration;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
index 6afea34..340ecbe 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
@@ -790,9 +790,9 @@ public class ProjectRegistryManager {
private MavenExecutionRequest configureExecutionRequest(MavenExecutionRequest request, IProjectRegistry state,
IFile pom, ResolverConfiguration resolverConfiguration) throws CoreException {
request.setPom(pom.getLocation().toFile());
-
+
request.addActiveProfiles(resolverConfiguration.getActiveProfileList());
-
+ request.addInactiveProfiles(resolverConfiguration.getInactiveProfileList());
// temporary solution for https://issues.sonatype.org/browse/MNGECLIPSE-1607
Properties systemProperties = new Properties();
EnvironmentUtils.addEnvVars(systemProperties);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java
index 8271bd1..dc258ef 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/ResolverConfiguration.java
@@ -29,28 +29,65 @@ public class ResolverConfiguration implements Serializable {
private boolean resolveWorkspaceProjects = true;
- private String activeProfiles = ""; //$NON-NLS-1$
+ private String selectedProfiles = ""; //$NON-NLS-1$
public boolean shouldResolveWorkspaceProjects() {
return this.resolveWorkspaceProjects;
}
+
+ /**
+ * @deprecated use {@link #getSelectedProfiles()} instead.
+ */
+ @Deprecated
public String getActiveProfiles() {
- return this.activeProfiles;
+ return getSelectedProfiles();
}
-
+
+ public String getSelectedProfiles() {
+ return this.selectedProfiles;
+ }
+
public List<String> getActiveProfileList() {
- if (activeProfiles.trim().length() > 0) {
- return Arrays.asList(activeProfiles.split("[,\\s\\|]")); //$NON-NLS-1$
- }
- return new ArrayList<String>();
+ return parseProfiles(selectedProfiles, true);
+ }
+
+ public List<String> getInactiveProfileList() {
+ return parseProfiles(selectedProfiles, false);
}
public void setResolveWorkspaceProjects(boolean resolveWorkspaceProjects) {
this.resolveWorkspaceProjects = resolveWorkspaceProjects;
}
+ /**
+ * @deprecated use {@link #setSelectedProfiles(String)} instead.
+ */
+ @Deprecated
public void setActiveProfiles(String activeProfiles) {
- this.activeProfiles = activeProfiles;
+ setSelectedProfiles(activeProfiles);
+ }
+
+ public void setSelectedProfiles(String profiles) {
+ this.selectedProfiles = profiles;
}
+
+ private static List<String> parseProfiles(String profilesAsText, boolean status) {
+ List<String> profiles;
+ if (profilesAsText != null && profilesAsText.trim().length() > 0) {
+ String[] profilesArray = profilesAsText.split("[,\\s\\|]");
+ profiles = new ArrayList<String>(profilesArray.length);
+ for (String profile : profilesArray) {
+ boolean isActive = !profile.startsWith("!");
+ if (status == isActive) {
+ profile = (isActive)? profile : profile.substring(1);
+ profiles.add(profile);
+ }
+ }
+ } else {
+ profiles = new ArrayList<String>(0);
+ }
+ return profiles;
+ }
+
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
index b704fde..7a30696 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/ExecutePomAction.java
@@ -230,9 +230,9 @@ public class ExecutePomAction implements ILaunchShortcut, IExecutableExtension {
if(projectFacade != null) {
ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
- String activeProfiles = configuration.getActiveProfiles();
- if(activeProfiles != null && activeProfiles.length() > 0) {
- workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, activeProfiles);
+ String selectedProfiles = configuration.getSelectedProfiles();
+ if(selectedProfiles != null && selectedProfiles.length() > 0) {
+ workingCopy.setAttribute(MavenLaunchConstants.ATTR_PROFILES, selectedProfiles);
}
}
}