So, I have a war project with several dependent jars that are not available in any repository. Up until recently, I'd been keeping them in src/main/webapp/WEB-INF/lib
, and adding them to the pom with system scope.
I get that that's problematic, so I'm looking to clean up my build. I've semi-manually installed the jars into my .m2/repository
via the install:install-file
plugin. That's great for me, but what about the other people on my team? We're tiny, and setting up Nexus isn't really an option for us. I've resorted to adding comments to the pom.xml
explaining how to run install:install-file
for each jar.
I'm OK with the install:install-file
solution, but I'd still like to include these artifacts in my project's version control, and not merely have them sprinkled about my filesystem.
Keeping them in src/main/webapp/WEB-INF/lib
doesn't work, since that automatically adds them to the resulting war artifact (digression: if maven would simply go ahead and add them to the classpath here I'd be done, no need for install:install-file!)
Question: is there a sanctioned place in the maven directory layout where I can tuck these .jar
files, just so that I can keep them as part of my project?
I do realize what's going on here- Maven is attempting to keep dependent jars outside of my build so that when other projects depend on my build, they can resolve the transitive dependencies. That's great for open-source projects that are going into the public maven repos, but I'd bet that the vast majority of people using Maven are working on "leaf" projects such as this, and it would be really handy to have a way to include jar files as part of the project without jumping through so many hoops.
Apache Maven Shade Plugin provides the capability to package the artifact in an uber-jar, which consists of all dependencies required to run the project.
Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.
If setting up Nexus or just a simple fileserver repo as suggested by Jan is really too much trouble, here are some other options:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With