0

I have a web app with thousands classes packed in hundred jar's placed in several folders.

I want create in local maven repository a library, containing all classes from those jars. And I can use this dependensy in all my projects...

Like in a IntelliJ IDEA i create a global library. Select a folder with sets of jars with subfolders and set name "My web-app libs". And then i add this global lib on my project.

I have founded a way for construct group for several libraries, described here. But I have a hundred jar files and stupid make new project for each.

In advance thanks.

2 Answers2

1

Look at maven shade plugin.

This plugin provides the capability to package the artifact in an uber-jar,

MariuszS
  • 30,646
  • 12
  • 114
  • 155
  • With this i can repack all classes to my one new jar, yes? But i need include all 300+ jar's before? I was read addon FAQ, but don't understand how it can help me... can you explain a bit how i can avoid add dependency for every existing jar? This jars not in repository, they are just in folder on my HDD. – Андрей Крюков Nov 18 '13 at 16:27
0

You may want to create another project which enlists all your artifacts as dependencies. So when you include it into your project all the needed 100 dependencies will be transitively resolved.

Maven Versions plugin could help you bulk updating the many versions inside this new artifact.

UPDATE

If all your 300+ jars are completely static, i.e. their versions are fixed, you might probably need to repack them with the shade plugin. Otherwise updating a version of a JAR from this huge set could be a trouble... I can't predict the performance, but my guess is that a normal Maven approach is more efficient.

A note on Maven shade plugin: you might need to move your shaded libraries to shaded package. That's what they usually do to avoid library versions conflicts. I.e. if your 300+ libs use spring-2.0 and your current project uses spring-3.1.0, both will be included anyway. So to avoid conflicts, it's recommended to configure this plugin to move spring-2.0 packages under a different package.

UPDATE 2

If your jars are not mavenized, Maven won't be a big help here. You should probably merge your jars manually and check if it works for you: Merging Multiple Jars in to a Single Jar.

Community
  • 1
  • 1
Andrey Chaschev
  • 16,160
  • 5
  • 51
  • 68
  • Yeah, but first I need import to repository all 300+ .jar's, right? Seems stupid. – Андрей Крюков Nov 18 '13 at 16:19
  • Just to clarify - your 300+ will be automatically copied into your local repo when your newly created dependency is resolved. – Andrey Chaschev Nov 18 '13 at 17:09
  • Guys, thank to answers, but I still don't understand how i can use this addon. For create uber-jar I need include all dependensy which I want repack to this jar. But i haven't it in my repo, it just a files... and I need avoid installing each of them to repository. Maybe my english so bad, or I just can't understand how this addon can help me. – Андрей Крюков Nov 19 '13 at 11:09
  • If these jars are not Maven artifacts if these are just 300 .jar files lying in your directory, it's a completely different and a difficult problem. Maven won't help you here to create an uber-jar. You probably should merge the jars manually and check if it works for you or stay with what you have at the moment... Anyway, you may try installing your jars to your local repo in this fashion: http://stackoverflow.com/a/19181610/1851024. – Andrey Chaschev Nov 19 '13 at 11:21
  • Updated the answer - your best option might be to merge your jars manually: http://stackoverflow.com/questions/882204/merging-multiple-jars-in-to-a-single-jar. – Andrey Chaschev Nov 19 '13 at 11:28