apply plugin: 'war'
apply plugin: 'tomcat'

apply from: "$rootDir/gradle/functionalTest.gradle"
apply from: "$rootDir/gradle/acceptanceTest.gradle"
apply from: "$rootDir/gradle/swaggerUiInclude.gradle"

jvmsrc {
  packageName "com.ak.spring3.testsuite"
}

sourceCompatibility = 1.6

buildscript {
  dependencies {
    classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
  }
}

dependencies {
  compile libs.springWeb.call() //Call the closure - its not a list like the others
  compile libs.jackson
  compile libs.logging
  compile libs.jackson
  compile libs.swagger
  compile libs.validation
  compile 'commons-fileupload:commons-fileupload:1.3.1'

  compile 'javax.servlet:jstl:1.2'

  providedCompile 'javax.servlet:javax.servlet-api:3.0.1'

  tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
  tomcat "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
  tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
    exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
  }
  tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"

}

/**
 * Task to run functional and acceptance tests
 * acceptance run with phantom headless browser
 */
task fullTest()

fullTest.dependsOn tomcatRun
fullTest.dependsOn functionalTest
fullTest.dependsOn acceptanceTestPhantom

fullTest.finalizedBy tomcatStop

functionalTest.shouldRunAfter tomcatRun
acceptanceTestPhantom.shouldRunAfter functionalTest
tomcatStop.shouldRunAfter acceptanceTestPhantom

tomcat {
  httpPort = 9080
  ajpPort = 9009
  stopPort = 9091
}

//should always be true for ci
tomcatRun.daemon = project.hasProperty('tcDaemon') ? true : false

