In my example, I’m creating a Jenkins plugin (so, Maven) which has a dependency to the Team Concert plugin from IBM. As expected, Maven is going to resolve this dependency by fetching the corresponding .jar file from the Jenkins public repository, listed in the repository list of my own plugin.
So I’ve added the following to my plugin’s pom file:
And when executed…
Unluckily, Team Concert plugin has a dependency of its own (com.ibm.team.build.hpiplugin-rtc), which is resolved locally in the developers’ environment (not nice, uhm IBM?). No .jar is provided anywhere, so the only solution would be to build the dependency ourselves and install it in the local maven. This would require a bulky package – part of the Rational Team Concert API – and an environment similar of those devs.
That sounds awkward, yes, especially because what I really need – the .jar file of the Team Concert plugin – is already there. But before we blame Maven, we can identify that the dependency between the Team Concert plugin and com.ibm.team.build.hpiplugin-rtc happens to be declared with the default scope, that is, compile scope.
compile : This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
As a fact, I cannot change the dependency relation in the Team Concert plugin. Also, I’m not exactly willing to download and setup the IBM environment. My last resort is a dirty trick that, although very simple, I could not figure out at first without help:
As we know, when Maven resolves dependencies from an external repository, it’s actually installing each of them on the local machine (.m2 folder). This hidden folder is nicely managed by Maven. Until something goes really wrong, Maven users don’t even need to know this folder exists.
Still, this is a repo with plenty of .jar files and their respective .pom, where the dependencies are listed. So, in order to cut a dependency from our environment, we will need a little twist in one of those .pom files.
My plugin ⇒ Team Concert plugin ⇒ com.ibm.team.build.hpiplugin-rtc
To proceed, I’ll open the org.jenkins-ci.plugins:teamconcert:jar:1.1.9.4 Maven file at .m2/repository/org/jenkins-ci/plugins/teamconcert/1.1.9.4/teamconcert-1.1.9.4.pom and comment the following dependency: