diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java index 818b491fd..675149377 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java @@ -18,6 +18,7 @@ import org.eclipse.m2e.core.embedder.MavenModelManager; import org.eclipse.m2e.core.embedder.MavenRuntimeManager; import org.eclipse.m2e.core.internal.MavenPluginActivator; +import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IMavenProjectRegistry; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.IWorkspaceClassifierResolverManager; @@ -41,6 +42,11 @@ public static MavenPlugin getDefault() { return INSTANCE; } + /** + * Use {@link IMavenProjectFacade#getMaven()} instead whenever possible + * + * @return a generic Maven instance (not customized by project). + */ public static IMaven getMaven() { return MavenPluginActivator.getDefault().getMaven(); } diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java index a807c6b4a..be6a5a682 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java @@ -36,6 +36,7 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; +import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.embedder.ArtifactKey; import org.eclipse.m2e.core.embedder.ArtifactRef; import org.eclipse.m2e.core.embedder.ArtifactRepositoryRef; @@ -528,4 +529,10 @@ public List getExecutionPlan(String lifecycle, IProgressMonitor m Map> executionPlans = getExecutionPlans(monitor); return executionPlans != null ? executionPlans.get(lifecycle) : null; } + + @Override + public IMaven getMaven() { + // TODO: if project has Maven customization (such as a .mvn, MAVEN_OPTS...) + return MavenPlugin.getMaven(); + } } 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 55025294d..58126341d 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 @@ -30,6 +30,7 @@ import org.eclipse.m2e.core.embedder.ArtifactKey; import org.eclipse.m2e.core.embedder.ArtifactRef; import org.eclipse.m2e.core.embedder.ArtifactRepositoryRef; +import org.eclipse.m2e.core.embedder.IMaven; import org.eclipse.m2e.core.lifecyclemapping.model.IPluginExecutionMetadata; import org.eclipse.m2e.core.project.configurator.MojoExecutionKey; @@ -137,6 +138,13 @@ public interface IMavenProjectFacade { Set getPluginArtifactRepositoryRefs(); + /** + * Gets an access to a Maven instance, configured according to this project. + * + * @return a Maven instance, configured according to this project + */ + IMaven getMaven(); + /** * Returns fully setup MojoExecution instance bound to project build lifecycle that matches provided mojoExecutionKey. * Returns null if no such mojo execution. @@ -156,4 +164,5 @@ List getMojoExecutions(String groupId, String artifactId, IProgre String getLifecycleMappingId(); Map> getMojoExecutionMapping(); + }