Reputation: 524
Ive two maven projects. Project A and Project B. B uses A as a dependency. When I build B as a war, Maven exports A and it's dependency. How to tell maven not to include this dependency tree alone while exporting? I cannot find excludes tag in maven war configuration.
Note: I cannot use provided scope in the dependency because I need it to test using embedded tomcat.
Snippet of Project B Pom
<dependencies>
<!-- Project A -->
<dependency>
<groupId>test</groupId>
<artifactId>test-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>80</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<!-- Exclude Tag is not available in configuration -->
</configuration>
</plugin>
</plugins>
Upvotes: 0
Views: 1396
Reputation: 524
I’ve finally decided to clone a branch in git and call it release branch. It’ll now have a different Pom i.e., scope of project A within B will be provided. After series of changes in the Dev branch, I’ll cherry pick it into release branch and build the jars. Also I believe this should be good for Jenkins (haven’t tested yet, but that’s next)
Upvotes: 0
Reputation: 3637
You need to create profiles, you can create two profiles, one for development (embedded tomcat, with dep A), and another for production (without the dep)
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<!-- dep A -->
</dependency>
</dependencies>
</profile>
<profile>
<id>prod</id>
<dependencies>
<dependency>
<!-- dep A -->
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
Upvotes: 1