Reputation: 1845
I want to combine more than 3 maven projects (HTML, javascript and CSS based) into a single one. My main project uses dependencies from other projects. So, how can I build a single project without changing those dependencies?
Upvotes: 2
Views: 5347
Reputation: 35829
Let's say you have a multi module project with:
mysite
: a parent pom module.mysite-core
: a java modulemysite-web
: a web resources module (javascript, html, ...)mysite-webapp
: a war modulemysite
has packaging pom
and includes the other 3 modules
:
<groupId>mysite</groupId>
<artifactId>mysite</artifactId>
<packaging>pom</packaging>
<modules>
<module>../mysite-core</module>
<module>../mysite-web</module>
<module>../mysite-webapp</module>
</modules>
mysite-core
uses the standard jar packaging
:
<parent>
<artifactId>mysite</artifactId>
<groupId>mysite</groupId>
<relativePath>../mysite/</relativePath>
</parent>
<groupId>mysite</groupId>
<artifactId>mysite-core</artifactId>
mysite-web
is similar:
...
<artifactId>mysite-web</artifactId>
mysite-webapp
includes the java and the web resources module as a dependency:
...
<artifactId>mysite-webapp</artifactId>
<packaging>war</packaging>
<dependency>
<groupId>mysite</groupId>
<artifactId>mysite-core</artifactId>
</dependency>
<dependency>
<groupId>mysite</groupId>
<artifactId>mysite-web</artifactId>
</dependency>
With the overlays property from the maven-war-plugin, you add the resources to the war:
<overlays>
<overlay>
<groupId>mysite</groupId>
<artifactId>mysite-web</artifactId>
<type>jar</type>
</overlay>
</overlays>
Note: It is best to have a flat project layout, like:
instead of a hierarchical layout:
I've noticed that tools like Eclipse don't like hierarchical structures (slow or even endless builds).
Upvotes: 4
Reputation: 2003
Use Maven modules. There is extensive documentation here:
http://maven.apache.org/guides/mini/guide-multiple-modules.html
Upvotes: -1