From 940f10bf60acb1e86b4937ddd96e003dadc6a098 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 30 Apr 2017 23:17:04 -0700 Subject: [PATCH] Added deploy task. --- kobalt/src/Build.kt | 88 ++++++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index 129bbde..31a977b 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -1,17 +1,23 @@ import com.beust.kobalt.* -import com.beust.kobalt.plugin.apt.* -import com.beust.kobalt.plugin.packaging.* -import com.beust.kobalt.plugin.application.* -import com.beust.kobalt.plugin.java.* +import com.beust.kobalt.api.Project +import com.beust.kobalt.api.annotation.Task +import com.beust.kobalt.misc.KobaltLogger +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.FileInputStream import java.util.* val bs = buildScript { - repos() + repos(file("K:/maven/repository")) } val mainClassName = "net.thauvin.erik.mobibot.Mobibot" +val deploy = "deploy" fun StringBuilder.prepend(s: String): StringBuilder { if (this.isNotEmpty()) { @@ -41,49 +47,59 @@ val p = project { version = versionFor() - val processorJar = "net.thauvin.erik:semver:" + val processorJar = "net.thauvin.erik:semver:0.9.7" + val lib = "lib" 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-logging:commons-logging:1.2") - compile("commons-net:commons-net:3.6") - compile("commons-cli:commons-cli:1.4") - compile("commons-httpclient:commons-httpclient:3.1") + compile("commons-codec:commons-codec:1.10") + compile("commons-logging:commons-logging:1.2") + compile("commons-net:commons-net:3.6") + compile("commons-cli:commons-cli:1.4") + 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("com.rometools:rome:1.7.1") - compile("org.slf4j:slf4j-log4j12:1.7.25") - compile("org.json:json:20160810") - compile("org.ostermiller:utils:1.07.00") + compile("org.jsoup:jsoup:1.10.2") + compile("com.rometools:rome:1.7.1") + compile("org.slf4j:slf4j-log4j12:1.7.25") + compile("org.json:json:20160810") + 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("net.sf.delicious-java:delicious:1.14") + compile("org.twitter4j:twitter4j-core:4.0.6") + 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) - compile(processorJar) + apt(processorJar) + compileOnly(processorJar) } apt { - outputDir = "/src/generated/java/" + outputDir = "../src/generated/java/" + } + + autoGitTag { + enabled = true + message = "Version $version" + annotated = true } assemble { jar { name = "${project.name}.jar" - fatJar = true manifest { 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 { - 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() +}