0

What is the best way to add project in Maven Central repository if it uses jar-file and web-resources (js, css, images)?

I can't find any good way to do it so users could add dependency in pom.xml and get all required files (not only jar-file).

I found WebJars project, but it looks a little compicated and requires additional steps (adding and configuring webjars maven plugin before getting my project).

It would be useful to have another project with similar structure.

Thanks for your help!

radyno
  • 26
  • 3
  • Do you need to be able to depend on the artifacts (the jar, js, css, image, etc) independently or do they always come as a complete package? – Nick Holt Jun 07 '13 at 13:47
  • Usually as complete package. jar-file includes classes which generate html/js code. This code uses some js-library, css-files and images. So I would like to distribute them as a complete package. – radyno Jun 07 '13 at 14:01

1 Answers1

0

OK - if you want to distrubute a webapp as a complete package the most common thing to do is package your application as a WAR.

To do this you just need to add the following to your pom:

<packaging>war</packaging>

Don't forget to ensure that your project conforms to the layout specified by the Maven WAR Plugin.

Once you have your WAR deployed, other WAR projects can depend on it which produce a single WAR that is a combination of the two.

If you need something a little more complicated look at using the Maven Assembly Plugin that allows you to create custom archives. As with the WAR, other assembly projects can depend on it, though as the unpacking is in your hands there is again an increase level of complexity.

Nick Holt
  • 33,455
  • 4
  • 52
  • 58
  • So it looks like there is no easy way to distribute jar and js/css/images in one package using maven central repository. Thaks for your answer! – radyno Jun 07 '13 at 14:45
  • Yes, you put them all in the war. If you want to keep them separately you need to create a custom Maven lifecycle writing MOJOs as described here - http://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html – Nick Holt Jun 07 '13 at 14:56