pom.xml 7.5 KB

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