Introduction to maven-jar-plugin configuration
Recently, I learned the springboot multi-module jar package deployment project, and used the maven-jar-plugin plug-in. I'll study it carefully. I won't say much nonsense. Look down.
The maven plug-in functions: compile, package, deploy... are all in the ${project. build. directory}/ classes file path, and the test is operated under test-classes, as shown in the figure:
This makes it easy for us to understand maven packaged plug-ins.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.2</version> <configuration> <archive> <!-- File --> <addMavenDescriptor/> <!-- Add to maven Description is META-INF Lower maven Folder --> <compress/> <!-- compress --> <forced/> <!-- Is it mandatory to reconstruct archives? --> <index/> <!-- Does the created archive contain INDEX.LIST file --> <manifest> <!-- Configuration List( MANIFEST)--> <addClasspath/> <!-- Whether to create Class-Path List entry--> <addDefaultImplementationEntries/> <addDefaultSpecificationEntries/> <addExtensions/> <classpathLayoutType/> <classpathMavenRepositoryLayout/> <classpathPrefix/> <!-- classpath prefix --> <customClasspathLayout/> <mainClass/> <!-- Program main function entry --> <packageName/> <!-- Package name --> <useUniqueVersions/> <!-- Use Unique Version --> </manifest> <manifestEntries> <!-- Configuration List( MANIFEST)attribute --> <key>value</key> </manifestEntries> <manifestFile/> <!-- MANIFEST file location --> <manifestSections> <manifestSection> <name/> <manifestEntries> <key>value</key> </manifestEntries> <manifestSection/> </manifestSections> <pomPropertiesFile/> </archive> <excludes> <!-- Filter out unwanted inclusions jar Documents in --> <exclude/> </excludes> <includes> <!-- Add files to jar Documents in --> <include/> </includes> </configuration> </plugin>
Interested can go to the official website to add, I listed a number of possible uses
Two, actual combat
This plug-in is used to specify the configuration in the MANIFEST.MF file in the jar package generated by this project, such as Class-Path and Main-Class, commonly used configurations:
Add dependency
Parent:
Sub level:
Execute maven packaging and target generates jar files as follows:
Copy to the desktop and open it with WinRAR. The directory is as follows:
The MANIFEST.MF file is in the folder marked red above.
The above packing method has not yet generated the dependent jar files needed for running, so the next one will follow. This time is mainly to generate the jar file and MANIFEST.MF file of this sub-project. Project information is as follows: