apply from: "$rootDir/gradle/instrumentation.gradle"

muzzle {
  pass {
    group = "org.apache.tomcat"
    module = "tomcat-jasper"
    // range [7.0.0,7.0.19) and version 8.0.9 missing from maven
    // tomcat 10 uses JSP 3.0
    versions = "[7.0.19,10)"
    skipVersions += '8.0.9'
  }
}

dependencies {
  // compiling against tomcat 7.0.20 because there seems to be some issues with Tomcat's dependency < 7.0.20
  compileOnly group: 'org.apache.tomcat', name: 'tomcat-jasper', version: '7.0.20'
  compileOnly group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '2.3.0'
  compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'

  testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
  testInstrumentation project(':instrumentation:servlet:servlet-common:javaagent')

  // using tomcat 7.0.37 because there seems to be some issues with Tomcat's jar scanning in versions < 7.0.37
  // https://stackoverflow.com/questions/23484098/org-apache-tomcat-util-bcel-classfile-classformatexception-invalid-byte-tag-in
  testLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '7.0.37'
  testLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '7.0.37'
  testLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '7.0.37'

  latestDepTestLibrary group: 'javax.servlet.jsp', name: 'javax.servlet.jsp-api', version: '+'
  latestDepTestLibrary group: 'javax.servlet', name: 'javax.servlet-api', version: '+'
  latestDepTestLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.+'
  latestDepTestLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version: '9.+'
  latestDepTestLibrary group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '9.+'
}

tasks.withType(Test) {
  // skip jar scanning using environment variables:
  // http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html#JAR_Scanning
  // having this set allows us to test with old versions of the tomcat api since
  // JarScanFilter did not exist in the tomcat 7 api
  jvmArgs '-Dorg.apache.catalina.startup.ContextConfig.jarsToSkip=*'
  jvmArgs '-Dorg.apache.catalina.startup.TldConfig.jarsToSkip=*'
}
