Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blog Post Example Script
import org.gradle.kotlin.dsl.extra
import org.jetbrains.kotlin.gradle.dsl.Coroutines
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val kotlinVersion = plugins.getPlugin(KotlinPluginWrapper::class.java).kotlinPluginVersion
val kotlinCoroutinesVersion = "0.19.3"
val vertxVersion = "3.5.0"
val nexusRepo = "http://x.x.x.x:8080/nexus/content/repositories/releases"
plugins {
kotlin("jvm").version("1.2.0")
application
java
`maven-publish`
}
dependencies {
compile(kotlin("stdlib", kotlinVersion))
compile(kotlin("reflect", kotlinVersion))
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion")
"io.vertx:vertx".let { v ->
compile("$v-lang-kotlin:$vertxVersion")
compile("$v-lang-kotlin-coroutines:$vertxVersion")
compile("$v-web:$vertxVersion")
compile("$v-mongo-client:$vertxVersion")
compile("$v-health-check:$vertxVersion")
compile("$v-web-templ-thymeleaf:$vertxVersion")
}
compile("org.slf4j:slf4j-api:1.7.14")
compile("ch.qos.logback:logback-classic:1.1.3")
compile("com.fasterxml.jackson.module:jackson-module-kotlin:2.9.0.pr3")
testCompile(kotlin("test", kotlinVersion))
testCompile(kotlin("test-junit", kotlinVersion))
testCompile("io.vertx:vertx-unit:$vertxVersion")
testCompile("org.mockito:mockito-core:2.6.2")
testCompile("junit:junit:4.11")
}
repositories {
mavenCentral()
jcenter()
listOf("https://www.seasar.org/maven/maven2/",
"https://plugins.gradle.org/m2/",
nexusRepo).forEach {
maven { url = uri(it) }
}
}
kotlin {
experimental.coroutines = Coroutines.ENABLE
}
application {
group = "de.swirtz"
version = "1.0.0"
applicationName = "gradle-kotlindsl"
mainClassName = "de.swirtz.ApplicationKt"
}
publishing {
repositories {
maven {
url = uri(nexusRepo)
}
}
if (!project.hasProperty("jenkins")) {
println("Property 'jenkins' not set. Publishing only to MavenLocal")
} else {
(publications) {
"maven"(MavenPublication::class) {
from(components["java"])
}
}
}
}
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
withType<Test> {
testLogging.showStandardStreams = true
}
withType<Jar> {
manifest {
attributes["Main-Class"] = application.mainClassName
}
from(configurations.runtime.map { if (it.isDirectory) it else zipTree(it) })
}
withType<GradleBuild> {
finalizedBy("publishToMavenLocal")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment