The
Describes how to use the assembly package configuration file before, and here's how to package the entire project into a single executable jar. During system testing, a separate jar is required to test with the other integration team. For the first time, the jar package was chosen with assembly plugin, because our test program was inside Src/test/java, and assembly could automatically pack the test package and test dependencies, as follows:
1. Create Package Test Class and Test dependency's assembly configuration file Package.xml in src/main/resources/assembly/:
<assembly xmlns= "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi= "http:// Www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/plugins/maven-assembly-plugin/ assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd "> <id>test-executable</id> <forma ts> <format>jar</format> </formats> <includebasedirectory>false</includebase directory> <dependencySets> <dependencySet> <outputdirectory>/</outputdire Ctory> <useProjectArtifact>true</useProjectArtifact> *<unpack>true</unpack > <scope>test</scope>* </dependencySet> </dependencySets> <files
Ets> <fileSet> <directory>${project.build.directory}/classes</directory> <outputdirectory>/</outputdirectory> <includes> <include>**/*</include> </INCLUDES&G
T <useDefaultExcludes>true</useDefaultExcludes> </fileSet> <fileSet> ;d irectory>${project.build.directory}/test-classes</directory> <outputdirectory>/</outputdir
ectory> <includes> <include>**/*</include> </includes> <useDefaultExcludes>true</useDefaultExcludes> </fileSet> </fileSets> </ Assembly>
To create a Maven-assembly-plugin package configuration:
<plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2 .3</version> <configuration> <descriptor>src/main/resources, assembly
/package.xml</descriptor> </configuration> <executions> <execution> <id>make-package</id> <phase>packa
Ge</phase> <goals> <goal>single</goal>
</goals> <configuration> <archive> <manifest> <!--main class--> <mainclas S>com.cloud ..... Publishertest</mainclass> </manifest> </archive
> </configuration> </execution> </executions> </plugin>
After executing maven package, there will be *-test-executable.jar in target folder containing all the required class files. This packaging is problematic, however, because a file assembly with the same name will be ignored directly, and for spring-related jars, XSD files are saved in Meta-inf (Meta-inf/spring.handlers and meta-inf/ Spring.schemas), so packing can cause many XSD to be unresolved without a network, and the following questions are reported:
Unable to locate Namespacehandler when using * * *
This time you will need to use Maven-shade-plugin, as described in the next article.