Added deploy task.

This commit is contained in:
Erik C. Thauvin 2017-04-30 23:17:04 -07:00
parent 7076c928a1
commit 940f10bf60

View file

@ -1,17 +1,23 @@
import com.beust.kobalt.* import com.beust.kobalt.*
import com.beust.kobalt.plugin.apt.* import com.beust.kobalt.api.Project
import com.beust.kobalt.plugin.packaging.* import com.beust.kobalt.api.annotation.Task
import com.beust.kobalt.plugin.application.* import com.beust.kobalt.misc.KobaltLogger
import com.beust.kobalt.plugin.java.* import com.beust.kobalt.misc.log
import com.beust.kobalt.plugin.application.application
import com.beust.kobalt.plugin.apt.apt
import com.beust.kobalt.plugin.packaging.assemble
import com.beust.kobalt.plugin.packaging.install
import com.beust.kobalt.plugin.publish.autoGitTag
import java.io.File import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.util.* import java.util.*
val bs = buildScript { val bs = buildScript {
repos() repos(file("K:/maven/repository"))
} }
val mainClassName = "net.thauvin.erik.mobibot.Mobibot" val mainClassName = "net.thauvin.erik.mobibot.Mobibot"
val deploy = "deploy"
fun StringBuilder.prepend(s: String): StringBuilder { fun StringBuilder.prepend(s: String): StringBuilder {
if (this.isNotEmpty()) { if (this.isNotEmpty()) {
@ -41,49 +47,59 @@ val p = project {
version = versionFor() version = versionFor()
val processorJar = "net.thauvin.erik:semver:" val processorJar = "net.thauvin.erik:semver:0.9.7"
val lib = "lib"
dependencies { dependencies {
compile("log4j:log4j:jar:1.2.17") compile("log4j:log4j:jar:1.2.17")
compile("pircbot:pircbot:1.5.0") compile("pircbot:pircbot:1.5.0")
compile("commons-codec:commons-codec:1.10") compile("commons-codec:commons-codec:1.10")
compile("commons-logging:commons-logging:1.2") compile("commons-logging:commons-logging:1.2")
compile("commons-net:commons-net:3.6") compile("commons-net:commons-net:3.6")
compile("commons-cli:commons-cli:1.4") compile("commons-cli:commons-cli:1.4")
compile("commons-httpclient:commons-httpclient:3.1") compile("commons-httpclient:commons-httpclient:3.1")
compile("oro:oro:2.0.8") compile("oro:oro:2.0.8")
compile("org.jsoup:jsoup:1.10.2") compile("org.jsoup:jsoup:1.10.2")
compile("com.rometools:rome:1.7.1") compile("com.rometools:rome:1.7.1")
compile("org.slf4j:slf4j-log4j12:1.7.25") compile("org.slf4j:slf4j-log4j12:1.7.25")
compile("org.json:json:20160810") compile("org.json:json:20160810")
compile("org.ostermiller:utils:1.07.00") compile("org.ostermiller:utils:1.07.00")
compile("net.sourceforge.jweather:jweather:jar:0.3.0") compile("net.objecthunter:exp4j:0.4.8")
compile("net.objecthunter:exp4j:0.4.8")
compile("org.twitter4j:twitter4j-core:4.0.6") compile("org.twitter4j:twitter4j-core:4.0.6")
compile("net.sf.delicious-java:delicious:1.14") compile("net.sf.delicious-java:delicious:1.14")
compile(file("lib/owm-japis-2.5.0.5.jar")) compile(file("lib/owm-japis-2.5.0.5.jar"))
apt(processorJar) apt(processorJar)
compile(processorJar) compileOnly(processorJar)
} }
apt { apt {
outputDir = "/src/generated/java/" outputDir = "../src/generated/java/"
}
autoGitTag {
enabled = true
message = "Version $version"
annotated = true
} }
assemble { assemble {
jar { jar {
name = "${project.name}.jar" name = "${project.name}.jar"
fatJar = true
manifest { manifest {
attributes("Main-Class", mainClassName) attributes("Main-Class", mainClassName)
attributes("Class-Path",
collect(compileDependencies)
.filter { !it.file.name.startsWith("junit") }
.map { it.file.name }
.joinToString(" ./$lib/", prefix = ". ./$lib/"))
} }
} }
} }
@ -94,6 +110,20 @@ val p = project {
} }
install { install {
libDir = "deploy" target = deploy
include(from("kobaltBuild/libs"), to(target), glob("**/*"))
include(from("properties"), to(target), glob("**/*.properties"))
collect(compileDependencies)
.filter { !it.file.name.startsWith("junit") }
.forEach {
copy(from(it.file.absolutePath), to("$target/$lib"))
}
} }
} }
@Task(name = "deploy", dependsOn = arrayOf("assemble", "install"), description = "Deploy application")
fun deploy(project: Project): TaskResult {
File("$deploy/logs").mkdir()
KobaltLogger.log(1, " Deployed to " + File(deploy).absolutePath)
return TaskResult()
}