• springboot项目自动拉取git信息的配置方法


    <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <targetPath>${project.build.outputDirectory}</targetPath>
                    <includes>
                        <include>**/**</include>
                    </includes>
                    <!-- 开启变量注入,resources目录下的文件可以使用这些注入的变量-->
                    <filtering>true</filtering>
                </resource>
            </resources>
            <plugins>
            <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>get-the-git-infos</id>
                            <phase>initialize</phase>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <verbose>false</verbose>
                        <dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
                        <generateGitPropertiesFile>true</generateGitPropertiesFile>
                        <generateGitPropertiesFilename>${project.build.outputDirectory}/.gitinfo
                        </generateGitPropertiesFilename>
                        <format>json</format>
                        <includeOnlyProperties>
                            <includeOnlyProperty>^git.branch$</includeOnlyProperty>
                            <includeOnlyProperty>^git.build.version$</includeOnlyProperty>
                            <includeOnlyProperty>^git.commit.id.full$</includeOnlyProperty>
                            <includeOnlyProperty>^git.commit.id.abbrev</includeOnlyProperty>
                            <includeOnlyProperty>^git.build.time$</includeOnlyProperty>
                            <includeOnlyProperty>^git.commit.message.full$</includeOnlyProperty>
                        </includeOnlyProperties>
                        <commitIdGenerationMode>full</commitIdGenerationMode>
                        <abbrevLength>11</abbrevLength>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <id>timestamp-property</id>
                            <goals>
                                <goal>timestamp-property</goal>
                            </goals>
                            <configuration>
                                <name>build.time</name>
                                <pattern>yyyyMMdd</pattern>
                                <locale>zh_CN</locale>
                                <timeZone>GMT+8</timeZone>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
           </plugins>
    </build>

    这里开启了变量注入,这样的话可以在resources目录下创建一个version文件,通过变量获取值,如:

    V@project.version@_@build.time@_@git.commit.id.abbrev@
  • 相关阅读:
    如何学习WindDbg
    如何在程序中嵌入google的V8 Javascript引擎
    理解程序内存
    如何学习Windows编程
    如何让窗口控件半透明
    Sessions, Window Stations and Desktops
    QQ截图时窗口自动识别的原理
    为什么设计模式在C++社区没有Java社区流行?
    当年写的俄罗斯方块
    如何判断一个C++对象是否在堆上
  • 原文地址:https://www.cnblogs.com/yb38156/p/15876213.html
Copyright © 2020-2023  润新知