From 2cb839d2179f9acd49da109a5a5300aa0331ad74 Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Fri, 25 Nov 2022 14:31:56 +0100 Subject: [PATCH] Keep new utility method getMojoParameterValue(...) private --- org.eclipse.m2e.core/META-INF/MANIFEST.MF | 2 +- org.eclipse.m2e.core/pom.xml | 2 +- .../org/eclipse/m2e/core/embedder/IMaven.java | 23 ------------------- .../m2e/core/internal/embedder/MavenImpl.java | 20 ++++++++++++++-- org.eclipse.m2e.jdt/META-INF/MANIFEST.MF | 2 +- .../AbstractJavaProjectConfigurator.java | 3 ++- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF index b5bf392b18..187ebf94b8 100644 --- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.0.5.qualifier Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin diff --git a/org.eclipse.m2e.core/pom.xml b/org.eclipse.m2e.core/pom.xml index 0183680564..559f4b3e2d 100644 --- a/org.eclipse.m2e.core/pom.xml +++ b/org.eclipse.m2e.core/pom.xml @@ -19,7 +19,7 @@ org.eclipse.m2e.core - 2.0.4-SNAPSHOT + 2.0.5-SNAPSHOT eclipse-plugin Maven Integration for Eclipse Core Plug-in diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java index af905f20bf..b632ba2e06 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java @@ -22,8 +22,6 @@ import java.util.List; import java.util.Map; -import org.osgi.annotation.versioning.ProviderType; - import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -59,7 +57,6 @@ * @author igor * @noimplement This interface is not intended to be implemented by clients. */ -@ProviderType public interface IMaven extends IComponentLookup { // POM Model read/write operations @@ -173,30 +170,10 @@ MojoExecution setupMojoExecution(MavenProject project, MojoExecution execution, * @return the parameter value or {@code null} if the parameter with the given name was not found * @throws CoreException * @since 1.4 - * @see IMaven#getMojoParameterValue(MavenProject, MojoExecution, List, Class, IProgressMonitor) */ T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, String parameter, Class asType, IProgressMonitor monitor) throws CoreException; - /** - * Resolves a nested configuration parameter from the given {@code mojoExecution}. It coerces from String to the given - * type and considers expressions and default values. - * - * @param - * @param project the Maven project - * @param mojoExecution the mojo execution from which to retrieve the configuration value - * @param parameterPath the path of the parameter to look up, the first item is the name of the element directly below - * {@code } and the last one is the element containing the actual value - * @param asType the type to coerce to - * @param monitor the progress monitor - * @return the parameter value or {@code null} if the parameter with the given name was not found - * @throws CoreException - * @since 2.1.0 - * @see IMaven#getMojoParameterValue(MavenProject, MojoExecution, String, Class, IProgressMonitor) - */ - T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, List parameterPath, - Class asType, IProgressMonitor monitor) throws CoreException; - /** * @since 1.4 */ diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java index e5fa3666af..d92ca47de0 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java @@ -755,13 +755,29 @@ public T getMojoParameterValue(MavenProject project, MojoExecution mojoExecu monitor); } - @Override + /** + * Resolves a nested configuration parameter from the given {@code mojoExecution}. It coerces from String to the given + * type and considers expressions and default values. Deliberately no public API yet as probably refactored in the + * near future. + * + * @param + * @param project the Maven project + * @param mojoExecution the mojo execution from which to retrieve the configuration value + * @param parameterPath the path of the parameter to look up, the first item is the name of the element directly below + * {@code } and the last one is the element containing the actual value + * @param asType the type to coerce to + * @param monitor the progress monitor + * @return the parameter value or {@code null} if the parameter with the given name was not found + * @throws CoreException + * @since 2.1.0 + * @see IMaven#getMojoParameterValue(MavenProject, MojoExecution, String, Class, IProgressMonitor) + */ public T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, List parameterPath, Class asType, IProgressMonitor monitor) throws CoreException { return getExecutionContext().execute(project, (context, pm) -> getMojoParameterValue(context.getSession(), mojoExecution, parameterPath, asType), monitor); } - + private T getMojoParameterValue(String parameter, Class type, MavenSession session, Plugin plugin, ConfigurationContainer configuration, String goal) throws CoreException { Xpp3Dom config = (Xpp3Dom) configuration.getConfiguration(); diff --git a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF index a35c32ed4b..b7c512a028 100644 --- a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.m2e.jdt;singleton:=true -Bundle-Version: 2.0.2.qualifier +Bundle-Version: 2.0.3.qualifier Bundle-Localization: plugin Export-Package: org.eclipse.m2e.jdt, org.eclipse.m2e.jdt.internal;x-friends:="org.eclipse.m2e.jdt.ui", diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java index 58115199aa..1e1918873d 100644 --- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java +++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/AbstractJavaProjectConfigurator.java @@ -55,6 +55,7 @@ import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.internal.M2EUtils; +import org.eclipse.m2e.core.internal.embedder.MavenImpl; import org.eclipse.m2e.core.project.IMavenProjectFacade; import org.eclipse.m2e.core.project.IProjectConfigurationManager; import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator; @@ -858,7 +859,7 @@ private String getMinimumJavaBuildEnvironmentId(ProjectConfigurationRequest requ private String getMinimumJavaBuildEnvironmentId(MavenProject mavenProject, MojoExecution mojoExecution, IProgressMonitor monitor) throws InvalidVersionSpecificationException, CoreException { - String version = maven.getMojoParameterValue(mavenProject, mojoExecution, + String version = ((MavenImpl) maven).getMojoParameterValue(mavenProject, mojoExecution, List.of("rules", "requireJavaVersion", "version"), String.class, monitor); return getMinimumJavaBuildEnvironmentId(version); }