Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.maven;
import lombok.*;
import lombok.experimental.FieldDefaults;
import lombok.experimental.NonFinal;
import org.intellij.lang.annotations.Language;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.marker.BuildTool;
import org.openrewrite.marker.Markers;
import org.openrewrite.maven.utilities.MavenWrapper;
import org.openrewrite.properties.PropertiesIsoVisitor;
import org.openrewrite.properties.PropertiesParser;
import org.openrewrite.properties.PropertiesVisitor;
import org.openrewrite.properties.search.FindProperties;
import org.openrewrite.properties.tree.Properties;
import org.openrewrite.quark.Quark;
import org.openrewrite.remote.Remote;
import org.openrewrite.semver.Semver;
import org.openrewrite.semver.VersionComparator;
import org.openrewrite.text.PlainText;
import java.time.ZonedDateTime;
import java.util.*;
import static java.util.Objects.requireNonNull;
import static org.openrewrite.PathUtils.equalIgnoringSeparators;
import static org.openrewrite.internal.StringUtils.isBlank;
import static org.openrewrite.maven.utilities.MavenWrapper.*;
/**
* This recipe expects for the specified repository to be a Maven layout with `maven-metadata.xml` files containing all
* the following REQUIRED publications:
*
* org.apache.maven.wrapper:maven-wrapper:{wrapperVersion}
* org.apache.maven.wrapper:maven-wrapper-distribution:{wrapperVersion}
* org.apache.maven:apache-maven:{distributionVersion}
*/
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false)
public class UpdateMavenWrapper extends ScanningRecipe {
private static final String DISTRIBUTION_URL_KEY = "distributionUrl";
private static final String DISTRIBUTION_SHA_256_SUM_KEY = "distributionSha256Sum";
private static final String WRAPPER_URL_KEY = "wrapperUrl";
private static final String WRAPPER_SHA_256_SUM_KEY = "wrapperSha256Sum";
@Getter
@Option(displayName = "New wrapper version",
description = "An exact version number or node-style semver selector used to select the wrapper version number.",
example = "3.x",
required = false)
@Nullable
final String wrapperVersion;
@Getter
@Option(displayName = "Wrapper Distribution type",
description = "The distribution of the Maven wrapper to use.\n\n" +
"* \"bin\" uses a `maven-wrapper.jar` compiled binary.\n" +
"* \"only-script\" uses a lite version of `mvnw`/`mvnw.cmd` using wget/curl or powershell. (required wrapper 3.2.0 or newer)\n" +
"* \"script\" downloads `maven-wrapper.jar` or `MavenWrapperDownloader.java` to then download a full distribution.\n" +
"* \"source\" uses `MavenWrapperDownloader.java` source file.\n\n" +
"Defaults to \"bin\".",
valid = {"bin", "only-script", "script", "source"},
required = false)
@Nullable
final String wrapperDistribution;
@Getter
@Option(displayName = "New distribution version",
description = "An exact version number or node-style semver selector used to select the Maven version number.",
example = "3.x",
required = false)
@Nullable
final String distributionVersion;
@Getter
@Option(displayName = "Repository URL",
description = "The URL of the repository to download the Maven wrapper and distribution from. Supports repositories " +
"with a Maven layout. Defaults to `https://repo.maven.apache.org/maven2`.",
example = "https://repo.maven.apache.org/maven2",
required = false)
@Nullable
final String repositoryUrl;
@Getter
@Option(displayName = "Add if missing",
description = "Add a Maven wrapper, if it's missing. Defaults to `true`.",
required = false)
@Nullable
final Boolean addIfMissing;
@Getter
@Option(displayName = "Enforce checksum verification for maven-wrapper.jar",
description = "Enforce checksum verification for the maven-wrapper.jar. Enabling this feature may sporadically " +
"result in build failures, such as [MWRAPPER-103](https://issues.apache.org/jira/browse/MWRAPPER-103). Defaults to `false`.",
required = false)
@Nullable
final Boolean enforceWrapperChecksumVerification;
@Override
public String getDisplayName() {
return "Update Maven wrapper";
}
@Override
public String getDescription() {
return "Update the version of Maven used in an existing Maven wrapper.";
}
@Override
public Validated