From bc760a8afcbd4c38fb88d5fc6a54d78771205312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 10 Nov 2022 07:01:36 +0100 Subject: [PATCH] Add new IProjectConfiguration as replacement for ResolverConfiguration Currently ResolverConfiguration is used for many purpose especially for grouping projects in resolve operations. The problem is that this class itself is modifiable and thus can change without any notice and as it is a public API class we can't easily change this or have alternative implementations. Beside that the javadoc suggest that the naming is not well chosen. This adds a new interface IProjectConfiguration that also takes the new concept of MultiModuleProjectDirectory into account --- ...ractM2eAptProjectConfiguratorTestCase.java | 3 +- .../META-INF/MANIFEST.MF | 2 +- .../internal/actions/MavenPropertyTester.java | 6 +- .../MavenProjectPreferencePage.java | 7 +- .../ResolverConfigurationComponent.java | 5 +- .../core/internal/builder/MavenBuilder.java | 4 +- .../project/ProjectConfigurationManager.java | 9 +-- .../project/ResolverConfigurationIO.java | 18 ++--- .../DefaultMavenDependencyResolver.java | 2 +- .../EclipseWorkspaceArtifactRepository.java | 2 +- .../project/registry/MavenProjectFacade.java | 6 ++ .../registry/ProjectRegistryManager.java | 30 ++++---- .../m2e/core/project/IMavenProjectFacade.java | 10 +++ .../core/project/IProjectConfiguration.java | 42 +++++++++++ .../project/IProjectConfigurationManager.java | 4 +- .../core/project/ResolverConfiguration.java | 72 +++++++++++++++++-- .../launch/MavenRuntimeClasspathProvider.java | 4 +- .../eclipse/m2e/actions/ExecutePomAction.java | 4 +- .../META-INF/MANIFEST.MF | 2 +- .../internal/management/ProfileManager.java | 3 +- 20 files changed, 181 insertions(+), 54 deletions(-) create mode 100644 org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfiguration.java diff --git a/org.eclipse.m2e.apt.tests/src/org/eclipse/m2e/apt/tests/AbstractM2eAptProjectConfiguratorTestCase.java b/org.eclipse.m2e.apt.tests/src/org/eclipse/m2e/apt/tests/AbstractM2eAptProjectConfiguratorTestCase.java index a1f3b19e76..e48090ada4 100644 --- a/org.eclipse.m2e.apt.tests/src/org/eclipse/m2e/apt/tests/AbstractM2eAptProjectConfiguratorTestCase.java +++ b/org.eclipse.m2e.apt.tests/src/org/eclipse/m2e/apt/tests/AbstractM2eAptProjectConfiguratorTestCase.java @@ -46,6 +46,7 @@ import org.eclipse.m2e.apt.preferences.AnnotationProcessingMode; import org.eclipse.m2e.apt.preferences.IPreferencesManager; import org.eclipse.m2e.core.MavenPlugin; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.IProjectCreationListener; import org.eclipse.m2e.core.project.ResolverConfiguration; @@ -139,7 +140,7 @@ protected void updateProject(IProject project, String newPomName) throws Excepti } IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager(); - ResolverConfiguration configuration = new ResolverConfiguration(); + IProjectConfiguration configuration = new ResolverConfiguration(); configurationManager.enableMavenNature(project, configuration, monitor); configurationManager.updateProjectConfiguration(project, monitor); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor); diff --git a/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF b/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF index ec4128275b..45c2add114 100644 --- a/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.binaryproject/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.m2e.binaryproject;singleton:=true -Bundle-Version: 2.0.1.qualifier +Bundle-Version: 2.1.0.qualifier Bundle-Vendor: Eclipse.org - m2e Bundle-Name: M2E Binary Project Core Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)", diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java index a2a44c4ace..223bc88bac 100644 --- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java +++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenPropertyTester.java @@ -30,8 +30,8 @@ import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.MavenProjectUtils; -import org.eclipse.m2e.core.project.ResolverConfiguration; /** @@ -69,8 +69,8 @@ public boolean test(Object receiver, String property, Object[] args, Object expe IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry(); IMavenProjectFacade projectFacade = projectManager.create(projectAdapter, new NullProgressMonitor()); if(projectFacade != null) { - ResolverConfiguration configuration = projectFacade.getResolverConfiguration(); - return !configuration.shouldResolveWorkspaceProjects(); + IProjectConfiguration configuration = projectFacade.getResolverConfiguration(); + return !configuration.isResolveWorkspaceProjects(); } } return enableWorkspaceResolution; 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 5e57c842b5..52fe929279 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 @@ -36,6 +36,7 @@ import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.internal.IMavenConstants; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.ResolverConfiguration; import org.eclipse.m2e.core.ui.internal.Messages; @@ -107,9 +108,9 @@ protected void performDefaults() { init(new ResolverConfiguration()); } - private void init(ResolverConfiguration configuration) { + private void init(IProjectConfiguration configuration) { - resolveWorspaceProjectsButton.setSelection(configuration.shouldResolveWorkspaceProjects()); + resolveWorspaceProjectsButton.setSelection(configuration.isResolveWorkspaceProjects()); // includeModulesButton.setSelection(configuration.shouldIncludeModules()); selectedProfilesText.setText(configuration.getSelectedProfiles()); } @@ -129,7 +130,7 @@ public boolean performOk() { final ResolverConfiguration configuration = getResolverConfiguration(); if(configuration.getSelectedProfiles().equals(selectedProfilesText.getText()) && // configuration.shouldIncludeModules()==includeModulesButton.getSelection() && - configuration.shouldResolveWorkspaceProjects() == resolveWorspaceProjectsButton.getSelection()) { + configuration.isResolveWorkspaceProjects() == resolveWorspaceProjectsButton.getSelection()) { return true; } 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 d16b1a0e2a..28d5ce2a5d 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 @@ -29,6 +29,7 @@ import org.eclipse.ui.forms.events.ExpansionEvent; import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.ProjectImportConfiguration; import org.eclipse.m2e.core.project.ResolverConfiguration; import org.eclipse.m2e.core.ui.internal.Messages; @@ -117,14 +118,14 @@ public void expansionStateChanged(ExpansionEvent e) { } public void loadData() { - resolveWorkspaceProjects.setSelection(resolverConfiguration.shouldResolveWorkspaceProjects()); + resolveWorkspaceProjects.setSelection(resolverConfiguration.isResolveWorkspaceProjects()); profiles.setText(resolverConfiguration.getSelectedProfiles()); if(template != null) { template.setText(projectImportConfiguration.getProjectNameTemplate()); } } - public ResolverConfiguration getResolverConfiguration() { + public IProjectConfiguration getResolverConfiguration() { return this.resolverConfiguration; } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java index ef4ed366ce..7b2e5f0b17 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java @@ -42,8 +42,8 @@ import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager; import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager; import org.eclipse.m2e.core.project.IMavenProjectFacade; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.IProjectConfigurationManager; -import org.eclipse.m2e.core.project.ResolverConfiguration; import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant; import org.eclipse.m2e.core.project.configurator.ILifecycleMapping; import org.eclipse.m2e.core.project.configurator.MojoExecutionKey; @@ -74,7 +74,7 @@ public final T execute(final int kind, final Map args, IProgress return null; } - ResolverConfiguration resolverConfiguration = configurationManager.getResolverConfiguration(project); + IProjectConfiguration resolverConfiguration = configurationManager.getResolverConfiguration(project); if(resolverConfiguration == null) { // TODO unit test me diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java index 7ea8bf6d93..c27109d97d 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java @@ -82,6 +82,7 @@ import org.eclipse.m2e.core.project.IMavenProjectChangedListener; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectImportResult; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.IProjectCreationListener; import org.eclipse.m2e.core.project.MavenProjectChangedEvent; @@ -503,7 +504,7 @@ private void updateProjectConfiguration(ProjectConfigurationRequest request, IPr } @Override - public void enableMavenNature(IProject project, ResolverConfiguration configuration, IProgressMonitor monitor) + public void enableMavenNature(IProject project, IProjectConfiguration configuration, IProgressMonitor monitor) throws CoreException { monitor.subTask(Messages.ProjectConfigurationManager_task_enable_nature); IMavenExecutionContext.getThreadContext().orElseGet(maven::createExecutionContext).execute(new AbstractRunnable() { @@ -515,7 +516,7 @@ protected void run(IMavenExecutionContext context, IProgressMonitor monitor) thr }, monitor); } - void enableBasicMavenNature(IProject project, ResolverConfiguration configuration, IProgressMonitor monitor) + void enableBasicMavenNature(IProject project, IProjectConfiguration configuration, IProgressMonitor monitor) throws CoreException { ResolverConfigurationIO.saveResolverConfiguration(project, configuration); @@ -838,7 +839,7 @@ IProject create(MavenProjectInfo projectInfo, ProjectImportConfiguration configu listener.projectCreated(project); } - ResolverConfiguration resolverConfiguration = configuration.getResolverConfiguration(); + IProjectConfiguration resolverConfiguration = configuration.getResolverConfiguration(); enableBasicMavenNature(project, resolverConfiguration, monitor); // create empty/marker persistent configuration @@ -919,7 +920,7 @@ public ResolverConfiguration getResolverConfiguration(IProject project) { } @Override - public boolean setResolverConfiguration(IProject project, ResolverConfiguration configuration) { + public boolean setResolverConfiguration(IProject project, IProjectConfiguration configuration) { return ResolverConfigurationIO.saveResolverConfiguration(project, configuration); } 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 4763d18f72..4db8b4f3a4 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 @@ -16,6 +16,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; +import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.stream.Collectors; @@ -31,6 +32,7 @@ import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.m2e.core.internal.IMavenConstants; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.ResolverConfiguration; @@ -75,13 +77,13 @@ public class ResolverConfigurationIO { */ private static final String VERSION = "1"; //$NON-NLS-1$ - public static boolean saveResolverConfiguration(IProject project, ResolverConfiguration configuration) { + public static boolean saveResolverConfiguration(IProject project, IProjectConfiguration configuration) { IScopeContext projectScope = new ProjectScope(project); IEclipsePreferences projectNode = projectScope.getNode(IMavenConstants.PLUGIN_ID); if(projectNode != null) { projectNode.put(P_VERSION, VERSION); - projectNode.putBoolean(P_RESOLVE_WORKSPACE_PROJECTS, configuration.shouldResolveWorkspaceProjects()); + projectNode.putBoolean(P_RESOLVE_WORKSPACE_PROJECTS, configuration.isResolveWorkspaceProjects()); projectNode.put(P_SELECTED_PROFILES, configuration.getSelectedProfiles()); @@ -91,8 +93,8 @@ public static boolean saveResolverConfiguration(IProject project, ResolverConfig projectNode.remove(P_LIFECYCLE_MAPPING_ID); } - if(configuration.getProperties() != null && !configuration.getProperties().isEmpty()) { - projectNode.put(P_PROPERTIES, propertiesAsString(configuration.getProperties())); + if(configuration.getConfigurationProperties() != null && !configuration.getConfigurationProperties().isEmpty()) { + projectNode.put(P_PROPERTIES, propertiesAsString(configuration.getConfigurationProperties())); } else { projectNode.remove(P_PROPERTIES); } @@ -129,9 +131,9 @@ public static ResolverConfiguration readResolverConfiguration(IProject project) return configuration; } - private static String propertiesAsString(Properties properties) { - Stream> stream = properties.entrySet().stream(); - String propAsString = stream.map(e -> encodeEntry(e)).collect(Collectors.joining(PROPERTIES_SEPARATOR)); + private static String propertiesAsString(Map properties) { + String propAsString = properties.entrySet().stream().map(e -> encodeEntry(e)) + .collect(Collectors.joining(PROPERTIES_SEPARATOR)); return propAsString; } @@ -154,7 +156,7 @@ private static void convert(String e, Properties p) { p.put(urlDecode(key), urlDecode(value)); } - private static String encodeEntry(Entry e) { + private static String encodeEntry(Entry e) { String key = e.getKey().toString(); String value = e.getValue() == null ? "" : e.getValue().toString(); return urlEncode(key) + PROPERTIES_KV_SEPARATOR + urlEncode(value); diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java index 71292bce3d..b82fd86540 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/DefaultMavenDependencyResolver.java @@ -72,7 +72,7 @@ public void resolveProjectDependencies(final IMavenProjectFacade facade, Set { refreshPhase2(newState, context, originalCapabilities, originalRequirements, pom, facade, pm); @@ -822,7 +823,7 @@ public MavenProjectFacade getMavenProject(String groupId, String artifactId, Str private MavenProject readProjectWithDependencies(IMavenProjectFacade facade) { IFile pomFile = facade.getPom(); - ResolverConfiguration resolverConfiguration = facade.getResolverConfiguration(); + IProjectConfiguration resolverConfiguration = facade.getResolverConfiguration(); Collection results = readProjectsWithDependencies(pomFile, resolverConfiguration, null); if(results.size() != 1) { throw new IllegalStateException("Results should contain one entry."); @@ -850,7 +851,7 @@ private static boolean hasError(MavenExecutionResult mavenExecutionResult) { } private Collection readProjectsWithDependencies(IFile pomFile, - ResolverConfiguration resolverConfiguration, IProgressMonitor monitor) { + IProjectConfiguration resolverConfiguration, IProgressMonitor monitor) { try { IMavenPlexusContainer container = mapToContainer(pomFile); Map resultMap = Map.of(); @@ -885,11 +886,11 @@ public IMavenProjectFacade getProject(IProject project) { static class Context { final IProjectRegistry state; - final ResolverConfiguration resolverConfiguration; + final IProjectConfiguration resolverConfiguration; final IFile pom; - Context(IProjectRegistry state, ResolverConfiguration resolverConfiguration, IFile pom) { + Context(IProjectRegistry state, IProjectConfiguration resolverConfiguration, IFile pom) { this.state = state; this.resolverConfiguration = resolverConfiguration; this.pom = pom; @@ -897,7 +898,7 @@ static class Context { } private MavenExecutionRequest configureExecutionRequest(MavenExecutionRequest request, IProjectRegistry state, - IFile pom, ResolverConfiguration resolverConfiguration) throws CoreException { + IFile pom, IProjectConfiguration resolverConfiguration) throws CoreException { if(pom != null) { request.setPom(ProjectRegistryManager.toJavaIoFile(pom)); } @@ -905,13 +906,14 @@ private MavenExecutionRequest configureExecutionRequest(MavenExecutionRequest re request.addActiveProfiles(resolverConfiguration.getActiveProfileList()); request.addInactiveProfiles(resolverConfiguration.getInactiveProfileList()); - Properties p = request.getUserProperties(); - Properties addProperties = resolverConfiguration.getProperties(); + Properties userProperties = request.getUserProperties(); + Map addProperties = resolverConfiguration.getConfigurationProperties(); if(addProperties != null) { - if(p == null) { - p = new Properties(); + if(userProperties == null) { + userProperties = new Properties(); + //FIXME should we not set them here?? request.setUserProperties(p); } - p.putAll(addProperties); + userProperties.putAll(addProperties); } // eclipse workspace repository implements both workspace dependency resolution @@ -928,7 +930,7 @@ private MavenExecutionRequest configureExecutionRequest(MavenExecutionRequest re } private static EclipseWorkspaceArtifactRepository getWorkspaceReader(IProjectRegistry state, IFile pom, - ResolverConfiguration resolverConfiguration) { + IProjectConfiguration resolverConfiguration) { Context context = new Context(state, resolverConfiguration, pom); return new EclipseWorkspaceArtifactRepository(context); } @@ -978,7 +980,7 @@ PlexusContainerManager getContainerManager() { } private IMavenExecutionContext createExecutionContext(IProjectRegistry state, IFile pom, - ResolverConfiguration resolverConfiguration) throws CoreException { + IProjectConfiguration resolverConfiguration) throws CoreException { IMavenExecutionContext context; try { @@ -1003,7 +1005,7 @@ private IMavenExecutionContext createExecutionContext(IProjectRegistry state, IF return context; } - public IMavenExecutionContext createExecutionContext(IFile pom, ResolverConfiguration resolverConfiguration) + public IMavenExecutionContext createExecutionContext(IFile pom, IProjectConfiguration resolverConfiguration) throws CoreException { return createExecutionContext(projectRegistry, pom, resolverConfiguration); } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java index 968fed9c7d..5f7d84c324 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java @@ -113,6 +113,16 @@ public interface IMavenProjectFacade extends IMavenExecutableLocation { Set getMavenProjectArtifacts(); + /** + * @return the configuration associated with this facade + */ + IProjectConfiguration getConfiguration(); + + /** + * @deprecated use {@link #getConfiguration()} instead + * @return + */ + @Deprecated(forRemoval = true) ResolverConfiguration getResolverConfiguration(); /** diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfiguration.java new file mode 100644 index 0000000000..a9aa824282 --- /dev/null +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfiguration.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2022 Christoph Läubrich + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ + +package org.eclipse.m2e.core.project; + +import java.io.File; +import java.util.List; +import java.util.Map; + + +/** + * {@link IProjectConfiguration} represents the project specific configuration, many projects can share the same + * configuration and are usually resolved together. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IProjectConfiguration { + + Map getConfigurationProperties(); + + boolean isResolveWorkspaceProjects(); + + String getSelectedProfiles(); + + List getActiveProfileList(); + + List getInactiveProfileList(); + + String getLifecycleMappingId(); + + File getMultiModuleProjectDirectory(); + +} diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java index 45fb55e9f3..dc3cefaf1a 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java @@ -55,7 +55,7 @@ void createSimpleProject(IProject project, IPath location, Model model, List collectProjects(Collection projects); - void enableMavenNature(IProject project, ResolverConfiguration configuration, IProgressMonitor monitor) + void enableMavenNature(IProject project, IProjectConfiguration configuration, IProgressMonitor monitor) throws CoreException; void disableMavenNature(IProject project, IProgressMonitor monitor) throws CoreException; @@ -90,6 +90,6 @@ boolean removeMavenBuilder(IProject project, IProjectDescription description, IP /** * PROVISIONAL */ - boolean setResolverConfiguration(IProject project, ResolverConfiguration configuration); + boolean setResolverConfiguration(IProject project, IProjectConfiguration configuration); } 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 8ade26ceaf..e8d774c1ee 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 @@ -14,11 +14,16 @@ package org.eclipse.m2e.core.project; +import java.io.File; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Properties; +import java.util.Set; /** @@ -27,7 +32,7 @@ * * @author Eugene Kuleshov */ -public class ResolverConfiguration implements Serializable { +public class ResolverConfiguration implements Serializable, IProjectConfiguration { private static final long serialVersionUID = 1258510761534886581L; private boolean resolveWorkspaceProjects = true; @@ -38,26 +43,63 @@ public class ResolverConfiguration implements Serializable { private Properties properties; + private File multiModuleProjectDirectory; + + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getProperties() + */ public Properties getProperties() { return this.properties; } + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getConfigurationProperties() + */ + @Override + public Map getConfigurationProperties() { + if(properties == null) { + return Collections.emptyMap(); + } + Set names = properties.stringPropertyNames(); + Map map = new HashMap<>(); + for(String key : names) { + map.put(key, properties.getProperty(key)); + } + return Collections.unmodifiableMap(map); + } + public void setProperties(Properties properties) { this.properties = properties; } - public boolean shouldResolveWorkspaceProjects() { + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#shouldResolveWorkspaceProjects() + */ + @Override + public boolean isResolveWorkspaceProjects() { return this.resolveWorkspaceProjects; } + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getSelectedProfiles() + */ + @Override public String getSelectedProfiles() { return this.selectedProfiles; } + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getActiveProfileList() + */ + @Override public List getActiveProfileList() { return parseProfiles(selectedProfiles, true); } + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getInactiveProfileList() + */ + @Override public List getInactiveProfileList() { return parseProfiles(selectedProfiles, false); } @@ -88,9 +130,10 @@ private static List parseProfiles(String profilesAsText, boolean status) return profiles; } - /** - * @since 1.3 + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getLifecycleMappingId() */ + @Override public String getLifecycleMappingId() { return lifecycleMappingId; } @@ -120,11 +163,28 @@ public boolean equals(Object obj) { return this.resolveWorkspaceProjects == other.resolveWorkspaceProjects && Objects.equals(this.selectedProfiles, other.selectedProfiles) && Objects.equals(this.lifecycleMappingId, other.lifecycleMappingId) - && Objects.equals(this.properties, other.properties); + && Objects.equals(this.properties, other.properties) + && Objects.equals(this.multiModuleProjectDirectory, other.multiModuleProjectDirectory); } @Override public int hashCode() { - return Objects.hash(resolveWorkspaceProjects, selectedProfiles, lifecycleMappingId, properties); + return Objects.hash(resolveWorkspaceProjects, selectedProfiles, lifecycleMappingId, properties, + multiModuleProjectDirectory); + } + + /* (non-Javadoc) + * @see org.eclipse.m2e.core.project.IProjectConfiguration#getMultiModuleProjectDirectory() + */ + @Override + public File getMultiModuleProjectDirectory() { + return multiModuleProjectDirectory; + } + + /** + * @param multiModuleProjectDirectory The multiModuleProjectDirectory to set. + */ + public void setMultiModuleProjectDirectory(File multiModuleProjectDirectory) { + this.multiModuleProjectDirectory = multiModuleProjectDirectory; } } diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java index 386d4f19d0..3b1bc09cc4 100644 --- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java +++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/launch/MavenRuntimeClasspathProvider.java @@ -56,7 +56,7 @@ import org.eclipse.m2e.core.embedder.IMavenExecutionContext; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; -import org.eclipse.m2e.core.project.ResolverConfiguration; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.jdt.IClassifierClasspathProvider; import org.eclipse.m2e.jdt.IClasspathManager; import org.eclipse.m2e.jdt.IMavenClassifierManager; @@ -313,7 +313,7 @@ protected void addProjectEntries(Set resolved, IPath pat return; } - ResolverConfiguration configuration = projectFacade.getResolverConfiguration(); + IProjectConfiguration configuration = projectFacade.getResolverConfiguration(); if(configuration == null) { return; } 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 b004aae632..48373f3e0d 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 @@ -66,7 +66,7 @@ import org.eclipse.m2e.core.internal.IMavenConstants; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; -import org.eclipse.m2e.core.project.ResolverConfiguration; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.internal.launch.LaunchingUtils; import org.eclipse.m2e.internal.launch.Messages; import org.eclipse.m2e.ui.internal.launch.MavenLaunchMainTab; @@ -236,7 +236,7 @@ private void setProjectConfiguration(ILaunchConfigurationWorkingCopy workingCopy IFile pomFile = basedir.getFile(new Path(IMavenConstants.POM_FILE_NAME)); IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor()); if(projectFacade != null) { - ResolverConfiguration configuration = projectFacade.getResolverConfiguration(); + IProjectConfiguration configuration = projectFacade.getResolverConfiguration(); String selectedProfiles = configuration.getSelectedProfiles(); if(selectedProfiles != null && selectedProfiles.length() > 0) { diff --git a/org.eclipse.m2e.profiles.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.profiles.core/META-INF/MANIFEST.MF index 5c1e7b3eac..bfc990809f 100644 --- a/org.eclipse.m2e.profiles.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.profiles.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: M2E Maven Profiles Management Bundle-SymbolicName: org.eclipse.m2e.profiles.core;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.1.0.qualifier Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.core.resources;bundle-version="3.6.0", org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)", diff --git a/org.eclipse.m2e.profiles.core/src/org/eclipse/m2e/profiles/core/internal/management/ProfileManager.java b/org.eclipse.m2e.profiles.core/src/org/eclipse/m2e/profiles/core/internal/management/ProfileManager.java index 43001a1f9d..f8be200166 100644 --- a/org.eclipse.m2e.profiles.core/src/org/eclipse/m2e/profiles/core/internal/management/ProfileManager.java +++ b/org.eclipse.m2e.profiles.core/src/org/eclipse/m2e/profiles/core/internal/management/ProfileManager.java @@ -58,6 +58,7 @@ import org.eclipse.m2e.core.internal.Messages; import org.eclipse.m2e.core.internal.NoSuchComponentException; import org.eclipse.m2e.core.project.IMavenProjectFacade; +import org.eclipse.m2e.core.project.IProjectConfiguration; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.MavenUpdateRequest; import org.eclipse.m2e.core.project.ResolverConfiguration; @@ -133,7 +134,7 @@ public List getProfileDatas(IMavenProjectFacade facade, IProgressMo return Collections.emptyList(); } - ResolverConfiguration resolverConfiguration = MavenPlugin.getProjectConfigurationManager() + IProjectConfiguration resolverConfiguration = MavenPlugin.getProjectConfigurationManager() .getResolverConfiguration(facade.getProject()); List configuredProfiles = toList(resolverConfiguration.getSelectedProfiles());