我使用POM文件的这一部分生成一个构建号:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<buildNumberPropertyName>project.build.number</buildNumberPropertyName>
<timestampPropertyName>project.build.time</timestampPropertyName>
<format>{0,date,yyyyMMddHHmmss}</format>
<items>
<item>timestamp</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
之后我将finalName设置为以下:
<finalName>
${project.artifactId}-${project.version}.${project.build.number}
</finalName>
我也使用webstart-maven-plugin将项目生成为webstart-app。 webstart-plugin生成一个zip文件。 除了一个小细节之外,一切正常:
在构建时有这样的输出:
[buildnumber:create]
Storing buildNumber: 20130312133207 at timestamp: 1363091527664
Building jar: D:\projects\myProject\target\myProject-1.0.20130312133207.jar
Building jar: D:\projects\myProject\target\myProject-1.0.20130312133207-sources.jar
Building jar: D:\projects\myProject\target\myProject-1.0.20130312133207-javadoc.jar
Building zip: D:\projects\myProject\target\myProject-1.0.${project.build.number}.zip
为什么zip文件中没有替换$ {project.build.number}? 是因为它是拉链而不是罐子? 为什么替换版本呢? 如何告诉POM替换zip文件中的buildNumber?
我已经尝试使用默认的$ buildNumber而不是$ project.build.number,这也不起作用。
编辑:我已经尝试过两个插件的不同阶段,但到目前为止还没有任何组合。
Edit2:如果您感兴趣的话,Webstart-Plugin-part的外观如下,这里是代码:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>jnlp</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- JNLP generation -->
<jnlp>
<!-- default values -->
<inputTemplateResourcePath>${project.basedir}</inputTemplateResourcePath>
<inputTemplate>src/main/jnlp/app.vm</inputTemplate> <!-- relative to inputTemplateResourcePath -->
<outputFile>app.jnlp</outputFile> <!-- defaults to launch.jnlp -->
<!-- used to automatically identify the jar containing the main class. -->
<!-- this is perhaps going to change -->
<mainClass>com.mycompany.myproject.App</mainClass>
</jnlp>
<sign>
<keystore>${basedir}/keystore</keystore>
<keypass>password</keypass> <!-- we need to override passwords easily from the command line. ${keypass} -->
<storepass>password</storepass> <!-- ${storepass} -->
<!--storetype>fillme</storetype-->
<alias>MyProjectWebstart</alias>
<!--validity>fillme</validity-->
<!-- only required for generating the keystore -->
<dnameCn>MyProjectWebstart</dnameCn>
<dnameOu>MyName</dnameOu>
<dnameO>MyCompany</dnameO>
<dnameL>MyTown</dnameL>
<dnameSt>MyState</dnameSt>
<dnameC>MyCountry</dnameC>
<verify>true</verify> <!-- verify that the signing operation succeeded -->
<!-- KEYSTORE MANAGEMENT -->
<keystoreConfig>
<delete>true</delete> <!-- delete the keystore -->
<gen>true</gen> <!-- optional shortcut to generate the store. -->
</keystoreConfig>
</sign>
</configuration>
</plugin>
我使用了示例中的代码:Looking for Webstart Maven Plugin sample application
答案 0 :(得分:0)
不要将buildNumberPropertyName参数设置为project.build.ANYTHING ..表达式,以$ {project.XXX}开头,基于MavenProject对象进行解析,因此您在$ {project.build.date}中说有一个getter getBuild ()返回一个具有getter getDate()的对象,该对象不正确。
只是以不同方式命名buildNumberPropertyName和timestampPropertyName参数,例如。 myBuildNumber和myTimestamp并相应更改pom的其余部分