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

muzzle {
  pass {
    group = 'org.springframework'
    module = 'spring-webmvc'
    versions = "[3.1.0.RELEASE,]"
    skipVersions += ['1.2.1', '1.2.2', '1.2.3', '1.2.4'] // broken releases... missing dependencies
    skipVersions += '3.2.1.RELEASE' // missing a required class.  (bad release?)
    extraDependency "javax.servlet:javax.servlet-api:3.0.1"
    assertInverse = true
  }

  // FIXME: webmvc depends on web, so we need a separate instrumentation for spring-web specifically.
  fail {
    group = 'org.springframework'
    module = 'spring-web'
    versions = "[,]"
    skipVersions += ['1.2.1', '1.2.2', '1.2.3', '1.2.4'] // broken releases... missing dependencies
    extraDependency "javax.servlet:javax.servlet-api:3.0.1"
  }
}

dependencies {
  compileOnly group: 'org.springframework', name: 'spring-webmvc', version: '3.1.0.RELEASE'
  compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
//  compileOnly group: 'org.springframework', name: 'spring-webmvc', version: '2.5.6'
//  compileOnly group: 'javax.servlet', name: 'servlet-api', version: '2.4'

  testImplementation(project(':testing-common')) {
    exclude(module: 'jetty-server') // incompatible servlet api
  }

  // Include servlet instrumentation for verifying the tomcat requests
  testInstrumentation project(':instrumentation:servlet:servlet-3.0:javaagent')
  testInstrumentation project(':instrumentation:servlet:servlet-common:javaagent')
  testInstrumentation project(':instrumentation:tomcat-7.0:javaagent')

  testImplementation group: 'javax.validation', name: 'validation-api', version: '1.1.0.Final'
  testImplementation group: 'org.hibernate', name: 'hibernate-validator', version: '5.4.2.Final'

  testImplementation group: 'org.spockframework', name: 'spock-spring', version: "$versions.spock"

  testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.17.RELEASE'
  testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.17.RELEASE'
  testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.17.RELEASE'

  testImplementation group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.0.16.RELEASE'

  // For spring security
  testImplementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
  testImplementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
}

tasks.withType(Test) {
  // TODO run tests both with and without experimental span attributes
  jvmArgs '-Dotel.instrumentation.spring-webmvc.experimental-span-attributes=true'
}
