I see a lot of build.gradle configs with this setting:
compile group: 'org.jenkins-ci.main', name: 'jenkins-core', version: '+', ext: 'jar'
what is ext: 'jar'
do?
ext is DefaultExtraPropertiesExtension but I can’t find docs for what “jar” is.
If I take off the ext: jar
in this example I get an error for what looks like a transitive dependency:
Could not find org.connectbot.jbcrypt:jbcrypt:1.0.0.
Is “jar” downloading a precompiled uber jar or something instead of a proper Maven package? Why is it there seems to be ZERO documentation for this- maybe I’m not looking in the right place?
Edit
I found an explanation here:
NOTE 2: The ext: ‘jar’ is VERY important to ensure that jar files, instead of hpi/jpi files, are being downloaded and understood by IntellJ. Without that ext option specified, IntellJ won’t find JAR files nested in hpi/jpi files which is the default binaries for Jenkins plugins.
But I’m still confused what’s happening. Is the argument “jar” being passed to the dependency and these Jenkins dependencies are aware of this “jar” argument? So jar isn’t a standard Gradle dep thing, it’s specific to these Jenkins deps?
Advertisement
Answer
This is documented in the DSL documentation of DependencyHander
:
https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html#N16E3D
There are two notations supported for declaring a dependency on an external module. One is a string notation formatted this way:
configurationName "group:name:version:classifier@extension"
The other is a map notation:
configurationName group: group, name: name, version: version, classifier: classifier, ext: extension
And is further documented in the Javadoc:
Returns the extension of this artifact. Often the extension is the same as the type, but sometimes this is not the case. For example for an ivy XML module descriptor, the type is ivy and the extension is xml.