要求:上传(部署)一个附加文件(文本格式的发行说明文件)以及 jar/war 到 nexus。
可能的解决方案:使用maven deploy plugin
如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<packaging>RELEASENOTE.MD</packaging>
<generatePom>false</generatePom>
<url>${project.distributionManagement.repository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>RELEASENOTE.MD</file>
</configuration>
</execution>
</executions>
</plugin>
问题:
RELEASENOTE.MD
文件是可选的。仅当文件存在时才应部署该文件。如果文件不存在,上述解决方案会引发错误。[错误] 无法执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...\RELEASENOTE.MD not found。
*RELEASENOTE.MD
。maven deploy plugin
不接受正则表达式。[错误] 无法执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file (default) on project ...*RELEASENOTE.MD not found。
如何规避这两个问题?
结合来自@SpaceTrucker和@khmarbaise的输入,提出了以下解决方案:
<profiles>
<profile>
<id>add-release-note</id>
<activation>
<file><exists>RELEASENOTE.MD</exists></file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>RELEASENOTE.MD</file>
<type>MD</type>
<classifier>RELEASENOTE</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
编辑
maven-deploy-plugin
在配置文件激活中也有效。然而,由于它的<url>
标签,它给发布/快照构建参数化带来了困难。build-helper-maven-plugin
是一个更简单的解决方案
文件名正则表达式可以通过包装壳构建脚本处理
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句