我正在尝试使用properties-maven-plugin
将Git属性写入指定的文件。为此,我使用以下代码:
<plugin>
<groupId>ru.concerteza.buildnumber</groupId>
<artifactId>maven-jgit-buildnumber-plugin</artifactId>
<version>1.2.7</version>
<executions>
<execution>
<id>git-buildnumber</id>
<goals>
<goal>extract-buildnumber</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
</plugin>
<!--write project properties to file -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>${project.basedir}/../build-info.tmp</outputFile>
<properties>
<property>
<name>revision</name>
<value>${revision}</value>
</property>
<property>
<name>buildnumber</name>
<value>${buildnumber}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
现在我的问题是:
maven-jgit-buildnumber-plugin
使用属性插件中仅提取修订版本和内部版本号。git.buildnumber
为buildnumber
,git.revision
为revision
。buildnumber
?有人可以通过这个建议我吗?提前谢谢。
答案 0 :(得分:1)
这是有效....通过将其保存在配置文件中并给出命令clean install -P profilename -Dversion = 16
<plugin>
<groupId>com.keyboardsamurais.maven</groupId>
<artifactId>maven-timestamp-plugin</artifactId>
<version>1.0</version>
<configuration>
<propertyName>date</propertyName>
<timestampPattern>EEE MMM dd hh:mm:ss yyyy Z</timestampPattern>
<timeZone>IST</timeZone>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>ru.concerteza.buildnumber</groupId>
<artifactId>maven-jgit-buildnumber-plugin</artifactId>
<version>1.2.7</version>
<executions>
<execution>
<id>git-buildnumber</id>
<phase>initialize</phase>
<goals>
<goal>extract-buildnumber</goal>
</goals>
<configuration>
<revisionProperty>revision</revisionProperty>
<buildnumberProperty>version</buildnumberProperty>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>revision</name>
<value>${revision}</value>
</property>
<property>
<name>date</name>
<value>${date}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.internetitem</groupId>
<artifactId>write-properties-file-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>write-properties-file</id>
<phase>install</phase>
<goals>
<goal>write-properties-file</goal>
</goals>
<configuration>
<filename>build-info.tmp</filename>
<outputDirectory>${project.basedir}/../</outputDirectory>
<properties>
<property>
<name>revision</name>
<value>${revision}</value>
</property>
<property>
<name>date</name>
<value>${date}</value>
</property>
<property>
<name>version</name>
<value>${version}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>