在汇编期间从依赖项中删除文件夹层次结构

时间:2016-06-21 14:43:15

标签: maven maven-assembly-plugin

我尝试为包含tomcat的产品创建构建。 tomcat文件夹结构应位于已汇编的zip文件的根目录下。但实际上我有一个文件夹层次结构太多了。

我的pom.xml

...

<dependencies>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat</artifactId>
        <version>8.5.3</version>
        <type>zip</type>
    </dependency>
</dependencies>

...

<build>     
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/bin.xml</descriptor>                       
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

...

src/assembly/bin.xml

<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>bin</id>

  <formats>
      <format>zip</format>      
  </formats>

  <dependencySets>      
      <dependencySet>                               
          <includes>
             <include>org.apache.tomcat:tomcat:zip</include>
          </includes>
          <outputDirectory>.</outputDirectory>
          <unpack>true</unpack>
          <useProjectArtifact>false</useProjectArtifact>
      </dependencySet>
  </dependencySets>

</assembly>

引用的zip的结构如下:

apache-tomcat-8.5.3
├── LICENSE
├── NOTICE
├── RELEASE-NOTES
├── RUNNING.txt
├── bin
├── conf
├── lib
├── logs
├── temp
├── webapps
└── work

我的结果(bin.zip)应如下所示:

bin
├── LICENSE
├── NOTICE
├── RELEASE-NOTES
├── RUNNING.txt
├── bin
├── conf
├── lib
├── logs
├── temp
├── webapps
└── work

但实际上它看起来像这样:

bin
└─ apache-tomcat-8.5.3
   ├── LICENSE
   ├── NOTICE
   ├── RELEASE-NOTES
   ├── RUNNING.txt
   ├── bin
   ├── conf
   ├── lib
   ├── logs
   ├── temp
   ├── webapps
   └── work

最后我的问题是:

如何在apache-tomcat-8.5.3目标期间删除assembly:single文件夹?

tomcat依赖只是一个例子。我还有很多案例。

0 个答案:

没有答案