我想用Maven打包一個Web應用程序作爲可運行的JAR文件。 jar -with-dependencies assembly照顧包括所有依賴項,但我仍然需要包含src/main/webapp。如何使用Maven將目錄添加到JAR文件中?
我設法目錄使用自定義組件添加到我的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-與依賴性。但是,最終的JAR包含webapp目錄和所有依賴項,但不包含我的項目的類文件。我的大會顯然是刪除它們。
我可以在程序集中保留我自己項目的類文件嗎?或者有另一種方法將目錄添加到JAR中?