More with kobalt.
This commit is contained in:
parent
ae4e775e6e
commit
e5e6d9c383
4 changed files with 43 additions and 12 deletions
|
@ -1,17 +1,23 @@
|
||||||
import java.util.Properties
|
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.lang.NumberFormatException
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
import com.beust.kobalt.*
|
import com.beust.kobalt.*
|
||||||
import com.beust.kobalt.plugin.packaging.*
|
import com.beust.kobalt.api.annotation.Task
|
||||||
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.plugin.application.*
|
import com.beust.kobalt.plugin.application.*
|
||||||
import com.beust.kobalt.plugin.java.*
|
|
||||||
import com.beust.kobalt.plugin.apt.*
|
import com.beust.kobalt.plugin.apt.*
|
||||||
|
import com.beust.kobalt.plugin.java.*
|
||||||
|
import com.beust.kobalt.plugin.packaging.*
|
||||||
|
|
||||||
val repos = repos()
|
val repos = repos()
|
||||||
|
|
||||||
val p = project {
|
val p = project {
|
||||||
|
|
||||||
fun getVersion(isIncremental: Boolean = false): String {
|
name = "example"
|
||||||
|
|
||||||
|
fun getVersion(isIncrement: Boolean = false): String {
|
||||||
val propsFile = "version.properties"
|
val propsFile = "version.properties"
|
||||||
val majorKey = "version.major"
|
val majorKey = "version.major"
|
||||||
val minorKey = "version.minor"
|
val minorKey = "version.minor"
|
||||||
|
@ -31,10 +37,28 @@ val p = project {
|
||||||
if (prerelease.length > 0) {
|
if (prerelease.length > 0) {
|
||||||
prerelease.insert(0, "+");
|
prerelease.insert(0, "+");
|
||||||
}
|
}
|
||||||
return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + p.getProperty(patchKey, "0") + prerelease + metadata)
|
|
||||||
|
val value = p.getProperty(patchKey, "0");
|
||||||
|
val patch: String?
|
||||||
|
|
||||||
|
if (isIncrement) {
|
||||||
|
patch = try {
|
||||||
|
(value.toInt() + 1).toString();
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
"0"
|
||||||
|
}
|
||||||
|
|
||||||
|
FileOutputStream(propsFile).use { output ->
|
||||||
|
p.setProperty(patchKey, patch)
|
||||||
|
p.store(output, "")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
patch = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (p.getProperty(majorKey, "1") + "." + p.getProperty(minorKey, "0") + "." + patch + prerelease + metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
name = "example"
|
|
||||||
version = getVersion()
|
version = getVersion()
|
||||||
|
|
||||||
val mainClassName = "net.thauvin.erik.semver.example.Example"
|
val mainClassName = "net.thauvin.erik.semver.example.Example"
|
||||||
|
@ -69,3 +93,9 @@ val p = project {
|
||||||
mainClass = mainClassName
|
mainClass = mainClassName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Task(name = "release", dependsOn = arrayOf("clean"), description = "Releases new version.")
|
||||||
|
fun taskRelease(project: Project): TaskResult {
|
||||||
|
project.version = project.getVersion(true)
|
||||||
|
return TaskResult()
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
BIN
example/libs/example-3.1.45+beta.jar
Normal file
BIN
example/libs/example-3.1.45+beta.jar
Normal file
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
#Wed, 03 Feb 2016 13:10:11 -0800
|
#
|
||||||
version.project=Example
|
#Wed Jul 06 19:28:58 PDT 2016
|
||||||
version.major=3
|
|
||||||
version.minor=1
|
|
||||||
version.patch=39
|
|
||||||
version.buildmeta=
|
|
||||||
version.prerelease=beta
|
version.prerelease=beta
|
||||||
|
version.project=Example
|
||||||
|
version.minor=1
|
||||||
|
version.buildmeta=
|
||||||
|
version.patch=45
|
||||||
|
version.major=3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue