Added the ability to specify the version via the command line.
This commit is contained in:
parent
8d423a506a
commit
16d1a06571
2 changed files with 21 additions and 19 deletions
|
@ -116,16 +116,17 @@ class SemverPlugin : Plugin<Project> {
|
|||
Properties().apply {
|
||||
load(reader)
|
||||
|
||||
hasReqProps = stringPropertyNames().containsAll(setOf(config.majorKey, config.minorKey,
|
||||
config.patchKey, config.preReleaseKey, config.buildMetaKey))
|
||||
val requiredProps = setOf(config.majorKey, config.minorKey, config.patchKey,
|
||||
config.preReleaseKey, config.buildMetaKey)
|
||||
hasReqProps = stringPropertyNames().containsAll(requiredProps) && !hasEnv(requiredProps)
|
||||
|
||||
version.major = getProperty(config.majorKey, Version.DEFAULT_MAJOR)
|
||||
version.minor = getProperty(config.minorKey, Version.DEFAULT_MINOR)
|
||||
version.patch = getProperty(config.patchKey, Version.DEFAULT_PATCH)
|
||||
version.preRelease = getProperty(config.preReleaseKey, Version.DEFAULT_EMPTY)
|
||||
version.major = loadProperty(this, config.majorKey, Version.DEFAULT_MAJOR)
|
||||
version.minor = loadProperty(this, config.minorKey, Version.DEFAULT_MINOR)
|
||||
version.patch = loadProperty(this, config.patchKey, Version.DEFAULT_PATCH)
|
||||
version.preRelease = loadProperty(this, config.preReleaseKey, Version.DEFAULT_EMPTY)
|
||||
version.preReleasePrefix =
|
||||
getProperty(config.preReleasePrefixKey, Version.DEFAULT_PRERELEASE_PREFIX)
|
||||
version.buildMeta = getProperty(config.buildMetaKey, Version.DEFAULT_EMPTY)
|
||||
version.buildMeta = loadProperty(this, config.buildMetaKey, Version.DEFAULT_EMPTY)
|
||||
version.buildMetaPrefix =
|
||||
getProperty(config.buildMetaPrefixKey, Version.DEFAULT_BUILDMETA_PREFIX)
|
||||
version.separator = getProperty(config.separatorKey, Version.DEFAULT_SEPARATOR)
|
||||
|
@ -147,4 +148,15 @@ class SemverPlugin : Plugin<Project> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasEnv(keys: Set<String>): Boolean {
|
||||
keys.forEach {
|
||||
if (System.getProperties().containsKey(it)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun loadProperty(props: Properties, key: String, default: String): String {
|
||||
return System.getProperty(key, props.getProperty(key, default))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue