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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With