diff --git a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java index f6afa058..6ac19888 100644 --- a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java +++ b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java @@ -33,21 +33,22 @@ import java.util.Properties; import org.apache.maven.Maven; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; -import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Settings; import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.components.io.fileselectors.FileSelector; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; @@ -68,12 +69,16 @@ public class WrapperMojo extends AbstractMojo { /** * The version of Maven to require, default value is the Runtime version of Maven. * Can be any valid release above 2.0.9 + * + * @since 3.0.0 */ @Parameter(property = "maven") private String mavenVersion; /** * The version of Maven Daemon to require. + * + * @since 3.2.0 */ @Parameter(property = "mvnd") private String mvndVersion; @@ -88,16 +93,19 @@ public class WrapperMojo extends AbstractMojo { *
source
*
Java source code, will be compiled on the fly
*
only-script
- *
the new lite implementation of mvnw/mvnw.cmd scripts downloads the maven directly and skips maven-wrapper.jar
+ *
the new lite implementation of mvnw/mvnw.cmd scripts downloads the maven directly and skips maven-wrapper.jar - since 3.2.0
* - * * Value will be used as classifier of the downloaded file + * + * @since 3.0.0 */ @Parameter(defaultValue = "bin", property = "type") private String distributionType; /** * Include mvnwDebug* scripts? + * + * @since 3.0.0 */ @Parameter(defaultValue = "false", property = "includeDebug") private boolean includeDebugScript; @@ -105,6 +113,8 @@ public class WrapperMojo extends AbstractMojo { /** * The expected SHA-256 checksum of the maven-wrapper.jar that is * used to load the configured Maven distribution. + * + * @since 3.2.0 */ @Parameter(property = "wrapperSha256Sum") private String wrapperSha256Sum; @@ -112,6 +122,8 @@ public class WrapperMojo extends AbstractMojo { /** * The expected SHA-256 checksum of the Maven distribution that is * executed by the installed wrapper. + * + * @since 3.2.0 */ @Parameter(property = "distributionSha256Sum") private String distributionSha256Sum; @@ -119,6 +131,8 @@ public class WrapperMojo extends AbstractMojo { /** * Determines if the Maven distribution should be downloaded * on every execution of the Maven wrapper. + * + * @since 3.2.0 */ @Parameter(defaultValue = "false", property = "alwaysDownload") private boolean alwaysDownload; @@ -126,6 +140,8 @@ public class WrapperMojo extends AbstractMojo { /** * Determines if the Maven distribution should be unpacked * on every execution of the Maven wrapper. + * + * @since 3.2.0 */ @Parameter(defaultValue = "false", property = "alwaysUnpack") private boolean alwaysUnpack; @@ -198,34 +214,25 @@ private void cleanup(Path wrapperDir) throws MojoExecutionException { } private Artifact downloadWrapperDistribution(String wrapperVersion) throws MojoExecutionException { - Artifact artifact = repositorySystem.createArtifactWithClassifier( + + Artifact artifact = new DefaultArtifact( WRAPPER_DISTRIBUTION_GROUP_ID, WRAPPER_DISTRIBUTION_ARTIFACT_ID, - wrapperVersion, + distributionType, WRAPPER_DISTRIBUTION_EXTENSION, - distributionType); + wrapperVersion); - MavenExecutionRequest executionRequest = session.getRequest(); + ArtifactRequest request = new ArtifactRequest(); + request.setRepositories(session.getCurrentProject().getRemotePluginRepositories()); + request.setArtifact(artifact); - ArtifactResolutionRequest resolutionRequest = new ArtifactResolutionRequest() - .setArtifact(artifact) - .setLocalRepository(session.getLocalRepository()) - .setRemoteRepositories(session.getCurrentProject().getPluginArtifactRepositories()) - .setOffline(executionRequest.isOffline()) - .setForceUpdate(executionRequest.isUpdateSnapshots()); - - ArtifactResolutionResult resolveResult = repositorySystem.resolve(resolutionRequest); + try { + ArtifactResult artifactResult = repositorySystem.resolveArtifact(session.getRepositorySession(), request); + return artifactResult.getArtifact(); - if (!resolveResult.isSuccess()) { - if (executionRequest.isShowErrors()) { - for (Exception e : resolveResult.getExceptions()) { - getLog().error(e.getMessage(), e); - } - } - throw new MojoExecutionException("artifact: " + artifact + " not resolved."); + } catch (ArtifactResolutionException e) { + throw new MojoExecutionException("artifact: " + artifact + " not resolved.", e); } - - return artifact; } private void unpack(Artifact artifact, Path targetFolder) { @@ -245,7 +252,7 @@ private void unpack(Artifact artifact, Path targetFolder) { * No need to look for other properties, restore them, respecting comments, etc. * * @param wrapperVersion the wrapper version - * @param targetFolder the folder containing the wrapper.properties + * @param targetFolder the folder containing the wrapper.properties * @throws MojoExecutionException if writing fails */ private void replaceProperties(String wrapperVersion, Path targetFolder) throws MojoExecutionException { diff --git a/pom.xml b/pom.xml index 589c5bd1..eabd67b5 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ under the License. wrapper-archives/wrapper-LATEST - 3.1.0 + 3.2.5 8 2022-05-08T09:15:34Z