Reputation: 1902
I have gone through the documentation, but still not able to achieve what I am trying to. The requirement is very simple. I have two maven projects. ProjectA and ProjectB. ProjectB requires to reuse some common configs and code from ProjectA. I don't want to just copy and paste them as this is will require to updates if anything changes. So, what are the options now? How can I achieve this?
Upvotes: 0
Views: 50
Reputation: 1902
I created a multi module maven project but it was always compiling that the packages not found. Eventually, I figured out the issue here. Maven Multi-module dependency package not found
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
Upvotes: 0
Reputation: 3031
I don't think there is a silver bullet for this but we use combination of these two aproaches:
Upvotes: 1
Reputation: 544
You might have two options.
Use your ProjectA has parent of your projectB
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<parent>
<groupId>com.example</groupId>
<artifactId>projectA</artifactId>
<version>1.0</version>
</parent>
<artifactId>projectB</artifactId>
Thus, your projectB will inherit from the first one, with all its dependencies build / dependency management.
Use your ProjectA has dependency of your projectB
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<artifactId>projectB</artifactId>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>projectA</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
In this case, projectB wil inherit from projectA all the sources and dependencies.
Upvotes: 1