Tomcat Maven:将zip工件解压缩到特定的文件夹名称

Tomcat Maven:将zip工件解压缩到特定的文件夹名称,tomcat,maven,unpack,maven-dependency-plugin,Tomcat,Maven,Unpack,Maven Dependency Plugin,我正在尝试下载tomcat zip工件,并将其解压缩到一个名为tomcat的文件夹中。 我得到的是tomcat/apache-tomcat-7.0.19/ 我怎样才能摆脱恼人的中间目录 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4&

我正在尝试下载tomcat zip工件,并将其解压缩到一个名为tomcat的文件夹中。 我得到的是tomcat/apache-tomcat-7.0.19/ 我怎样才能摆脱恼人的中间目录

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
    <execution>
        <id>unpack-tomcat</id>
        <phase>process-sources</phase>
        <goals>
            <goal>unpack</goal>
        </goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>org.apache</groupId>
                    <artifactId>tomcat</artifactId>
                    <version>7.0.19-win64</version>
                    <type>zip</type>
                    <overWrite>false</overWrite>
                    <outputDirectory>tomcat</outputDirectory>
                    <excludes>webapps/**</excludes>
                </artifactItem>
            </artifactItems>                            
        </configuration>
    </execution>
</executions>
</plugin>

org.apache.maven.plugins
maven依赖插件
2.4
打开tomcat的包
过程源
打开
org.apache
雄猫
7.0.19-win64
拉链
假的
雄猫
网络应用/**
使用目标并将useSubDirectoryPerArtifact设置为false。

也许有更多的“mavenish”方法来实现我的建议:)但是使用maven ant插件可能是解决您的情况的一种变通方法:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target>
                                <move file   = "tomcat/apache-tomcat-7.0.19/*"
                                      tofile = "tomcat" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target>
                                <delete dir = "tomcat/apache-tomcat-7.0.19"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
</plugin>

maven antrun插件
1.7
包裹
跑
包裹
跑

maven使用平面路径解包

:

绝对没有办法(我在写这篇博文时就知道了) 让这个maven插件吐出一个平面结构

因此,一个好的替代方法是使用 允许用户将
true
指定为 为了在没有负担的情况下获得所需的文件 从工件根开始的相对路径包括为 嗯


文档指出,该插件还能够将压缩后的maven工件中的任意相对路径解压缩到特定的目标文件夹。

我无法管理它工作。现在它给我带来了我得到的所有依赖项,而不仅仅是tomcat。在pom中插件声明的配置部分下,添加tomcatI发布了整个pom插件代码。这对我仍然不起作用。只需创建嵌套目录这绝对不起作用,并且根据手册,useSubDirectoryPerArtifact在默认情况下被设置为false。@marcv81当OP可以将其设置为默认值以外的值时,默认值没有多大意义。直到我发布了我的答案,OP才发布他的POM。请考虑更温和一点。该插件可能无法在Maven 3.6中工作,如issues.apache.org/jira/browse/JS2-1366所述。