`outputFileNameMapping` 使用运行插件的工件的名称而不是依赖项
我正在使用 maven-assemble-plugin
v.3.3.0,并在程序集文件中进行以下配置(模块名称为 example
):
pom 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-example</artifactId>
<groupId>com.mysite</groupId>
<version>see-jgitver</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>example</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>A</artifactId>
<version>${lib.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>B</artifactId>
<version>${lib.version}</version>
</dependency>
<dependencies>
程序集文件:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySet>
<unpack>false</unpack>
<includes>
<include>*:tar.gz</include>
</includes>
<outputFileNameMapping>${artifact.groupId}${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
(不确定 ${artifact.groupId}
属性是否正确。)
include 标记与工件 A
和 B
匹配。 我期待它们出现在最终的包中 A.tar.gz
和 B.tar.gz
。 相反,我得到了一个名为 example.tar.gz
的工件,
因此,artifact.artifactId
指的是正在运行插件的示例工件,而不是依赖项。这是预期的行为吗?我怎样才能实现我的目标?
附加信息(编辑):
你为什么喜欢使用outputFileNameMapping? 我试图了解它是如何使用的。在本例中,我有多个具有相同 artifactId(尽管 groupId 不同)的依赖项,因此将 groupId 添加到所有依赖项会很有用。
有什么问题吗? 虽然,这里有一个上下文,我试图通过这次编辑来澄清,但我认为我的问题非常简单。从 文档 我期待不同的行为。
为什么要更改输出目录? 我删除了该标签,因为它与本例无关。
为什么要包含在 tar.gz 中? 因此,有多个依赖项被加入到单个 tar 中。这不是我的项目,是一个更大的建设的一部分。
谢谢!
I'm using maven-assembly-plugin
v.3.3.0 with the following configuration in my assembly file (the module name is example
):
pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-example</artifactId>
<groupId>com.mysite</groupId>
<version>see-jgitver</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>example</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>A</artifactId>
<version>${lib.version}</version>
</dependency>
<dependency>
<groupId>com.myLib</groupId>
<artifactId>B</artifactId>
<version>${lib.version}</version>
</dependency>
<dependencies>
Assembly file:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySet>
<unpack>false</unpack>
<includes>
<include>*:tar.gz</include>
</includes>
<outputFileNameMapping>${artifact.groupId}${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
(Not sure if the ${artifact.groupId}
property is correct.)
The include tag matches artifact A
and B
.
I was expecting them to appear in the final package asA.tar.gz
and B.tar.gz
.
Instead I get a single artifact called example.tar.gz
So, artifact.artifactId
is referring to the example artifact, that is running the plugin, and not to the dependency. Is this expected behavior? How can I achieve my goal?
Additional info(edit):
why do you like to use outputFileNameMapping?
I'm trying to understand how it is used. In this case I have multiple dependencies with the same artifactId (although different groupId), so it would be useful to add the groupId to all of them.What is the problem?
Although, there's a context here, which I tried to clarify with this edit, I think my question is really straightforward. From the documentation I was expecting a different behavior.Why have you changed the outputDirectory?
I removed that tag, as it is not relevant in this case.Why an include on tar.gz?
So, there are several dependencies that are being joined in single tar. This is not my project, is part of a bigger construction.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论