我想在maven中将变量${mercurialVersion}
(最新的mercurial标签)写入文件,并将目标目录更改为target / prod-latestMercurialTag / app.war。我怎么能这样做?
这是我使用最新的hg标签填充${mercurialVersion}
的代码:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<script>hg parent --template {latesttag}</script>
</properties>
<source>
def command = project.properties.script
def process =
command.execute()
process.waitFor()
project.properties.mercurialVersion = process.in.text
</source>
</configuration>
</plugin>
我试过了:
<plugin>
<groupId>com.internetitem</groupId>
<artifactId>write-properties-file-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>mercurialVersion</id>
<phase>compile</phase>
<goals>
<goal>write-properties-file</goal>
</goals>
<configuration>
<outputFile>${baseDir}/src/main/resources</outputFile>
<filename>version.properties</filename>
<properties>
<property>
<name>version</name>
<value>${mercurialVersion}</value>
</property>
<property>
<name>artifactId</name>
<value>My Artifact ID is ${project.artifactId}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
但是没有任何内容进入${baseDir}/src/main/resources/version.properties
文件...
提前谢谢你。
最好的问候,
mismas