Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
124 lines (97 sloc) 3.09 KB
/*
* Check usage information at: http://hexagonkt.com/gradle.html#kotlin
*/
apply(plugin: "kotlin")
apply(plugin: "jacoco")
apply(plugin: "maven-publish")
defaultTasks("build")
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
}
// Replace build variables in resource files
processResources {
[ "properties", "ini", "cfg", "txt", "html", "xml", "json", "yaml" ].each { String ext ->
final Map<String, ?> stringProperties = project.getProperties()
.findAll { it.value instanceof String }
filesMatching("**/*.$ext") {
filter {
String content = it
stringProperties.entrySet().forEach { entry ->
content = content.replace("\${project.${entry.key}}", entry.value.toString())
}
content
}
}
}
}
tasks.compileKotlin.kotlinOptions.jvmTarget = targetCompatibility
tasks.compileKotlin.kotlinOptions.apiVersion = "1.3"
tasks.compileTestKotlin.kotlinOptions.jvmTarget = tasks.compileKotlin.kotlinOptions.jvmTarget
tasks.compileTestKotlin.kotlinOptions.apiVersion = tasks.compileKotlin.kotlinOptions.apiVersion
// Clean the project taking care of logs and runtime files
clean {
delete("build", "log", "out", ".vertx", "file-uploads")
delete(
fileTree(rootDir) { include "**/*.log" },
fileTree(rootDir) { include "**/*.hprof" }
)
}
// Show useful testing information while running tests
tasks.withType(Test).each { testTask ->
testTask.systemProperties(project.getProperties().findAll { it.value instanceof String })
testTask.testLogging {
events("skipped", "failed", "standardOut", "standardError")
}
}
test {
exclude("**/*IT.*")
}
task("verify", dependsOn: "test", type: Test) {
include("**/*IT.*")
}
jacoco {
toolVersion = "0.8.3"
}
// Generate coverage reports properly
jacocoTestReport {
dependsOn("test")
reports {
xml.enabled = true
html.enabled = true
}
}
task("jarAll", type: Jar, dependsOn: "test") {
archiveBaseName.set("${archiveBaseName.orNull}-all".toString())
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
with(jar)
}
assemble.dependsOn("jarAll")
task("sourceJar", type: Jar) {
archiveClassifier.set("sources")
from(sourceSets.main.allJava)
}
task("testJar", type: Jar, dependsOn: testClasses) {
archiveClassifier.set("test")
from(sourceSets.test.output.classesDirs)
}
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
artifact(sourceJar) // To be accepted in JCenter, the package need to include sources
artifact(testJar)
}
}
}
You can’t perform that action at this time.