Skip to content

Commit fcf088b

Browse files
solonovamaxbgalek
andauthored
Expose cached DecoratedVersion, and introduce isSnapshot() to DecoratedVersion (#749)
Introduces a method, getDecoratedVersion() in the VersionConfig class, allowing you to easily retrieve the cached decorated version, instead of having to do versionProvider().get(), which looks less nice (imo) Also introduces a method, isSnapshot() to DecoratedVersion, which allows you to check if the decorated version is a snapshot. This is passed the value of VersionContact.isSnapshot(). This is convenient for checking if a version is a snapshot or not when building the project. Co-authored-by: Bartosz Gałek <bartosz.galek@allegro.com>
1 parent 489aa88 commit fcf088b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ abstract class VersionConfig extends BaseExtension {
244244
return uncachedVersionProvider().get()
245245
}
246246

247+
@Nested
248+
VersionService.DecoratedVersion getDecoratedVersion() {
249+
return versionProvider().get()
250+
}
251+
247252
@Input
248253
String getVersion() {
249254
return versionProvider().map({ it.decoratedVersion }).get()

src/main/java/pl/allegro/tech/build/axion/release/domain/VersionService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,23 @@ public DecoratedVersion currentDecoratedVersion(VersionProperties versionPropert
3737
}
3838

3939
return new DecoratedVersion(versionContext.getVersion().toString(), finalVersion, versionContext.getPosition(),
40-
versionContext.getPreviousVersion().toString());
40+
versionContext.getPreviousVersion().toString(), versionContext.isSnapshot());
4141
}
4242

4343
public static class DecoratedVersion {
4444
private final String undecoratedVersion;
4545
private final String decoratedVersion;
4646
private final ScmPosition position;
4747
private final String previousVersion;
48+
private final boolean snapshot;
4849

4950
public DecoratedVersion(String undecoratedVersion, String decoratedVersion, ScmPosition position,
50-
String previousVersion) {
51+
String previousVersion, boolean snapshot) {
5152
this.undecoratedVersion = undecoratedVersion;
5253
this.decoratedVersion = decoratedVersion;
5354
this.position = position;
5455
this.previousVersion = previousVersion;
56+
this.snapshot = snapshot;
5557
}
5658

5759
@Input
@@ -73,5 +75,10 @@ public final ScmPosition getPosition() {
7375
public final String getPreviousVersion() {
7476
return previousVersion;
7577
}
78+
79+
@Input
80+
public boolean isSnapshot() {
81+
return snapshot;
82+
}
7683
}
7784
}

0 commit comments

Comments
 (0)