pl.allegro.tech.build.axion.release.domain.PredefinedVersionCreator.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axion-release-plugin Show documentation
Show all versions of axion-release-plugin Show documentation
Gradle release and version management plugin
package pl.allegro.tech.build.axion.release.domain
import pl.allegro.tech.build.axion.release.domain.scm.ScmPosition
enum PredefinedVersionCreator {
SIMPLE('simple', { String versionFromTag, ScmPosition position ->
return versionFromTag.toString()
}),
VERSION_WITH_BRANCH('versionWithBranch', { String versionFromTag, ScmPosition position ->
if (position.branch != 'master' && position.branch != 'HEAD') {
return "$versionFromTag-$position.branch".toString()
}
return versionFromTag
})
private final String type
final Closure versionCreator
private PredefinedVersionCreator(String type, Closure c) {
this.type = type
this.versionCreator = c
}
static Closure versionCreatorFor(String type) {
PredefinedVersionCreator creator = values().find { it.type == type }
if (creator == null) {
throw new IllegalArgumentException("There is no predefined version creator with $type type. " +
"You can choose from: ${values().collect { it.type }}");
}
return creator.versionCreator
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy