Converting from Maven to Gradle, need more specified dependencies in build.gradle or tests fail

You should use the following notation

dependencies {
  jenkinsTest group: 'org.jenkins-ci.plugins', name: 'ant', version: '1.3', ext: 'jar' 
}

If you use jenkinsTest "org.jenkins-ci.plugins:ant:1.3, Gradle will download the POM file, parse it, infer the packaging (hpi) and download the hpi file (not the jar file) but you’ll have the transitive dependencies because you parsed the POM. However the hpi file isn’t what you need because its content is different from the jar file (just compare them)

If you use jenkinsTest "org.jenkins-ci.plugins:ant:1.3@jar", you’re fetching the jar file (which is what you want) however you don’t parse the POM file and therefore don’t pull the transitive dependencies.

By using jenkinsTest group: 'org.jenkins-ci.plugins', name: 'ant', version: '1.3', ext: 'jar' you’re asking Gradle to fetch the jar file and also parse the POM file so you get what you want (jar file + transitive dependencies)

1 Like