Suppose I have a war and jar projects defined in maven.
The Jar project is dependent on the War project
I have managed to get this working in package mode by adding
In the war project <attachClasses> to true in the war plugin.
And making a dependency to
<groupId>com</groupId>
<artifactId>oneway-delegator</artifactId>
<version>1.0</version>
<classifier>classses</classifier>
in the jar pom.
But when running only compile the classes jar is not created and everything fails.
Any ideas folks ??
You can indeed configure the maven-war-plugin to package/deploy the classes and resources included in your webapp as an “attached” JAR artifact with a classifier with the following configuration:
But this artifact is created during the
packagephase so don’t expect it to be there if you runcompileonly.Note that this configuration option has been introduced for a very particular use case, the skinny war use case. If you need to re-use this JAR in another project the recommended approach is in general to move the classes to a separate module that builds a JAR, and then declare a dependency on that JAR from your webapp as well as from any other projects that need it.