Reputation: 51
I have two different maven modules in a project, one is ui module with angular js stuff and one services module which has restful web services with jersey. My question here is, Is there anyway i can add this services module as dependency to ui module in the pom.xml and use it from ui module as a service. Idea here is to not deploy both as different wars, but as one.
Upvotes: 5
Views: 1078
Reputation: 8798
You can generate your services module as JAR. pom.xml should contain:
<packaging>jar</packaging>
And
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Create libs folder in your main project and place there generated JAR file. Main project pom.xml should contain:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${basedir}/libs/your_service.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>your_service</groupId>
<artifactId>your_service</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
And
<!-- External lib -->
<dependency>
<groupId>your_service</groupId>
<artifactId>your_service</artifactId>
<version>1.0</version>
<!-- <systemPath>${basedir}/libs/your_service.jar</systemPath> -->
<!-- <scope>system</scope> -->
</dependency>
Upvotes: 1
Reputation: 10132
This is what I have done in my few projects,
1.First create a blank project which acts as a container/parent for both UI and Services components/projects using modules
tag. You specify both module
in it. You can call it APP.
To build your project, you build APP which in turns builds both modules and you deploy APP to server.
This is just a blank Maven project with only a pom.xml
Specify packaging
as war
in pom.xml
2.Specify service project as dependency
to UI project.
3.Specify APP project as parent
in both of service as well as UI project.
Hope this helps !!
Upvotes: 0