java - How to create jar for Junit test class -
i following maven package structure.in project have class payloadprocessortest.java
, has dependencies
i want create jar file payloadprocessortest dependencies
can 1 please me create jar dependencies
<plugin> <artifactid>maven-assembly-plugin</artifactid> <version>2.2-beta-2</version> <executions> <execution> <id>create-test-dependency</id> <phase>process-test-classes</phase> <goals> <goal>single</goal> </goals> <configuration> <finalname>classloader-test-deps</finalname> <attach>false</attach> <descriptors> <descriptor>src/main/assembly/test-assembly.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin>
this content of test-assembly.xml
<assembly> <id>test-classloader</id> <formats> <format>jar</format> </formats> <includebasedirectory>false</includebasedirectory> <filesets> <fileset> <directory>${project.build.testoutputdirectory}</directory> <outputdirectory>/</outputdirectory> <!--modify/add include match package(s) --> <includes> <include>com/test/**</include> </includes> </fileset> </filesets> </assembly>
use maven plugin maven shade plugin. documentation said "this plugin provides capability package artifact in uber-jar"
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>2.2</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <createdependencyreducedpom>false</createdependencyreducedpom> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>meta-inf/*.sf</exclude> <exclude>meta-inf/*.dsa</exclude> <exclude>meta-inf/*.rsa</exclude> <exclude>.settings/**</exclude> <exclude>*.classpath</exclude> <exclude>*.project</exclude> <exclude>*.txt</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment