In a large multi module maven project we collect test jars from 30 modules to create a customer-test jar. We exclude the tests, keeping only the utility classes supporting tests.
I want to make the equivalent source jar but don't want to violate DRY (don't-repeat-yourself) by cutting and pasting my dependency unpack execution.
Baring refactoring the test utility classes into their own module (which probably stands as the best option for packaging but perhaps a less good option for on going development) what approach do you think makes sense?
My guess is that I should move away from maven-dependency-plugin + antrun-plugin to use an assembly where I pass in the classifier and include ending (class vs java). I wanted to check to see if someone had a better solution. If not, I'll post my solution upon completion.
Again, I realize that refactoring the test support routines into their own module is probably the superior option and I may follow that route.
Unpack Execution
<execution>
<id>dist profile: unpack classes for core-app-tests</id>
<phase>prepare-package</phase>
<goals><goal>unpack</goal></goals>
<configuration>
<overWrite>true</overWrite>
<outputDirectory>${coreAppTestClassDir}</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>...platform</groupId>
<artifactId>app</artifactId>
<classifier>tests</classifier>
</artifactItem>
...
Vetting/Re-assmble via antrun
<execution>
<id>dist profile: Finalizing ${baseName} kit files</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="ise/antelope/tasks/antlib.xml"
classpathref="maven.plugin.classpath"/>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<delete>
<fileset dir="${coreAppTestClassDir}">
<include name="**/*Test.class"/>
<include name="**/*Test$*.class"/>
<include name="**/*java"/>
<include name="org/**"/>
</fileset>
</delete>
<jar destfile="${project.build.directory}/kit/sdk/lib-test/core-app-tests.jar" includes="**/*.class" excludes="org/**,META-INF/**" manifest="${project.build.directory}/classes/META-INF/MANIFEST.MF" >
<fileset dir="${coreAppTestClassDir}"/>
</jar>
...
If jar creation happens in its own module (which is should given the one-module-one-thing favored approach) this works:
The result is a classes and sources directory which can be collected via assembly plugin.