我有一个分层maven项目,我正在尝试为几个子模块构建一个本机安装程序。我在父POM中使用我的产品名称作为前缀:<finalName>xyz-${artifactId}</finalName>
,以便我的所有工件罐都有一个标准的命名约定。
xyz-parent
+-- util
+--- target/xyz-util.jar
+-- core
+--- target/xyz-core.jar
+-- app1 <--- "builds an installer as part of the package phase"
+--- target/xyz-app1.jar
+-- app2 <--- "builds an installer as part of the package phase"
...
我需要将所有依赖的jar实现到一个目录中(因为inno setup对maven一无所知)。因此,对于作为安装程序的每个子模块,我计划使用maven-assembly-plugin,然后在我的inno设置中使用以下内容:
Source: "target\pkg\lib\*.jar"; DestDir: "{app}\external"; Flags: ignoreversion;
当我运行mvn clean package
时,我得到一个包含所有相关jar的target/xyz-app1-bin/xyz-app1/lib
目录,但是我的兄弟项目产生的罐子都没有正确的最终名称(例如我有{{1}而不是util-0.0.1-SNAPSHOT.jar
)
此问题与this post类似,但我不知道“附加”是什么(可能已弃用)。
答案 0 :(得分:3)
我无法直接使用finalName,但是,我确实设法使用依赖集重新实现我想要的finalName逻辑 - 从而将我的依赖项分区为外部和内部集合(基于groupId):
<assembly>
<id>bin</id>
<formats>
<format>dir</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>external</outputDirectory>
<outputFileNameMapping>
${artifact.artifactId}.${artifact.extension}
</outputFileNameMapping>
<excludes>
<exclude>com.xyz:*</exclude>
</excludes>
</dependencySet>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<outputFileNameMapping>
xyz-${artifact.artifactId}.${artifact.extension}
</outputFileNameMapping>
<includes>
<include>com.xyz:*</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
答案 1 :(得分:1)
您应该能够直接使用finalName(这对我有用):
<outputFileNameMapping>
${artifact.build.finalName}.${artifact.extension}
</outputFileNameMapping>