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 2022 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;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.experimental.NonFinal;
import org.openrewrite.*;
import org.openrewrite.gradle.util.GradleWrapper;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.BuildTool;
import org.openrewrite.marker.Markers;
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.gradle.util.GradleWrapper.*;
import static org.openrewrite.internal.StringUtils.formatUriForPropertiesFile;
import static org.openrewrite.internal.StringUtils.isBlank;
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false)
public class UpdateGradleWrapper extends ScanningRecipe {
@Override
public String getDisplayName() {
return "Update Gradle wrapper";
}
@Override
public String getDescription() {
return "Update the version of Gradle used in an existing Gradle wrapper. " +
"Queries services.gradle.org to determine the available releases, but prefers the artifact repository URL " +
"which already exists within the wrapper properties file. " +
"If your artifact repository does not contain the same Gradle distributions as services.gradle.org, " +
"then the recipe may suggest a version which is not available in your artifact repository.";
}
@Getter
@Option(displayName = "New version",
description = "An exact version number or node-style semver selector used to select the version number. " +
"Defaults to the latest release available from services.gradle.org if not specified.",
example = "7.x",
required = false)
@Nullable
final String version;
@Getter
@Option(displayName = "Distribution type",
description = "The distribution of Gradle to use. \"bin\" includes Gradle binaries. " +
"\"all\" includes Gradle binaries, source code, and documentation. " +
"Defaults to \"bin\".",
valid = {"bin", "all"},
required = false
)
@Nullable
final String distribution;
@Getter
@Option(displayName = "Add if missing",
description = "Add a Gradle wrapper, if it's missing. Defaults to `true`.",
required = false)
@Nullable
final Boolean addIfMissing;
@Getter
@Option(example = "https://services.gradle.org/distributions/gradle-${version}-${distribution}.zip", displayName = "Wrapper URI",
description = "The URI of the Gradle wrapper distribution. " +
"Lookup of available versions still requires access to https://services.gradle.org " +
"When this is specified the exact literal values supplied for `version` and `distribution` " +
"will be interpolated into this string wherever `${version}` and `${distribution}` appear respectively. " +
"Defaults to https://services.gradle.org/distributions/gradle-${version}-${distribution}.zip.",
required = false)
@Nullable
final String wrapperUri;
@Override
public Validated