我正在使用描述符在Maven中构建程序集,我正在尝试简单地执行以下操作:
重命名格式:
${project.artifactId}-${project.version}.lib.${artifact.artifactId}.${artifact.extension}`
目前,我的程序集描述符如下所示:
<?xml version="1.0"?>
<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>default</id>
<formats>
<format>tar.gz</format>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>*:*</exclude>
</excludes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/</outputDirectory>
<outputFileNameMapping>
${project.artifactId}-${project.version}.lib.${artifact.artifactId}.${artifact.extension}
</outputFileNameMapping>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
不幸的是,我似乎无法让主项目工件落在发行版中。我究竟做错了什么?
答案 0 :(得分:2)
您可以使用<files>
块单独包含项目工件本身:
<!-- Include the project artifact itself. -->
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
<!-- Include all dependent libraries. -->
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/</outputDirectory>
<outputFileNameMapping>${project.artifactId}-${project.version}.lib.${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
(对于<source>
,可能有一个比上面更正确的表达式,但找到可用的Maven属性的完整列表很困难。如果有人知道,请随时编辑!)
最后,顺便说一句,如果您的任何依赖项都有分类器,您可能需要考虑在某处向${dashClassifier?}
添加<outputFileNameMapping>
,否则文件名中将缺少分类器。