Skip to content

Commit 0aaced9

Browse files
committed
Add instance name suffix method to UpdateGradleWrapper
1 parent 5e680f8 commit 0aaced9

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

rewrite-gradle/src/main/java/org/openrewrite/gradle/UpdateGradleWrapper.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ public class UpdateGradleWrapper extends ScanningRecipe<UpdateGradleWrapper.Grad
104104
@Option(example = "29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda",
105105
displayName = "SHA-256 checksum",
106106
description = "The SHA-256 checksum of the Gradle distribution. " +
107-
"If specified, the recipe will add the checksum along with the custom distribution URL.",
107+
"If specified, the recipe will add the checksum along with the custom distribution URL.",
108108
required = false)
109109
@Nullable
110110
final String distributionChecksum;
111111

112+
@Override
113+
public String getInstanceNameSuffix() {
114+
return version == null ? "" : version + '-' + (distribution == null ? "bin" : distribution);
115+
}
116+
112117
@Override
113118
public Validated<Object> validate() {
114119
Validated<Object> validated = super.validate();
@@ -231,7 +236,7 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
231236
}
232237

233238
if ((sourceFile instanceof Quark || sourceFile instanceof Remote) &&
234-
equalIgnoringSeparators(sourceFile.getSourcePath(), WRAPPER_JAR_LOCATION)) {
239+
equalIgnoringSeparators(sourceFile.getSourcePath(), WRAPPER_JAR_LOCATION)) {
235240
acc.addGradleWrapperJar = false;
236241
return true;
237242
}
@@ -286,11 +291,11 @@ public Collection<SourceFile> generate(GradleWrapperState acc, ExecutionContext
286291
//noinspection UnusedProperty
287292
Properties.File gradleWrapperProperties = new PropertiesParser().parse(
288293
"distributionBase=GRADLE_USER_HOME\n" +
289-
"distributionPath=wrapper/dists\n" +
290-
"distributionUrl=" + gradleWrapper.getPropertiesFormattedUrl() + "\n" +
291-
(checksum == null ? "" : "distributionSha256Sum=" + checksum + "\n") +
292-
"zipStoreBase=GRADLE_USER_HOME\n" +
293-
"zipStorePath=wrapper/dists")
294+
"distributionPath=wrapper/dists\n" +
295+
"distributionUrl=" + gradleWrapper.getPropertiesFormattedUrl() + "\n" +
296+
(checksum == null ? "" : "distributionSha256Sum=" + checksum + "\n") +
297+
"zipStoreBase=GRADLE_USER_HOME\n" +
298+
"zipStorePath=wrapper/dists")
294299
.findFirst()
295300
.orElseThrow(() -> new IllegalArgumentException("Could not parse as properties"))
296301
.withSourcePath(WRAPPER_PROPERTIES_LOCATION);

0 commit comments

Comments
 (0)