0

I have a maven project which uses the shade plugin to create a jar from several projects.

In addition it is possible with this plugin to create a source jar from these several projects.

For legacy reason we need to have one jar which contains classes and sources, so the combination of the two jars created by the shade plugin.

What is the best way (preferable in maven) to merge these two jars ?

I found the One-Jar but this apparently combines all dependencies - but I want to explictly say "merge this jar and that jar".

Thanks for any help

Emerson
  • 1,327
  • 2
  • 15
  • 24
  • [This similar question](http://stackoverflow.com/questions/1895537/how-to-merge-module-jars-to-a-single-jar-in-maven2) might help –  Mar 01 '13 at 06:01

2 Answers2

1

One possibility is to use the maven assembly plugin to create a single jar specifying and if required, maven dependency plugin.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • 3
    The shade plugin is _much_ more advanced then the assembly plugin. Is this really still the best answer? – Gray Feb 28 '13 at 22:54
  • @Gray I can't see that answer any more, but if you write one, I think it will be useful. – peterh Oct 09 '17 at 15:50
0

A simpler way is to tell maven that the source folder is also a resource folder.

Like this :

  <build>
   ...
    <resources>
        <resource>
            <directory>src/main/java</directory>
        </resource>
    </resources>
  ...
  </build>
lforet
  • 16
  • 2