Maven 程序集忽略依赖工件的 FinalName

发布于 2024-09-19 00:11:28 字数 1066 浏览 12 评论 0原文

我有一个分层的 Maven 项目,我试图从中构建几个子模块的本机安装程序。我在父 POM 中使用我的产品名称作为前缀:xyz-${artifactId},以便我的所有工件 jar 都具有标准命名约定。

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-assemble-plugin,然后在我的 inno 设置中使用类似以下内容:

Source: "target\pkg\lib\*.jar"; DestDir: "{app}\external";  Flags: ignoreversion;

当我运行 mvn clean package 时,我得到一个 target /xyz-app1-bin/xyz-app1/lib 目录包含所有依赖的 jar,但是我的兄弟项目生成的 jar 都没有正确的最终名称(例如,我有 util-0.0.1)。 1-SNAPSHOT.jar 而不是 xyz-util.jar

此问题看起来类似于 这篇文章,但我不知道“attach”是什么(可能已弃用)。

I have a hierarchical maven project, from which I am trying to build a native installer for several of the sub-modules. I am using my product name as a prefix: <finalName>xyz-${artifactId}</finalName> in the parent POM so that all my artifact jars have a standard naming convention.

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"
      ...

I need to materialize all the dependent jars into a directory (since inno setup knows nothing about maven). So for each submodule which is an installer I plan to use maven-assembly-plugin, then use something like the following in my inno setup:

Source: "target\pkg\lib\*.jar"; DestDir: "{app}\external";  Flags: ignoreversion;

When I run mvn clean package, I get a target/xyz-app1-bin/xyz-app1/lib directory with all of the dependent jars, however none of the jars produced by my sibling projects have their correct final names (e.g. I have util-0.0.1-SNAPSHOT.jar instead of xyz-util.jar)

This problem seems similar to this post, but I have no idea what "attach" is (perhaps deprecated).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱你不解释 2024-09-26 00:11:29

我无法直接使用 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>

I was unable to use finalName directly, however, I did manage to re-implement the finalName logic I wanted using dependency sets -- thus partitioning my dependencies into an external and internal set (based on the 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>
一个人的旅程 2024-09-26 00:11:29

您应该能够直接使用 FinalName (这对我有用):

<outputFileNameMapping>
    ${artifact.build.finalName}.${artifact.extension}
</outputFileNameMapping>

You should be able to use finalName directly using (this worked for me) :

<outputFileNameMapping>
    ${artifact.build.finalName}.${artifact.extension}
</outputFileNameMapping>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文