Skip to content

Commit

Permalink
Keep new utility method getMojoParameterValue(...) private
Browse files Browse the repository at this point in the history
  • Loading branch information
kwin committed Nov 25, 2022
1 parent 06de1a6 commit 2cb839d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.core</artifactId>
<version>2.0.4-SNAPSHOT</version>
<version>2.0.5-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>Maven Integration for Eclipse Core Plug-in</name>
Expand Down
23 changes: 0 additions & 23 deletions org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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> T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, String parameter,
Class<T> 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 <T>
* @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 <configuration>} 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> T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, List<String> parameterPath,
Class<T> asType, IProgressMonitor monitor) throws CoreException;

/**
* @since 1.4
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,29 @@ public <T> 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 <T>
* @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 <configuration>} 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> T getMojoParameterValue(MavenProject project, MojoExecution mojoExecution, List<String> parameterPath,
Class<T> asType, IProgressMonitor monitor) throws CoreException {
return getExecutionContext().execute(project,
(context, pm) -> getMojoParameterValue(context.getSession(), mojoExecution, parameterPath, asType), monitor);
}

private <T> T getMojoParameterValue(String parameter, Class<T> type, MavenSession session, Plugin plugin,
ConfigurationContainer configuration, String goal) throws CoreException {
Xpp3Dom config = (Xpp3Dom) configuration.getConfiguration();
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 2cb839d

Please sign in to comment.