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.gradle.plugins;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.gradle.DependencyVersionSelector;
import org.openrewrite.gradle.IsBuildGradle;
import org.openrewrite.gradle.IsSettingsGradle;
import org.openrewrite.gradle.marker.GradlePluginDescriptor;
import org.openrewrite.gradle.marker.GradleProject;
import org.openrewrite.gradle.marker.GradleSettings;
import org.openrewrite.gradle.util.ChangeStringLiteral;
import org.openrewrite.groovy.GroovyIsoVisitor;
import org.openrewrite.groovy.tree.G;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.java.MethodMatcher;
import org.openrewrite.java.tree.Expression;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.maven.MavenDownloadingException;
import org.openrewrite.maven.tree.GroupArtifact;
import org.openrewrite.semver.Semver;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* When changing a plugin id that uses the `apply` syntax or versionless plugins syntax, the version is will not be changed.
* At the time of this writing, we do not have a relationship between the plugin id and the jar that contains it that is
* required in order to update the version for the apply syntax. For the versionless plugins syntax, the version for a
* third party plugin must be defined in another file that is presently outside the scope of change for this recipe.
* If you are using either of these plugin styles, you should ensure that the plugin's version is appropriately updated.
*/
@Value
@EqualsAndHashCode(callSuper = false)
public class ChangePlugin extends Recipe {
@Option(displayName = "Plugin ID",
description = "The current Gradle plugin id.",
example = "org.openrewrite.rewrite")
String pluginId;
@Option(displayName = "New plugin ID",
description = "The new Gradle plugin id.",
example = "org.openrewrite.rewrite")
String newPluginId;
@Option(displayName = "New plugin version",
description = "An exact version number or node-style semver selector used to select the version number. " +
"You can also use `latest.release` for the latest available version and `latest.patch` if " +
"the current version is a valid semantic version. For more details, you can look at the documentation " +
"page of [version selectors](https://docs.openrewrite.org/reference/dependency-version-selectors).",
example = "7.x",
required = false)
@Nullable
String newVersion;
@Override
public String getDisplayName() {
return "Change a Gradle plugin";
}
@Override
public String getInstanceNameSuffix() {
return String.format("`%s` to `%s`", pluginId, newPluginId);
}
@Override
public String getDescription() {
return "Changes the selected Gradle plugin to the new plugin.";
}
@Override
public Validated