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 2021 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.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.maven.internal.MavenPomDownloader;
import org.openrewrite.maven.table.MavenMetadataFailures;
import org.openrewrite.maven.tree.*;
import org.openrewrite.semver.Semver;
import org.openrewrite.semver.VersionComparator;
import org.openrewrite.xml.AddToTagVisitor;
import org.openrewrite.xml.ChangeTagValueVisitor;
import org.openrewrite.xml.TagNameComparator;
import org.openrewrite.xml.tree.Xml;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.Collections.emptyList;
import static org.openrewrite.internal.StringUtils.matchesGlob;
@Value
@EqualsAndHashCode(callSuper = false)
public class ChangeParentPom extends Recipe {
transient MavenMetadataFailures metadataFailures = new MavenMetadataFailures(this);
@Option(displayName = "Old group ID",
description = "The group ID of the Maven parent pom to be changed away from.",
example = "org.springframework.boot")
String oldGroupId;
@Option(displayName = "New group ID",
description = "The group ID of the new maven parent pom to be adopted. If this argument is omitted it defaults to the value of `oldGroupId`.",
example = "org.springframework.boot",
required = false)
@Nullable
String newGroupId;
@Option(displayName = "Old artifact ID",
description = "The artifact ID of the maven parent pom to be changed away from.",
example = "spring-boot-starter-parent")
String oldArtifactId;
@Option(displayName = "New artifact ID",
description = "The artifact ID of the new maven parent pom to be adopted. If this argument is omitted it defaults to the value of `oldArtifactId`.",
example = "spring-boot-starter-parent",
required = false)
@Nullable
String newArtifactId;
@Option(displayName = "New version",
description = "An exact version number or node-style semver selector used to select the version number.",
example = "29.X")
String newVersion;
@Option(displayName = "Old relative path",
description = "The relativePath of the maven parent pom to be changed away from.",
example = "../../pom.xml",
required = false)
@Nullable
String oldRelativePath;
@Option(displayName = "New relative path",
description = "New relative path attribute for parent lookup.",
example = "../pom.xml",
required = false)
@Nullable
String newRelativePath;
@Option(displayName = "Version pattern",
description = "Allows version selection to be extended beyond the original Node Semver semantics. So for example," +
"Setting 'version' to \"25-29\" can be paired with a metadata pattern of \"-jre\" to select Guava 29.0-jre",
example = "-jre",
required = false)
@Nullable
String versionPattern;
@Option(displayName = "Allow version downgrades",
description = "If the new parent has the same group/artifact, this flag can be used to only upgrade the " +
"version if the target version is newer than the current.",
required = false)
@Nullable
Boolean allowVersionDowngrades;
@Override
public String getDisplayName() {
return "Change Maven parent";
}
@Override
public String getInstanceNameSuffix() {
return String.format("`%s:%s:%s`", newGroupId, newArtifactId, newVersion);
}
@Override
public String getDescription() {
return "Change the parent pom of a Maven pom.xml. Identifies the parent pom to be changed by its groupId and artifactId.";
}
@Override
public Validated