我正在努力实现与here发布的问题相同的目标,即将war依赖集合到一个可部署的zip中,在最终的zip中包含war和一些解压缩的* .yml文件。我已经将war文件正确地组装到zip中,但是我无法获得maven-dependency-plugin来解压缩战争中的* .yml文件以进行重新打包。
为清楚起见,这就是我所拥有的:
这是我的插件声明的样子:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>myapp</groupId>
<artifactId>myapp-war</artifactId>
<type>war</type>
<outputDirectory>${project.build.directory}/unpack</outputDirectory>
<includes>**/*.yml</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
我还尝试过一种变体,我在<outputDirectory>
下面宣布<includes>
和<configuration>
,[INFO] Configured Artifact: myapp:myapp-war:?:war
[INFO] Unpacking /build/myapp-war/target/myapp-war-0.0.1-SNAPSHOT.war to /build/myapp-deploy/target/unpack with includes "**/*.yml" and excludes ""
[DEBUG] Found unArchiver by type: org.codehaus.plexus.archiver.zip.ZipUnArchiver$__sisu2@692a65b1
[DEBUG] Expanding: /build/myapp-war/target/myapp-war-0.0.1-SNAPSHOT.war into /build/myapp-deploy/target/unpack
[DEBUG] expand complete
允许这样做。
在任何一种情况下,我得到一个空的myapp-deploy / target / unpack文件夹,以及maven输出中的[INFO]和[DEBUG]消息说明:
{{1}}
maven似乎理解了我的指示,但似乎并没有像它声称的那样拆开包装。知道我做错了吗?
答案 0 :(得分:1)
创建* .war依赖项显然存在问题。它首先使用maven-war-plugin:war
创建,然后使用spring-boot-maven-plugin:repackage
重新打包。从命令行解压缩成功,但会产生警告:
$ unzip myapp-war-0.0.1-SNAPSHOT.war
Archive: myapp-war-0.0.1-SNAPSHOT.war
warning [myapp-war-0.0.1-SNAPSHOT.war]: 7318 extra bytes at beginning or within zipfile
如果我将spring-boot-maven-plugin:repackage
配置为禁用executable * nix启动脚本前置战争,maven-dependency-plugin:unpack
按预期工作:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>false</executable>
</configuration>
</plugin>