apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'

mainClassName = 'ai.susi.SusiServer'

apply plugin: 'com.github.johnrengelman.shadow'
def swaggerVersion = '1.5.8'
def versionJersey = '2.22.2'
buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
    classpath 'org.ajoberstar:gradle-git:0.7.0' 
  }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets.main.java.srcDirs = ['src']
sourceSets.main.resources.srcDirs = ['conf/logs']
sourceSets.test.java.srcDirs = ['test']


import org.ajoberstar.grgit.*

jar {
    manifest {
        attributes 'Main-Class': 'ai.susi.SusiServer'
    }
}

shadowJar {
  mergeServiceFiles()
}

repositories {
  mavenCentral()
  maven { url 'https://github.com/broadbear/maven-repo/raw/master' }

}

dependencies {
  compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.+'
  compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+'
  compile group: 'com.google.guava', name: 'guava', version: '18.+'
  compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.+'
  compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.+'
  compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.+'
  compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version: '9.3.+'
  compile group: 'com.sun.mail', name: 'javax.mail', version: '1.+'
  compile group: 'org.eclipse.jetty', name: 'jetty-rewrite', version: '9.3.+'
  compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.3.+'
  compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.3.+'
  compile group: 'org.joda', name: 'joda-convert', version: '1.+'
  compile group: 'joda-time', name: 'joda-time', version: '2.+'
  compile group: 'org.jsoup', name: 'jsoup', version: '1.+'
  compile group: 'junit', name: 'junit', version: '4.+'
  compile group: 'rome', name: 'rome', version: '1.+'
  compile group: 'it.unibo.alice.tuprolog', name: 'tuprolog', version: '3.+'
  compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.+'
  compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.+'
  compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.+'
  compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.+'
  compile group: 'jfree', name: 'jfreechart', version: '1.+'
  compile group: 'com.wordnik', name: 'swagger-core_2.9.1', version: '1.1-SNAPSHOT.120119'
  compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.0.1.201806211838-r'
  compile 'org.broadbear:link-preview:1.2'
  compile group: 'io.swagger', name: 'swagger-annotations',version: swaggerVersion
  compile group: 'io.swagger', name: 'swagger-core', version: swaggerVersion
  compile group: 'io.swagger', name: 'swagger-jersey2-jaxrs', version: swaggerVersion
  compile group: 'io.swagger', name: 'swagger-models', version: swaggerVersion
  compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version: versionJersey
  compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet-core', version: versionJersey
  compile group: 'org.webjars', name: 'swagger-ui', version: '2.1.4'
  compile group: 'commons-io', name: 'commons-io', version: '2.6'
  compile group: 'com.joestelmach', name: 'natty', version: '0.13'
  compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.+'
  testCompile "org.mockito:mockito-core:2.+"
}

task stage(dependsOn: ['assemble', 'clean'])
assemble.mustRunAfter clean

tasks.withType(Javadoc) {
  options.addBooleanOption('Xdoclint:none', true)
}

tasks.withType(JavaCompile) {
  options.encoding = 'UTF-8'
}

task start(type: JavaExec, dependsOn: classes) {
  main = 'ai.susi.SusiServer'
  classpath sourceSets.main.runtimeClasspath
  classpath configurations.runtime
}

jacocoTestReport {
  reports {
    xml.enabled true
    html.enabled false
  }
}
