pom.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <parent>
  6. <artifactId>bnt</artifactId>
  7. <groupId>cn.reghao.bnt</groupId>
  8. <version>1.0.0</version>
  9. </parent>
  10. <modelVersion>4.0.0</modelVersion>
  11. <artifactId>agent</artifactId>
  12. <version>1.0.0</version>
  13. <properties>
  14. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  15. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  16. <maven.compiler.source>11</maven.compiler.source>
  17. <maven.compiler.target>11</maven.compiler.target>
  18. <project.build.outputDir>${project.basedir}/bin</project.build.outputDir>
  19. </properties>
  20. <dependencies>
  21. <dependency>
  22. <groupId>cn.reghao.bnt</groupId>
  23. <artifactId>common</artifactId>
  24. <version>1.0.0-SNAPSHOT</version>
  25. </dependency>
  26. <dependency>
  27. <groupId>ch.qos.logback</groupId>
  28. <artifactId>logback-core</artifactId>
  29. <version>1.2.3</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>ch.qos.logback</groupId>
  33. <artifactId>logback-classic</artifactId>
  34. <version>1.2.3</version>
  35. </dependency>
  36. </dependencies>
  37. <build>
  38. <finalName>devops-${project.artifactId}</finalName>
  39. <resources>
  40. <resource>
  41. <directory>src/main/resources</directory>
  42. <filtering>true</filtering>
  43. <includes>
  44. <include>git.properties</include>
  45. <include>logback.xml</include>
  46. </includes>
  47. </resource>
  48. </resources>
  49. <plugins>
  50. <plugin>
  51. <groupId>org.apache.maven.plugins</groupId>
  52. <artifactId>maven-assembly-plugin</artifactId>
  53. <version>3.2.0</version>
  54. <configuration>
  55. <archive>
  56. <manifest>
  57. <mainClass>cn.reghao.bnt.agent.AgentApp</mainClass>
  58. </manifest>
  59. </archive>
  60. <descriptorRefs>
  61. <descriptorRef>jar-with-dependencies</descriptorRef>
  62. </descriptorRefs>
  63. <!-- 不设置此属性则生成的 jar 包名字会带有 jar-with-dependencies -->
  64. <appendAssemblyId>false</appendAssemblyId>
  65. <outputDirectory>${project.build.outputDir}</outputDirectory>
  66. </configuration>
  67. <executions>
  68. <execution>
  69. <id>make-assembly</id>
  70. <phase>package</phase>
  71. <goals>
  72. <goal>single</goal>
  73. </goals>
  74. </execution>
  75. </executions>
  76. </plugin>
  77. <!--git-commit-id-plugin 插件,用于实现打包带git版本信息-->
  78. <plugin>
  79. <groupId>pl.project13.maven</groupId>
  80. <artifactId>git-commit-id-plugin</artifactId>
  81. <version>2.1.5</version>
  82. <executions>
  83. <execution>
  84. <goals>
  85. <goal>revision</goal>
  86. </goals>
  87. </execution>
  88. </executions>
  89. <configuration>
  90. <!--日期格式;默认值:dd.MM.yyyy '@' HH:mm:ss z;-->
  91. <dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
  92. <!--,构建过程中,是否打印详细信息;默认值:false;-->
  93. <verbose>true</verbose>
  94. <!-- ".git"文件路径;默认值:${project.basedir}/.git;
  95. 注意: 如果是多模块(多模块)项目,则需要修改到.git文件夹的目录-->
  96. <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
  97. <!--若项目打包类型为pom,是否取消构建;默认值:true;-->
  98. <skipPoms>false</skipPoms>
  99. <!--是否生成"git.properties"文件;默认值:false;-->
  100. <generateGitPropertiesFile>true</generateGitPropertiesFile>
  101. <!--指定"git.properties"文件的存放路径(相对于${project.basedir}的一个路径);
  102. 注意:该地址决定接口代码是否可以读取到git版本信息,请自行修改-->
  103. <generateGitPropertiesFilename>src/main/resources/git.properties</generateGitPropertiesFilename>
  104. <!--".git"文件夹未找到时,构建是否失败;若设置true,则构建失败;若设置false,则跳过执行该目标;默认值:true;-->
  105. <failOnNoGitDirectory>true</failOnNoGitDirectory>
  106. <!--git描述配置,可选;由JGit提供实现;-->
  107. <gitDescribe>
  108. <!--是否生成描述属性-->
  109. <skip>false</skip>
  110. <!--提交操作未发现tag时,仅打印提交操作ID,-->
  111. <always>false</always>
  112. <!--提交操作ID显式字符长度,最大值为:40;默认值:7;
  113. 0代表特殊意义;后面有解释;
  114. -->
  115. <abbrev>8</abbrev>
  116. <!--构建触发时,代码有修改时(即"dirty state"),添加指定后缀;默认值:"";-->
  117. <dirty>-dirty</dirty>
  118. <!--always print using the "tag-commits_from_tag-g_commit_id-maybe_dirty" format, even if "on" a tag.
  119. The distance will always be 0 if you're "on" the tag.
  120. -->
  121. <forceLongFormat>false</forceLongFormat>
  122. </gitDescribe>
  123. </configuration>
  124. </plugin>
  125. <!--apache maven插件,用于执行ant脚本函数-->
  126. <plugin>
  127. <artifactId>maven-antrun-plugin</artifactId>
  128. <version>1.8</version>
  129. <executions>
  130. <execution>
  131. <!--maven 插件生命周期,我试过用compile 发现打包以后没有git.properties,因为打包的时候,还没有生成
  132. 注意,这里改成 initialize 的话, 上面 git-commit-id-plugin 插件对应也该添加 phase 配置,并设置为 initialize
  133. 否则你生成的文件,写入的就不会对应的值,而是变量名-->
  134. <phase>initialize</phase>
  135. <goals>
  136. <goal>run</goal>
  137. </goals>
  138. <configuration>
  139. <tasks>
  140. <echo message="写入 git 版本信息"/>
  141. <!-- concat 常用于把一些信息写入文件,我这里用于把 git-commit-id-plugin 生成的git环境变量写入文件 -->
  142. <concat destfile="src/main/resources/git.properties">
  143. repo=${git.remote.origin.url}
  144. branch=${git.branch}
  145. commitId=${git.commit.id.abbrev}
  146. commitTime=${git.commit.time}
  147. buildTime=${git.build.time}
  148. </concat>
  149. </tasks>
  150. </configuration>
  151. </execution>
  152. </executions>
  153. </plugin>
  154. </plugins>
  155. </build>
  156. </project>