|
1 | 1 | /* |
2 | | - * Copyright 2019-2022 the original author or authors. |
| 2 | + * Copyright 2019-2024 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -31,22 +31,24 @@ public abstract class UpdateProjectVersionTask extends DefaultTask { |
31 | 31 |
|
32 | 32 | static final String VERSION_PROPERTY = "version"; |
33 | 33 |
|
34 | | - static final String SPRING_BOOT_VERSION_PROPERTY = "spring-boot-for-docs"; |
| 34 | + static final String VERSION_FOR_SAMPLES_PROPERTY = "version.samples"; |
| 35 | + |
| 36 | + static final String SPRING_BOOT_VERSION_FOR_DOCS_PROPERTY = "spring-boot-for-docs"; |
35 | 37 |
|
36 | 38 | static final Pattern VERSION_PATTERN = Pattern.compile("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-M\\d+|-RC\\d+|-SNAPSHOT)?$"); |
37 | 39 |
|
38 | | - protected void updateVersionInGradleProperties(String newVersion) { |
39 | | - this.updatePropertyInFile(Project.GRADLE_PROPERTIES, VERSION_PROPERTY, |
40 | | - (p) -> p.getVersion().toString(), |
41 | | - (__) -> newVersion, |
42 | | - (currentValue) -> "%s=%s".formatted(VERSION_PROPERTY, currentValue), |
43 | | - (__) -> "%s=%s".formatted(VERSION_PROPERTY, newVersion)); |
| 40 | + protected void updateVersionInGradleProperties(String versionPropertyName, String newVersion) { |
| 41 | + this.updatePropertyInFile(Project.GRADLE_PROPERTIES, versionPropertyName, |
| 42 | + (p) -> p.property(versionPropertyName).toString(), |
| 43 | + (currentValue) -> newVersion, |
| 44 | + (currentValue) -> "%s=%s".formatted(versionPropertyName, currentValue), |
| 45 | + (newValue) -> "%s=%s".formatted(versionPropertyName, newValue)); |
44 | 46 | } |
45 | 47 |
|
46 | 48 | protected void updateVersionInTomlVersions(String versionPropertyName, |
47 | 49 | Function<String, String> newPropertyValueGivenCurrentValue) { |
48 | 50 | this.updatePropertyInFile("gradle/libs.versions.toml", versionPropertyName, |
49 | | - (p) -> currentVersionForProperty(p, versionPropertyName), |
| 51 | + (p) -> currentVersionInCatalog(p, versionPropertyName), |
50 | 52 | newPropertyValueGivenCurrentValue, |
51 | 53 | (currentValue) -> "%s = \"%s\"".formatted(versionPropertyName, currentValue), |
52 | 54 | (newValue) -> "%s = \"%s\"".formatted(versionPropertyName, newValue)); |
@@ -85,7 +87,7 @@ protected VersionInfo parseVersion(String version) { |
85 | 87 | } |
86 | 88 | } |
87 | 89 |
|
88 | | - protected String currentVersionForProperty(Project project, String versionProperty) { |
| 90 | + protected String currentVersionInCatalog(Project project, String versionProperty) { |
89 | 91 | VersionCatalogsExtension catalog = project.getExtensions().getByType(VersionCatalogsExtension.class); |
90 | 92 | return catalog.named("libs").findVersion(versionProperty) |
91 | 93 | .orElseThrow(() -> new IllegalStateException("% property not found".formatted(versionProperty))) |
|
0 commit comments