💚 Modernize build script a bit
[rhynodge.git] / build.gradle
index a7da6a9..73ef9a1 100644 (file)
@@ -1,4 +1,20 @@
-apply plugin: "java"
+buildscript {
+    ext.kotlinVersion = '1.4.10'
+
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath group: "org.ajoberstar", name: "gradle-git", version: "1.1.0"
+    }
+}
+
+plugins {
+    id 'java'
+    id('org.jetbrains.kotlin.jvm') version '1.4.10'
+}
+
+apply plugin: "war"
 apply plugin: "jacoco"
 apply plugin: "idea"
 
@@ -15,10 +31,12 @@ sourceCompatibility = 1.8
 targetCompatibility = 1.8
 
 repositories {
-       mavenCentral()
+    mavenCentral()
+    jcenter()
 }
 
 dependencies {
+    compile group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "$kotlinVersion"
     compile group: "com.google.guava", name: "guava", version: "14.0-rc1"
     compile group: "log4j", name: "log4j", version: "1.2.17"
     compile group: "org.apache.httpcomponents", name: "httpclient", version: "4.4"
@@ -28,6 +46,9 @@ dependencies {
     compile group: "com.fasterxml.jackson.core", name: "jackson-core", version: "2.1.2"
     compile group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: "2.1.2"
     compile group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.1.2"
+    compile group: "com.google.inject", name: "guice", version: "4.0"
+    compile group: "org.jetbrains.kotlinx", name: "kotlinx-html-jvm", version: "0.7.1"
+    compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
 
     testCompile group: "junit", name: "junit", version:"4.12"
     testCompile group: "org.hamcrest", name: "hamcrest-library", version:"1.3"
@@ -42,6 +63,40 @@ task fatJar(type: Jar) {
                )
        }
        from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
+       from { sourceSets.generated.resources.srcDirs }
        with jar
        dependsOn test
 }
+
+task createVersion() {
+    sourceSets {
+        generated {
+            resources {
+                srcDir "src/generated/resources"
+            }
+        }
+    }
+    processResources.dependsOn(createVersion)
+}
+
+
+import org.ajoberstar.grgit.Grgit
+createVersion {
+    doLast {
+        def gitRepo = Grgit.open(".")
+        version = gitRepo.describe()
+        new File("src/generated/resources").mkdirs()
+        new File("src/generated/resources/version.txt").withWriter() { it.write(version) }
+    }
+}
+
+war {
+    classpath sourceSets.generated.output
+    dependsOn(test)
+}
+
+jacoco {
+    toolVersion = "0.7.6.201602180812"
+}
+
+/* vim: set ts=4 sw=4 et: */