Reputation: 753
I got two maven projects, P1 requires P2's java-sources at compile time. So, I have included sources in the P2's jar, to be included as dependency in P1's pom. How do I exclude those .java files from final war creation?
Or, is there a better way to package P1's jar?
Upvotes: 1
Views: 100
Reputation: 44545
A better way would be to create and deploy a separate JAR with sources for P2 and add this as a dependency for the GWT compile in P1.
For the sources JAR have a look at the maven-sources-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
If you add this in the build section of your POM, the build will create a separate JAR with the classifier 'sources'.
You can then add this artifact to the maven GWT compiler plugin as dependency:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<compileSourcesArtifacts>
<compileSourcesArtifact>your.groupId:artifactId</compileSourcesArtifact>
</compileSourcesArtifacts>
</plugin>
Upvotes: 1