org.openrewrite.maven.search.ParentPomInsight Maven / Gradle / Ivy
Show all versions of rewrite-maven Show documentation
/*
* 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.search;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.marker.SearchResult;
import org.openrewrite.maven.MavenDownloadingException;
import org.openrewrite.maven.MavenIsoVisitor;
import org.openrewrite.maven.internal.MavenPomDownloader;
import org.openrewrite.maven.table.ParentPomsInUse;
import org.openrewrite.maven.tree.MavenResolutionResult;
import org.openrewrite.maven.tree.Parent;
import org.openrewrite.maven.tree.ResolvedPom;
import org.openrewrite.semver.Semver;
import org.openrewrite.semver.VersionComparator;
import org.openrewrite.xml.tree.Xml;
import static java.util.Collections.emptyList;
import static org.openrewrite.internal.StringUtils.matchesGlob;
@EqualsAndHashCode(callSuper = false)
@Value
public class ParentPomInsight extends Recipe {
transient ParentPomsInUse inUse = new ParentPomsInUse(this);
@Option(displayName = "Group pattern",
description = "Group glob pattern used to match dependencies.",
example = "org.springframework.boot")
String groupIdPattern;
@Option(displayName = "Artifact pattern",
description = "Artifact glob pattern used to match dependencies.",
example = "spring-boot-starter-*")
String artifactIdPattern;
@Option(displayName = "Version",
description = "Match only dependencies with the specified version. " +
"Node-style [version selectors](https://docs.openrewrite.org/reference/dependency-version-selectors) may be used." +
"All versions are searched by default.",
example = "1.x",
required = false)
@Nullable
String version;
@Option(displayName = "Recursive",
description = "Whether to search recursively through the parents. True by default.",
required = false)
@Nullable
Boolean recursive;
@Override
public String getDisplayName() {
return "Maven parent insight";
}
@Override
public String getInstanceNameSuffix() {
return String.format("for `%s:%s`", groupIdPattern, artifactIdPattern);
}
@Override
public String getDescription() {
return "Find Maven parents matching a `groupId` and `artifactId`.";
}
@Override
public Validated