Maven的帮助文档ー查看各个插件的作用--- 【maven-assembly-plugin】

■前言

如果百度资料比较少,可以直接查看帮助文档

比如,今天遇到的 【maven-assembly-plugin

可用生成zip文件。

 

■可以百度到的内容总结

https://blog.csdn.net/sxzlc/article/details/107529169

 

■帮助文档maven-assembly-plugin

http://maven.apache.org/plugins/maven-assembly-plugin/

 

■帮助文档 【plugin

点击第一列即可查看

(下面第四张图,Tools 中 黄色背景色标记的部分)

===

===

 

===

Tools

---

■标签介绍页面

http://maven.apache.org/plugins/maven-assembly-plugin/

↓点击背景色黄色,标记的部分进入

■标签中的各个属性

 

http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

 

■zip 例

http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html

assembly.xml

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
  <id>project</id>
  <formats>
    <format>tar.gz</format>
    <format>tar.bz2</format>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <outputDirectory></outputDirectory>
      <useDefaultExcludes>true</useDefaultExcludes>
      <excludes>
        <exclude>**/*.log</exclude>
        <exclude>**/${project.build.directory}/**</exclude>
      </excludes>
    </fileSet>
  </fileSets>
</assembly>

 

===

pom.xml

<project>
  <groupId>your.group.id</groupId>
  <artifactId>my-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <modelVersion>4.0.0</modelVersion>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.3.0</version>
        <dependencies>
          <dependency>
            <groupId>your.group.id</groupId>
            <artifactId>my-assembly-descriptor</artifactId>
            <version>1.0-SNAPSHOT</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>


            <configuration>
              <fileName>delply</fileName>

              <!-- This is where we use our shared assembly descriptor -->
              <descriptorRefs>
                <descriptorRef>myassembly</descriptorRef>
              </descriptorRefs>

              <descriptor>assembly.xml</descriptor>
            </configuration>


          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

===

■其他 例

http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <filters>
            <filter>src/assembly/filter.properties</filter>
          </filters>
          <descriptors>
            <descriptor>src/assembly/distribution.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>
   [...]
</project>

===

The Assembly Descriptor

Filtering is only enabled inside <files> so that's what we will use. Thus, our assembly descriptor will be:

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
  <id>distribution</id>
  <formats>
    <format>jar</format>
  </formats>
  <files>
    <file>
      <source>README.txt</source>
      <outputDirectory></outputDirectory>
      <filtered>true</filtered>
    </file>
    <file>
      <source>LICENSE.txt</source>
      <outputDirectory></outputDirectory>
    </file>
    <file>
      <source>NOTICE.txt</source>
      <outputDirectory></outputDirectory>
      <filtered>true</filtered>
    </file>
  </files>
</assembly>

===

===

The above descriptor tells the Assembly Plugin to filter both the README.txt and the NOTICE.txt files and to just copy the LICENSE.txt file.

Alternatively, if there are many .txt files to include inside <files>, we can setup both <fileSets> and <files> like so:

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
  <id>distribution</id>
  <formats>
    <format>jar</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>${basedir}</directory>
      <includes>
        <include>*.txt</include>
      </includes>
      <excludes>
        <exclude>README.txt</exclude>
        <exclude>NOTICE.txt</exclude>
      </excludes>
    </fileSet>
  </fileSets>
  <files>
    <file>
      <source>README.txt</source>
      <outputDirectory></outputDirectory>
      <filtered>true</filtered>
    </file>
    <file>
      <source>NOTICE.txt</source>
      <outputDirectory></outputDirectory>
      <filtered>true</filtered>
    </file>
  </files>
</assembly>

===

■ 例子 中文版本

http://www.voidcn.com/article/p-pqqplemi-zk.html

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值