In order to optimize the need, I need to look at my Maven project (a Java service) how to package the project into a tar.gz package, the various files in the GZ package.
That said, I need to know how MAVEN is putting projects from this:
To become this:
My project is to have a parent module three sub-modules of the Java service, with Maven to manage related dependencies.
The MVN package commands the GZ pack with apps, Bin, Conf, Lib four folders:
There's a bunch of scripts in the bin that start, stop, and so on. What I want to figure out is actually how the script is generated, and now the optimization project that is encountered needs to adjust the startup script. Conf is a bunch of configuration files. Lib is all the relevant jar packages.
Explore the process
A, pom file
In the parent module's pom file, I found the package plugin for Maven:
<plugin>
<groupId>com.dangdang</groupId>
<artifactid>dd-assembly-plugin</ artifactid>
<version>2.0.1</version>
</plugin>
In the Submodule Tms-bms-bootstrap's pom file, I found the code that uses the parent module to package the plug-in:
<plugin>
<groupId>com.dangdang</groupId>
<artifactid>dd-assembly-plugin</ artifactid>
<executions>
<execution>
<phase>package</phase>
< goals>
<goal>assembly</goal>
</goals>
</execution>
</executions >
</plugin>
two, maven package plugin
In my local Maven repository, the path consists of the GroupID, Artifactid, and version configured in the Pom file: com\dangdang\dd-assembly-plugin\ 2.0.1 found the Dd-assembly-plugin-2.0.1.jar.
Dd-assembly-plugin-2.0.1.jar is Maven's packaged plugin, not the same name as MAVEN's own packaged plug-in, because this is a corporate framework that has been changed on that basis, and this jar package is structured like this:
third, package plug-in configuration file
The
has dd-frame-assemby.xml in the assemblies directory (not necessarily the name), is a packaged profile that describes what Maven will do when it is packaged, and is the key configuration for MAVEN's packaged plug-in, which reads as follows:
<assembly xmlns= "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi= "http// Www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://maven.apache.org/plugins/maven-assembly-plugin/ assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd "> <id>assembly</id > <formats> <format>tar.gz</format> </formats> <includeBaseDirectory> true</includebasedirectory> <fileSets> <fileSet> <directory>classpath:asse Mblies/bin/properties/jmx_config</directory> <outputdirectory>bin/properties/jmx_config</output Directory> <includes> <include>jmxremote.password</include> &
lt;/includes> <fileMode>0600</fileMode> </fileSet> <fileSet> <directory>classpath:assemblieS/bin</directory> <outputDirectory>bin</outputDirectory> <filemode>0755< ;/filemode> </fileSet> <fileSet> <directory>classpath:assemblies/app</ Directory> <outputDirectory>app</outputDirectory> <filemode>0644</filemode > </fileSet> <fileSet> <directory>classpath:assemblies/conf</directory
> <outputDirectory>conf</outputDirectory> <fileMode>0644</fileMode>
</fileSet> <fileSet> <directory>src/main/resources/conf</directory> <includes> <include>*.properties</include> <include>*/*.pro
Perties</include> <include>logback.xml</include> </includes>
<excludes> <exclude>*.private.properties</exclude> <exclude>*/*.private.properties</ Exclude> </excludes> <outputDirectory>conf</outputDirectory> < filemode>0644</filemode> </fileSet> </fileSets> <dependencySets> & lt;! --Copy all dd-frame and third party jars to Lib folder. -<dependencySet> <outputDirectory>lib</outputDirectory> <exclud Es> <exclude>com.dangdang:*</exclude> <exclude>com.dang:*</exclude > </excludes> </dependencySet> <dependencySet> <outputdire Ctory>lib</outputdirectory> <includes> <INCLUDE>COM.DANGDANG:APIMONITOR&L T;/include> <include>com.dangdang:ddschedule</include>
<include>com.dangdang:dd-assembly-plugin</include> <include>com.dangdan G:dd-common</include> <include>com.dangdang:dd-container</include> <i
Nclude>com.dangdang:dd-soa</include> <include>com.dangdang:dd-job</include> <include>com.dangdang:dd-job-tbschedule</include> <include>com.dangdang:dd-rdb< ;/include> <include>com.dangdang:dd-reg</include> <include>com.dangda Ng:dd-log</include> <include>com.dangdang:dd-web</include> <INCLUDE&G
T;com.dangdang:dd-test</include> <include>com.dangdang:dd-package</include> <include>com.dangdang:elastic-job-core</include> <include>com.dangdang:elastic-job-s
Pring</include> </includes> <fileMode>0644</fileMode> </dependencySet> <!--copy all Dangdang jars to app folder. -<dependencySet> <outputDirectory>app</outputDirectory> <includ Es> <include>com.dangdang:*</include> <include>com.dang:*</include > </includes> <excludes> <exclude>com.dangdang:apimonitor< /exclude> <exclude>com.dangdang:ddschedule</exclude> <exclude>com.dan
Gdang:dd-assembly-plugin</exclude> <exclude>com.dangdang:dd-common</exclude> <exclude>com.dangdang:dd-container</exclude> <EXCLUDE>COM.DANGDANG:DD-SOA</EXCLU De> <exclude>com.dangdang:dd-job</exclude> <exClude>com.dangdang:dd-job-tbschedule</exclude> <exclude>com.dangdang:dd-rdb</exclude> <exclude>com.dangdang:dd-reg</exclude> <exclude>com.dangdang:dd-log< /exclude> <exclude>com.dangdang:dd-web</exclude> <exclude>com.dangdan G:dd-test</exclude> <exclude>com.dangdang:dd-package</exclude> <EXCLU De>com.dangdang:elastic-job-core</exclude> <exclude>com.dangdang:elastic-job-spring</exc
lude> </excludes> <fileMode>0644</fileMode> </dependencySet> <!--Copy all Dangdang jar ' s ' *.properties ' and Profiles's ' *.properties ' to conf folder, E
Xclude ' *.private.properties '. -<dependencySet> <includes> <include>com.dangdaNg:*</include> <include>com.dang:*</include> </includes> & Lt;excludes> <exclude>com.dangdang:apimonitor</exclude> <exclude>com.
Dangdang:ddschedule</exclude> <exclude>com.dangdang:dd-assembly-plugin</exclude> <exclude>com.dangdang:dd-common</exclude> <exclude>com.dangdang:dd-container< ;/exclude> <exclude>com.dangdang:dd-soa</exclude> <exclude>com.dangda Ng:dd-job</exclude> <exclude>com.dangdang:dd-job-tbschedule</exclude> &L
T;exclude>com.dangdang:dd-rdb</exclude> <exclude>com.dangdang:dd-reg</exclude> <exclude>com.dangdang:dd-log</exclude> <exclude>com.dangdang:dd-web</exclud E> <exclude>com.dangdang:dd-test</exclude> <exclude>com.dangdang:dd-package</exclude> <exclude>com.dangdang:elastic-job-core</exclude> <exclude>com.dangdang:el Astic-job-spring</exclude> </excludes> <unpack>true</unpack> &
Lt;unpackoptions> <includes> <include>conf/*.properties</include> <include>conf/*/*.properties</include> <INCLUDE>CONF/LOGBACK.XM L</include> <include>conf/includedLogbackConfig.xml</include> </i
Ncludes> <excludes> <exclude>conf/*.private.properties</exclude>
<exclude>conf/*/*.private.properties</exclude> </excludes> </unpackoptions> <fileMode>0644</fileMode> </dependencySet> <!--If app Jar does not has Includedlogbackconfig.xml, copy default Includedlogbackconfig.xml to Conf folder.
For Ddframe the package is only. -<dependencySet> <includes> <include>com.dangdang:dd-log</i
nclude> </includes> <unpack>true</unpack> <unpackOptions>
<includes> <include>includedLogbackConfig.xml</include> </includes> </unpackOptions> <fileMode>0644</fileMode> < outputdirectory>conf/</outputdirectory> </dependencySet> </dependencySets> </assembly&
Gt
Some of the contents of this document are described below:
<formats> represents the packaged file format, and now writes a tar.gz that will generate a xxx.tar.gz compressed package and can be set to war or something. <fileSets> indicates what directories are under the package to be generated, what files are in the directory, and multiple directories can be represented by multiple <fileSet> tags. The <directory> in the <fileSets> tab indicates the directory from which to get the file, classpath:xxxx means to get the file from the packaged plug-in jar package, such as 20 rows of <directory> Classpath:assemblies/bin</directory> (The script in the boxed Bin directory comes from here, my purpose is reached), and the 35 line of <directory>src/main/ The resources/conf</directory> represents getting the file from the project path. The <includes> under the <fileSet> tab represents the opposite of those files that are packaged,<excludes> tags, which represent which files are ignored when packaged. The <outputDirectory> under the <fileSet> tab represents the name of the directory under the package that will be generated, such as the bin directory in the tar.gz package that is generated after packaging, which is set with this tag. <fileMode> under the <fileSet> tab may be directory permissions, I'm not sure. The <dependencySets> tag represents how the project's maven-dependent jar packages are handled, and where the jar packages will be placed in the target directory, multiple directories can be represented by multiple <dependencySet> tags. The <dependencySet> under <outputDirectory> function is the same as the label under <fileSet> with the same name, specifying the target path. The <dependencySet> under <includes> function is the same as the label under <fileSet>, specifying which jar packages will be placed in the target directory. The <dependencySet> under <excludes> function is the same as the label under <fileSet> with the same name, specifying which jar packages will be ignored.
The MAVEN package plugin's configuration file actually implements more functions, the user can configure themselves, I only study here, I can probably know when Maven packaged in accordance with what rules.