我正在尝试使用 Maven 构建一个独立的应用程序
使用描述的程序集插件 How do you create a standalone application with dependencies intact using Maven?
这将创建小部件分发 zip 包含
widget-1.0
widget-1.0/lib/widget.jar
widget-1.0/lib/3rdpartyjar1.jar
widget-1.0/lib/3rdpartyjar2.jar
...
但在我的 src 树中我有:
src/main/bin/widget.sh
这并没有进入最终的发行版 zip,我希望它放在这里
widget-1.0/widget.sh
在我的 src 树中,我还有一个属性文件
src/main/properties/widget.properties
目前正在进入
widget-1.0/lib/widget.jar
但因为我希望它是可编辑的,所以我希望它在
widget-1.0/widget.properties
是否可以在 maven 中做到这一点?
编辑 使用博客中的信息如下:
- 将 bin 文件夹重命名为 scripts 文件夹,因为这是标准 Maven 名称
- 将 widget.properties 移到脚本文件夹中
- 修改了我的 assembly.xml 以包含一个文件集
这是新的 xml
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.scriptSourceDirectory}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>widget.sh</include>
<include>widget.properties</include>
</includes>
</fileSet>
</fileSets>
</assembly>
但是小问题但无法在任何地方找到 maven 标准文件夹变量的列表,即属性文件夹是否有 ${project.build.scriptSourceDirectory} 的等价物
最佳答案
我找到了 this blog post成为如何做到这一点的好教程。
另外,我认为您放置文件的文件夹的名称是相关的。 Maven 显然对 src/main/java
中的文件和 src/main/resources
中的文件做不同的事情。我不是 100% 确定,但这个文件夹的名称可能意味着文件是否在 jar 中结束。
Here是 Maven 目录名称属性的列表。
关于java - 如何创建一个包含 shell 脚本和不在 jar 中的属性文件的 maven 程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11631682/