如何使用properties maven plugin:write project properties仅写入指定的属性

如何使用properties maven plugin:write project properties仅写入指定的属性,maven,Maven,我正在尝试使用properties-maven-plugin将Git属性写入指定的文件。为此,我使用以下代码: <plugin> <groupId>ru.concerteza.buildnumber</groupId> <artifactId>maven-jgit-buildnumber-plugin</artifactId> <version>1.2.7</version> &l

我正在尝试使用
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>

ru.concerteza.buildnumber
maven jgit buildnumber插件
1.2.7
git buildnumber
提取buildnumber
初始化
org.codehaus.mojo
属性maven插件
1.0-α-2
准备包装
写入项目属性
${project.basedir}/./build-info.tmp
修订
${revision}
建筑编号
${buildnumber}
现在我的问题是:

  • 它给出了branch、buildnumber、commitcount、tag、branch等,但我只想使用properties插件从
    maven jgit buildnumber插件
    中提取修订版和内部版本号
  • 我也想给它们重命名。例如
    git.buildnumber
    as
    buildnumber
    git.revision
    as
    revision
  • 是否有任何可能的方法可以从用户的命令提示符中手动获取
    buildnumber

  • 有人能给我推荐一下吗?提前谢谢。

    这正在起作用。。。。通过将其保存在概要文件中并给出命令clean install-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>
    
    
    com.keyboardsamurais.maven
    maven时间戳插件
    1
    日期
    EEE MMM dd hh:mm:ss yyyy Z
    IST
    创造
    ru.concerteza.buildnumber
    maven jgit buildnumber插件
    1.2.7
    git buildnumber
    初始化
    提取buildnumber
    修订
    版本
    org.codehaus.mojo
    属性maven插件
    1.0.0
    设置系统属性
    修订
    ${revision}
    日期
    ${date}
    com.internetitem
    写属性文件maven插件
    1.0.1
    写入属性文件
    安装
    写入属性文件
    build-info.tmp
    ${project.basedir}//
    修订
    ${revision}
    日期
    ${date}
    版本
    ${version}
    
    这正在工作。。。。通过将其保存在概要文件中并给出命令clean install-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>
    
    
    com.keyboardsamurais.maven
    maven时间戳插件
    1
    日期
    EEE MMM dd hh:mm:ss yyyy Z
    IST
    创造
    ru.concerteza.buildnumber
    maven jgit buildnumber插件
    1.2.7
    git buildnumber
    初始化
    提取buildnumber
    修订
    版本
    org.codehaus.mojo
    属性maven插件
    1.0.0
    设置系统属性
    修订
    ${revision}
    日期