Skip to content

Commit f72aaaf

Browse files
committed
Add javadocs for regex patterns
1 parent eef5f1a commit f72aaaf

File tree

2 files changed

+49
-14
lines changed

2 files changed

+49
-14
lines changed

tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/updaters/FetchExistingLibrariesWithNewerVersionsTask.groovy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ abstract class FetchExistingLibrariesWithNewerVersionsTask extends DefaultTask {
2525
abstract ListProperty<String> getAllLibraryCoordinates()
2626

2727
private static final List<String> INFRASTRUCTURE_TESTS = List.of("samples", "org.example")
28+
29+
/**
30+
* Identifies pre-release library versions by pattern matching against common pre-release suffixes.
31+
* <p>
32+
* A version is considered pre-release if its suffix (following the last '.' or '-') matches
33+
* one of these case-insensitive patterns:
34+
* <ul>
35+
* <li>{@code alpha} followed by optional numbers (e.g., "alpha", "Alpha1", "alpha123")</li>
36+
* <li>{@code beta} followed by optional numbers (e.g., "beta", "Beta2", "BETA45")</li>
37+
* <li>{@code rc} followed by optional numbers (e.g., "rc", "RC1", "rc99")</li>
38+
* <li>{@code cr} followed by optional numbers (e.g., "cr", "CR3", "cr10")</li>
39+
* <li>{@code m} followed by REQUIRED numbers (e.g., "M1", "m23")</li>
40+
* <li>{@code ea} followed by optional numbers (e.g., "ea", "ea2", "ea15")</li>
41+
* <li>{@code b} followed by REQUIRED numbers (e.g., "b0244", "b5")</li>
42+
* <li>{@code preview} followed by optional numbers (e.g., "preview", "preview1", "preview42")</li>
43+
* <li>Numeric suffixes separated by '-' (e.g., "-1", "-123")</li>
44+
* </ul>
45+
*/
2846
private static final Pattern PRE_RELEASE_PATTERN = ~/(?i)^(\d+(?:\.\d+)*)(?:[-.](alpha\d*|beta\d*|rc\d*|cr\d*|m\d+|ea\d*|b\d+|\d+|preview)(?:[-.].*)?)?$/
2947
private static final String FINAL_PATTERN = /(?i)\.Final$/
3048

tests/tck-build-logic/src/main/java/org/graalvm/internal/tck/TestedVersionUpdaterTask.java

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@
3030
import java.util.regex.Pattern;
3131

3232
public abstract class TestedVersionUpdaterTask extends DefaultTask {
33+
/**
34+
* Identifies pre-release library versions by pattern matching against common pre-release suffixes.
35+
* <p>
36+
* A version is considered pre-release if its suffix (following the last '.' or '-') matches
37+
* one of these case-insensitive patterns:
38+
* <ul>
39+
* <li>{@code alpha} followed by optional numbers (e.g., "alpha", "Alpha1", "alpha123")</li>
40+
* <li>{@code beta} followed by optional numbers (e.g., "beta", "Beta2", "BETA45")</li>
41+
* <li>{@code rc} followed by optional numbers (e.g., "rc", "RC1", "rc99")</li>
42+
* <li>{@code cr} followed by optional numbers (e.g., "cr", "CR3", "cr10")</li>
43+
* <li>{@code m} followed by REQUIRED numbers (e.g., "M1", "m23")</li>
44+
* <li>{@code ea} followed by optional numbers (e.g., "ea", "ea2", "ea15")</li>
45+
* <li>{@code b} followed by REQUIRED numbers (e.g., "b0244", "b5")</li>
46+
* <li>{@code preview} followed by optional numbers (e.g., "preview", "preview1", "preview42")</li>
47+
* <li>Numeric suffixes separated by '-' (e.g., "-1", "-123")</li>
48+
* </ul>
49+
*/
3350
private static final Pattern PRE_RELEASE_PATTERN = Pattern.compile(
3451
"(?i)^(\\d+(?:\\.\\d+)*)(?:[-.](alpha\\d*|beta\\d*|rc\\d*|cr\\d*|m\\d+|ea\\d*|b\\d+|\\d+|preview)(?:[-.].*)?)?$"
3552
);
@@ -94,13 +111,13 @@ void run() throws IllegalStateException, IOException {
94111
* <p>
95112
* Rules applied by this method:
96113
* <ul>
97-
* <li>If the newly added version is a full release (no pre-release label, or ending with ".Final"),
98-
* all existing pre-releases of the same base version are removed from {@code testedVersions}.</li>
99-
* <li>If the newly added version is itself a pre-release, no versions are removed.</li>
100-
* <li>If the entry's {@code metadataVersion} is a pre-release of the same base version,
101-
* it is updated to the new full release. The corresponding metadata and test directories are renamed accordingly.
102-
* The {@code gradle.properties} file in the tests directory is updated to refer to the new version.</li>
103-
* <li>Version parsing follows {@link #PRE_RELEASE_PATTERN} and treats ".Final" as a base version.</li>
114+
* <li>If the newly added version is a full release (no pre-release label, or ending with ".Final"),
115+
* all existing pre-releases of the same base version are removed from {@code testedVersions}.</li>
116+
* <li>If the newly added version is itself a pre-release, no versions are removed.</li>
117+
* <li>If the entry's {@code metadataVersion} is a pre-release of the same base version,
118+
* it is updated to the new full release. The corresponding metadata and test directories are renamed accordingly.
119+
* The {@code gradle.properties} file in the tests directory is updated to refer to the new version.</li>
120+
* <li>Version parsing follows {@link #PRE_RELEASE_PATTERN} and treats ".Final" as a base version.</li>
104121
* </ul>
105122
*/
106123
private MetadataVersionsIndexEntry handlePreReleases(MetadataVersionsIndexEntry entry, String newVersion, Path baseDir) throws IOException {
@@ -158,13 +175,13 @@ private MetadataVersionsIndexEntry handlePreReleases(MetadataVersionsIndexEntry
158175
* <p>
159176
* This method performs two operations:
160177
* <ol>
161-
* <li>Renames the test directory from {@code oldVersion} to {@code newVersion} under {@code tests/src/<group>/<artifact>/}.</li>
162-
* <li>Updates the {@code gradle.properties} file inside the renamed directory:
163-
* <ul>
164-
* <li>{@code library.version} is set to the new version,</li>
165-
* <li>{@code metadata.dir} is updated to point to the metadata directory for the new version.</li>
166-
* </ul>
167-
* </li>
178+
* <li>Renames the test directory from {@code oldVersion} to {@code newVersion} under {@code tests/src/<group>/<artifact>/}.</li>
179+
* <li>Updates the {@code gradle.properties} file inside the renamed directory:
180+
* <ul>
181+
* <li>{@code library.version} is set to the new version,</li>
182+
* <li>{@code metadata.dir} is updated to point to the metadata directory for the new version.</li>
183+
* </ul>
184+
* </li>
168185
* </ol>
169186
*/
170187
private void updateTests(Path metadataBaseDir, MetadataVersionsIndexEntry entry, String oldVersion, String newVersion) throws IOException {

0 commit comments

Comments
 (0)