diff --git a/docs/configuration/version.md b/docs/configuration/version.md index 495484e7..6b19b461 100644 --- a/docs/configuration/version.md +++ b/docs/configuration/version.md @@ -111,6 +111,41 @@ You can also active this option using command line: # ./gradlew currentVersion -Prelease.useHighestVersion 1.5.0 +### Search tags globally +Search all tags, in all branches to find the next release number. Use this if you want incrementing numbers across branches. + +In order to activate this feature: + + scmVersion { + useGlobalVersion = true + } + +Take this tree as an example: + +``` + [T1] + | + |     | +[T2] [T3] + |     | +[C] [_] +``` + +Let `T*` be a tagged commit and `C` the current commit. After releasing +version with tag `T1`, we have been working on two separate branches. +Then, branch on the right has been released and marked with `T3` tag, and the branch on the left has been released with `T2` tag. +When traversing *all* tags in this tree, `T3` will be reported as the highest tag, and so reported version will come from parsing `T3` tag, even though tag `T2` is the highest number on the *current* branch. + +If you had been using `useHighestVersion`, the reported version would have come from `T2` + +When using `useGlobalVersion`, the reported version will come from `T3` + +You can also activate this feature in command line form + +``` +# ./gradlew currentVersion -Prelease.useGlobalVersion +``` + ## Parsing Having current tag name, we can deserialize it to extract raw version. diff --git a/src/integration/groovy/pl/allegro/tech/build/axion/release/GlobalVersionIntegrationTest.groovy b/src/integration/groovy/pl/allegro/tech/build/axion/release/GlobalVersionIntegrationTest.groovy new file mode 100644 index 00000000..16c2bfe1 --- /dev/null +++ b/src/integration/groovy/pl/allegro/tech/build/axion/release/GlobalVersionIntegrationTest.groovy @@ -0,0 +1,52 @@ +package pl.allegro.tech.build.axion.release + +import org.gradle.testkit.runner.TaskOutcome + +class GlobalVersionIntegrationTest extends BaseIntegrationTest { + def "should return tag with highest version if useGlobalVersion is set to true"() { + given: + buildFile('') + + runGradle('release', '-Prelease.version=1.0.0', '-Prelease.localOnly', '-Prelease.disableChecks') + runGradle('release', '-Prelease.version=1.5.0', '-Prelease.localOnly', '-Prelease.disableChecks') + + repository.commit(['*'], "commit after release-1.5.0") + + runGradle('release', '-Prelease.version=1.2.0', '-Prelease.localOnly', '-Prelease.disableChecks') + + when: + def result = runGradle('currentVersion', '-Prelease.useGlobalVersion') + + then: + result.output.contains('1.5.1-SNAPSHOT') + result.task(":currentVersion").outcome == TaskOutcome.SUCCESS + } + + def "should resolve higher global version when on branch with higher version"() { + given: + buildFile('') + Fixtures.FixtureUseGlobalVersion.setupABranchWithHighTagAndBBranchWithLowTag(repository) + repository.checkout('high') + + when: + def result = runGradle('currentVersion', '-Prelease.useGlobalVersion') + + then: + result.output.contains('2.0.0') + result.task(":currentVersion").outcome == TaskOutcome.SUCCESS + } + + def "should resolve higher global version when on branch with lower version"() { + given: 'I am on a branch with a low release tag' + buildFile('') + Fixtures.FixtureUseGlobalVersion.setupABranchWithHighTagAndBBranchWithLowTag(repository) + repository.checkout('low') + + when: + def result = runGradle('currentVersion', '-Prelease.useGlobalVersion') + + then: + result.output.contains('2.0.1') + result.task(":currentVersion").outcome == TaskOutcome.SUCCESS + } +} diff --git a/src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy b/src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy index 3b330eef..3f39714b 100644 --- a/src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy +++ b/src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy @@ -32,6 +32,9 @@ class VersionConfig { @Input boolean useHighestVersion = false + @Input + boolean useGlobalVersion = false + @Nested RepositoryConfig repository diff --git a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DryRepository.groovy b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DryRepository.groovy index 83d009a0..6b852dd6 100644 --- a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DryRepository.groovy +++ b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DryRepository.groovy @@ -42,6 +42,16 @@ class DryRepository implements ScmRepository { return new ScmPushResult(true, Optional.empty()) } + @Override + void branch(String name) { + log("creating branch: ${name}") + } + + @Override + void checkout(String name) { + log("switching to branch: ${name}") + } + @Override void commit(List patterns, String message) { log("commiting files matching $patterns with message: $message") @@ -81,6 +91,11 @@ class DryRepository implements ScmRepository { return delegateRepository.taggedCommits(pattern) } + @Override + List taggedCommitsGlobally(Pattern pattern) { + return delegateRepository.taggedCommitsGlobally(pattern) + } + @Override boolean remoteAttached(String remoteName) { return true diff --git a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DummyRepository.groovy b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DummyRepository.groovy index 6f552f3e..ea7fb23c 100644 --- a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DummyRepository.groovy +++ b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/DummyRepository.groovy @@ -42,6 +42,16 @@ class DummyRepository implements ScmRepository { return new ScmPushResult(true, Optional.empty()) } + @Override + void branch(String name) { + log("creating branch: ${name}") + } + + @Override + void checkout(String name) { + log("switching to branch: ${name}") + } + @Override void commit(List patterns, String message) { log('commit') @@ -80,6 +90,11 @@ class DummyRepository implements ScmRepository { return [new TagsOnCommit(null, [])] } + @Override + List taggedCommitsGlobally(Pattern pattern) { + logger.quiet("Could not resolve current position on uninitialized repository, returning default") + return [new TagsOnCommit(null, [])] + } @Override boolean remoteAttached(String remoteName) { diff --git a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/config/VersionPropertiesFactory.groovy b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/config/VersionPropertiesFactory.groovy index cf00ff02..9618769c 100644 --- a/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/config/VersionPropertiesFactory.groovy +++ b/src/main/groovy/pl/allegro/tech/build/axion/release/infrastructure/config/VersionPropertiesFactory.groovy @@ -20,6 +20,8 @@ class VersionPropertiesFactory { private static final String USE_HIGHEST_VERSION_PROPERTY = 'release.useHighestVersion' + private static final String USE_GLOBAL_VERSION_PROPERTY = 'release.useGlobalVersion' + private static final String VERSION_INCREMENTER_PROPERTY = 'release.versionIncrementer' private static final String VERSION_CREATOR_PROPERTY = 'release.versionCreator' @@ -35,6 +37,8 @@ class VersionPropertiesFactory { boolean useHighestVersion = project.hasProperty(USE_HIGHEST_VERSION_PROPERTY) ?: config.useHighestVersion + boolean useGlobalVersion = project.hasProperty(USE_GLOBAL_VERSION_PROPERTY) ?: config.useGlobalVersion + return new VersionProperties( forceVersionValue?.trim() ? forceVersionValue.trim() : null, forceSnapshot, @@ -43,6 +47,7 @@ class VersionPropertiesFactory { findVersionIncrementer(project, config, currentBranch), config.sanitizeVersion, useHighestVersion, + useGlobalVersion, MonorepoPropertiesFactory.create(project, config.monorepoConfig, currentBranch) ) } diff --git a/src/main/java/pl/allegro/tech/build/axion/release/domain/VersionResolver.java b/src/main/java/pl/allegro/tech/build/axion/release/domain/VersionResolver.java index 251359d2..d04ec79d 100644 --- a/src/main/java/pl/allegro/tech/build/axion/release/domain/VersionResolver.java +++ b/src/main/java/pl/allegro/tech/build/axion/release/domain/VersionResolver.java @@ -20,6 +20,10 @@ * * version read from last release tag when on tag */ public class VersionResolver { + private enum VersionReadingStrategy { + HIGHEST_VERSION, + GLOBAL_VERSION + } private final ScmRepository repository; private final VersionSorter sorter; @@ -44,10 +48,12 @@ public VersionContext resolveVersion(VersionProperties versionProperties, TagPro VersionFactory versionFactory = new VersionFactory(versionProperties, tagProperties, nextVersionProperties, latestChangePosition, repository.isLegacyDefTagnameRepo()); VersionInfo versions; - if (versionProperties.isUseHighestVersion()) { - versions = readVersionsByHighestVersion(versionFactory, tagProperties, nextVersionProperties, versionProperties, latestChangePosition); + if (versionProperties.isUseGlobalVersion()) { + versions = readVersionsByGlobalOrHighestVersion(versionFactory, tagProperties, nextVersionProperties, versionProperties, latestChangePosition, VersionReadingStrategy.GLOBAL_VERSION); + } else if (versionProperties.isUseHighestVersion()) { + versions = readVersionsByGlobalOrHighestVersion(versionFactory, tagProperties, nextVersionProperties, versionProperties, latestChangePosition, VersionReadingStrategy.HIGHEST_VERSION); } else { - versions = readVersions(versionFactory, tagProperties, nextVersionProperties, versionProperties, latestChangePosition); + versions = readVersionsByFirstVersion(versionFactory, tagProperties, nextVersionProperties, versionProperties, latestChangePosition); } @@ -63,7 +69,7 @@ public VersionContext resolveVersion(VersionProperties versionProperties, TagPro return new VersionContext(finalVersion.version, finalVersion.snapshot, versions.previous, latestChangePosition); } - private VersionInfo readVersions( + private VersionInfo readVersionsByFirstVersion( VersionFactory versionFactory, TagProperties tagProperties, NextVersionProperties nextVersionProperties, @@ -106,19 +112,24 @@ private VersionInfo readVersions( ); } - private VersionInfo readVersionsByHighestVersion( + private VersionInfo readVersionsByGlobalOrHighestVersion( VersionFactory versionFactory, final TagProperties tagProperties, final NextVersionProperties nextVersionProperties, VersionProperties versionProperties, - ScmPosition latestChangePosition + ScmPosition latestChangePosition, + VersionReadingStrategy versionReadingStrategy ) { - Pattern releaseTagPattern = Pattern.compile("^" + tagProperties.getPrefix() + ".*"); Pattern nextVersionTagPattern = Pattern.compile(".*" + nextVersionProperties.getSuffix() + "$"); boolean forceSnapshot = versionProperties.isForceSnapshot(); - TaggedCommits allTaggedCommits = TaggedCommits.fromAllCommits(repository, releaseTagPattern, latestChangePosition); + TaggedCommits allTaggedCommits; + if (versionReadingStrategy == VersionReadingStrategy.HIGHEST_VERSION) { + allTaggedCommits = TaggedCommits.fromAllCommits(repository, releaseTagPattern, latestChangePosition); + } else { + allTaggedCommits = TaggedCommits.fromAllCommitsGlobally(repository, releaseTagPattern, latestChangePosition); + } VersionSorter.Result currentVersionInfo = versionFromTaggedCommits(allTaggedCommits, false, nextVersionTagPattern, versionFactory, forceSnapshot); VersionSorter.Result previousVersionInfo = versionFromTaggedCommits(allTaggedCommits, true, nextVersionTagPattern, versionFactory, forceSnapshot); diff --git a/src/main/java/pl/allegro/tech/build/axion/release/domain/properties/VersionProperties.java b/src/main/java/pl/allegro/tech/build/axion/release/domain/properties/VersionProperties.java index b5a0fb34..271f8d63 100644 --- a/src/main/java/pl/allegro/tech/build/axion/release/domain/properties/VersionProperties.java +++ b/src/main/java/pl/allegro/tech/build/axion/release/domain/properties/VersionProperties.java @@ -12,6 +12,7 @@ public class VersionProperties { private final Closure versionIncrementer; private final boolean sanitizeVersion; private final boolean useHighestVersion; + private final boolean useGlobalVersion; private final MonorepoProperties monorepoProperties; public VersionProperties( @@ -22,6 +23,7 @@ public VersionProperties( Closure versionIncrementer, boolean sanitizeVersion, boolean useHighestVersion, + boolean useGlobalVersion, MonorepoProperties monorepoProperties ) { this.forcedVersion = forcedVersion; @@ -31,6 +33,7 @@ public VersionProperties( this.versionIncrementer = versionIncrementer; this.sanitizeVersion = sanitizeVersion; this.useHighestVersion = useHighestVersion; + this.useGlobalVersion = useGlobalVersion; this.monorepoProperties = monorepoProperties; } @@ -66,6 +69,8 @@ public final boolean isUseHighestVersion() { return useHighestVersion; } + public final boolean isUseGlobalVersion() { return useGlobalVersion; } + public MonorepoProperties getMonorepoProperties() { return monorepoProperties; } diff --git a/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/ScmRepository.java b/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/ScmRepository.java index 6de930d2..d3f033cb 100644 --- a/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/ScmRepository.java +++ b/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/ScmRepository.java @@ -13,6 +13,10 @@ public interface ScmRepository { ScmPushResult push(ScmIdentity identity, ScmPushOptions pushOptions); + void branch(String name); + + void checkout(String name); + void commit(List patterns, String message); void attachRemote(String remoteName, String url); @@ -27,6 +31,8 @@ public interface ScmRepository { List taggedCommits(Pattern pattern); + List taggedCommitsGlobally(Pattern pattern); + boolean remoteAttached(String remoteName); boolean checkUncommittedChanges(); diff --git a/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/TaggedCommits.java b/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/TaggedCommits.java index 2c1a29f0..fae51346 100644 --- a/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/TaggedCommits.java +++ b/src/main/java/pl/allegro/tech/build/axion/release/domain/scm/TaggedCommits.java @@ -28,6 +28,11 @@ public static TaggedCommits fromAllCommits(ScmRepository repository, Pattern tag return new TaggedCommits(latestTagPosition, taggedCommits); } + public static TaggedCommits fromAllCommitsGlobally(ScmRepository repository, Pattern tagPattern, ScmPosition latestTagPosition) { + List taggedCommits = repository.taggedCommitsGlobally(tagPattern); + return new TaggedCommits(latestTagPosition, taggedCommits); + } + public static TaggedCommits fromLatestCommitBeforeNextVersion(ScmRepository repository, Pattern releaseTagPattern, Pattern nextVersionTagPattern, ScmPosition latestTagPosition) { TagsOnCommit previousTags = repository.latestTags(releaseTagPattern); while (previousTags.hasOnlyMatching(nextVersionTagPattern)) { diff --git a/src/main/java/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepository.java b/src/main/java/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepository.java index 478ce75d..7db141e5 100644 --- a/src/main/java/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepository.java +++ b/src/main/java/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepository.java @@ -201,6 +201,28 @@ public void attachRemote(String remoteName, String remoteUrl) { } } + @Override + public void branch(String name) { + try { + jgitRepository.branchCreate() + .setName(name) + .call(); + } catch (GitAPIException e) { + throw new ScmException(e); + } + } + + @Override + public void checkout(String name) { + try { + jgitRepository.checkout() + .setName(name) + .call(); + } catch (GitAPIException e) { + throw new ScmException(e); + } + } + @Override public void commit(List patterns, String message) { try { @@ -313,8 +335,8 @@ public TagsOnCommit latestTags(Pattern pattern, String sinceCommit) { return latestTagsInternal(pattern, sinceCommit, false); } - private TagsOnCommit latestTagsInternal(Pattern pattern, String maybeSinceCommit, boolean inclusive) { - List taggedCommits = taggedCommitsInternal(pattern, maybeSinceCommit, inclusive, true); + private TagsOnCommit latestTagsInternal(Pattern pattern, String maybeSinceCommit, boolean inclusiveStartingCommit) { + List taggedCommits = taggedCommitsInternal(pattern, maybeSinceCommit, inclusiveStartingCommit, true); return taggedCommits.isEmpty() ? TagsOnCommit.empty() : taggedCommits.get(0); } @@ -323,7 +345,39 @@ public List taggedCommits(Pattern pattern) { return taggedCommitsInternal(pattern, null, true, false); } - private List taggedCommitsInternal(Pattern pattern, String maybeSinceCommit, boolean inclusive, boolean stopOnFirstTag) { + @Override + public List taggedCommitsGlobally(Pattern pattern) { + List taggedCommits = new ArrayList<>(); + if (!hasCommits()) { + return taggedCommits; + } + + try { + ObjectId headId = jgitRepository.getRepository().resolve(Constants.HEAD); + RevWalk walk = walker(headId); + Map> allTags = tagsMatching(pattern, walk); + + for (Map.Entry> entry : allTags.entrySet()) { + String sha = entry.getKey(); + List currentTagsList = entry.getValue(); + + if (currentTagsList != null) { + TagsOnCommit taggedCommit = new TagsOnCommit( + sha, + currentTagsList + ); + taggedCommits.add(taggedCommit); + } + } + walk.dispose(); + } catch (IOException | GitAPIException e) { + throw new ScmException(e); + } + + return taggedCommits; + } + + private List taggedCommitsInternal(Pattern pattern, String maybeSinceCommit, boolean inclusiveStartingCommit, boolean stopOnFirstTag) { List taggedCommits = new ArrayList<>(); if (!hasCommits()) { return taggedCommits; @@ -341,7 +395,7 @@ private List taggedCommitsInternal(Pattern pattern, String maybeSi RevWalk walk = walker(startingCommit); - if (!inclusive) { + if (!inclusiveStartingCommit) { walk.next(); } diff --git a/src/test/groovy/pl/allegro/tech/build/axion/release/Fixtures.groovy b/src/test/groovy/pl/allegro/tech/build/axion/release/Fixtures.groovy new file mode 100644 index 00000000..d0c5d494 --- /dev/null +++ b/src/test/groovy/pl/allegro/tech/build/axion/release/Fixtures.groovy @@ -0,0 +1,54 @@ +package pl.allegro.tech.build.axion.release + +import pl.allegro.tech.build.axion.release.domain.scm.ScmRepository + +// Centralize setup for tests. This class is reachable from 'integration' and 'test' source tree. +final class Fixtures { + // Split up Fixtures, so its easier to see what they are used for. + // Shared fixtures can be in the Fixtures class itself (there are none at the hour of writing) + final class FixtureUseGlobalVersion { + static void setupABranchWithHighTagAndBBranchWithLowTag(ScmRepository repository) { + // * (tag: v2.0.0, high) some commit 2 + // | * (HEAD -> low, tag: v1.0.1) some commit 3 + // |/ + // * (tag: v1.0.0, start) some commit 1 + // * (master) initial commit + repository.branch('start') + repository.checkout('start') + repository.commit(['*'], 'some commit 1') + repository.tag("${TagPrefixConf.fullPrefix()}1.0.0") + repository.branch('high') + repository.checkout('high') + repository.commit(['*'], 'some commit 2') + repository.tag("${TagPrefixConf.fullPrefix()}2.0.0") + repository.checkout('start') + repository.branch('low') + repository.checkout('low') + repository.commit(['*'], 'some commit 3') + repository.tag("${TagPrefixConf.fullPrefix()}1.0.1") + } + static void setupABranchWithHighTagsOutOfOrderAndBBranchWithLowTag(ScmRepository repository) { + // * 570120a (HEAD -> high, tag: v2.0.0) some commit 3 + // * 610acf2 (tag: v3.0.0) some commit 2 + // | * b510d23 (tag: v1.0.1, low) some commit 3 + // |/ + // * 0b4c7ac (tag: v1.0.0, start) some commit 1 + // * eeae3d9 (master) initial commit + repository.branch('start') + repository.checkout('start') + repository.commit(['*'], 'some commit 1') + repository.tag("${TagPrefixConf.fullPrefix()}1.0.0") + repository.branch('high') + repository.checkout('high') + repository.commit(['*'], 'some commit 2') + repository.tag("${TagPrefixConf.fullPrefix()}3.0.0") + repository.commit(['*'], 'some commit 3') + repository.tag("${TagPrefixConf.fullPrefix()}2.0.0") + repository.checkout('start') + repository.branch('low') + repository.checkout('low') + repository.commit(['*'], 'some commit 3') + repository.tag("${TagPrefixConf.fullPrefix()}1.0.1") + } + } +} diff --git a/src/test/groovy/pl/allegro/tech/build/axion/release/domain/VersionResolverTest.groovy b/src/test/groovy/pl/allegro/tech/build/axion/release/domain/VersionResolverTest.groovy index ce781a0f..e9b136a5 100644 --- a/src/test/groovy/pl/allegro/tech/build/axion/release/domain/VersionResolverTest.groovy +++ b/src/test/groovy/pl/allegro/tech/build/axion/release/domain/VersionResolverTest.groovy @@ -1,5 +1,6 @@ package pl.allegro.tech.build.axion.release.domain +import pl.allegro.tech.build.axion.release.Fixtures import pl.allegro.tech.build.axion.release.RepositoryBasedTest import pl.allegro.tech.build.axion.release.TagPrefixConf import pl.allegro.tech.build.axion.release.domain.properties.NextVersionProperties @@ -26,6 +27,48 @@ class VersionResolverTest extends RepositoryBasedTest { resolver = new VersionResolver(repository, "") } + def "should resolve higher global version with useHighestVersion when on branch with lower version"() { + given: 'I am on a branch with a low release tag' + Fixtures.FixtureUseGlobalVersion.setupABranchWithHighTagAndBBranchWithLowTag(repository) + repository.checkout('low') + + when: 'I resolve the version on the branch with the lower release tag' + def versionRulesUseGlobalVersion = versionProperties().useGlobalVersion().useHighestVersion().build() + VersionContext version = resolver.resolveVersion(versionRulesUseGlobalVersion, tagRules, nextVersionRules) + + then: 'the number from branch with the high release number is resolved' + version.previousVersion.toString() == '2.0.0' + version.version.toString() == '2.0.1' + } + + def "should resolve higher global version with useHighestVersion when on branch with higher version"() { + given: 'I am on a branch with a high release tag' + Fixtures.FixtureUseGlobalVersion.setupABranchWithHighTagAndBBranchWithLowTag(repository) + repository.checkout('high') + + when: 'I resolve the version on the branch with the lower release tag' + def versionRulesUseGlobalVersion = versionProperties().useGlobalVersion().useHighestVersion().build() + VersionContext version = resolver.resolveVersion(versionRulesUseGlobalVersion, tagRules, nextVersionRules) + + then: 'the number from branch with the high release number is resolved' + version.previousVersion.toString() == '2.0.0' + version.version.toString() == '2.0.0' + } + + def "should resolve higher global version with useHighestVersion when there are out of order tags"() { + given: 'I am on a branch with a high release tag' + Fixtures.FixtureUseGlobalVersion.setupABranchWithHighTagsOutOfOrderAndBBranchWithLowTag(repository) + repository.checkout('high') + + when: 'I resolve the version on the branch with the lower release tag' + def versionRulesUseGlobalVersion = versionProperties().useGlobalVersion().useHighestVersion().build() + VersionContext version = resolver.resolveVersion(versionRulesUseGlobalVersion, tagRules, nextVersionRules) + + then: 'the number from branch with the high release number is resolved' + version.previousVersion.toString() == '3.0.0' + version.version.toString() == '3.0.1' + } + def "should return default previous and current version when no tag in repository"() { when: VersionContext version = resolver.resolveVersion(defaultVersionRules, tagRules, nextVersionRules) diff --git a/src/test/groovy/pl/allegro/tech/build/axion/release/domain/properties/VersionPropertiesBuilder.groovy b/src/test/groovy/pl/allegro/tech/build/axion/release/domain/properties/VersionPropertiesBuilder.groovy index e9fb85c7..95e15f1a 100644 --- a/src/test/groovy/pl/allegro/tech/build/axion/release/domain/properties/VersionPropertiesBuilder.groovy +++ b/src/test/groovy/pl/allegro/tech/build/axion/release/domain/properties/VersionPropertiesBuilder.groovy @@ -13,6 +13,8 @@ class VersionPropertiesBuilder { private boolean useHighestVersion = false + private boolean useGlobalVersion = false + private MonorepoProperties monorepoProperties = new MonorepoProperties() private Closure versionCreator = PredefinedVersionCreator.SIMPLE.versionCreator @@ -35,6 +37,7 @@ class VersionPropertiesBuilder { PredefinedVersionIncrementer.versionIncrementerFor('incrementPatch'), sanitizeVersion, useHighestVersion, + useGlobalVersion, monorepoProperties ) } @@ -58,7 +61,12 @@ class VersionPropertiesBuilder { this.useHighestVersion = true return this } - + + VersionPropertiesBuilder useGlobalVersion() { + this.useGlobalVersion = true + return this + } + VersionPropertiesBuilder supportMonorepos(MonorepoProperties monorepoProperties) { this.monorepoProperties = monorepoProperties return this