【发布时间】:2012-02-24 08:31:33
【问题描述】:
我正在尝试使用 Maven 将 Web 应用程序打包为可运行的 JAR 文件。 jar-with-dependencies 程序集负责包含所有依赖项,但我仍然需要包含 src/main/webapp。
我设法使用自定义程序集将目录添加到我的 JAR:
<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>webapp</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/webapp</directory>
<outputDirectory>/webapp</outputDirectory>
</fileSet>
</fileSets>
</assembly>
它确实有效,甚至可以将这个程序集与 jar-with-dependencies 一起使用。但是,最终的 JAR 包含 webapp 目录和所有依赖项,但不包含我项目的类文件。我的程序集显然正在删除它们。
我可以在程序集中保留我自己项目的类文件吗?还是有其他方法可以将目录添加到 JAR 中?
【问题讨论】: