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



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

现在我的问题是:

    它给出了分支、内部版本号、
  1. 提交计数、标签、分支等,但我只想使用属性插件从maven-jgit-buildnumber-plugin中提取修订版和内部版本号。
  2. 我也想重命名它们。例如,git.buildnumber buildnumbergit.revision revision
  3. 有什么可能的方法可以从用户手动获取命令提示符下的buildnumber

谁能建议我通过这个?提前谢谢。

这是有效的....通过将其保留在配置文件中并给出命令全新安装 -P 配置文件名称 -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>

相关内容

最新更新