[英]Maven deploy “Release Note” as artifact
要求 :將一個附加文件(文本格式發行說明文件)連同jar / war一起上載(部署)到聯系。
可能的解決方案 :使用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
文件是可選的。 該文件僅在存在時才應部署。 如果文件不存在,上述解決方案將引發錯誤。 [錯誤]無法在項目... \\ RELEASENOTE.MD上執行目標org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file(默認)。
*RELEASENOTE.MD
)。 maven deploy plugin
不接受正則表達式。 [錯誤]無法在項目... * RELEASENOTE.MD上執行目標org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file(默認)。
如何避免這兩個問題?
將發行說明的部署移動到其自己的Maven配置文件,並僅在存在發行說明文件的情況下激活該配置文件。
<profiles>
<profile>
<activation>
<file>
<exists>RELEASENOTE.MD</exists>
</file>
</activation>
<!-- deployment of release notes declarations here -->
</profile>
</profiles>
有關更多信息,請參見構建配置文件簡介 。
關於正則表達式要求,您應該為發行說明設置命名策略,並將其實現為可由Maven構建訪問的變量。 構建助手maven插件可能在那里使用。
結合@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
是一個更簡單的解決方案
可以通過包裝程序外殼構建腳本處理文件名正則表達式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.