无法将属性从maven概要文件传递到maven failsafe插件

njthzxwz  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(337)

我正在尝试基于概要文件执行集成测试。但是,我无法将属性传递给maven failsafe插件。请在我的pom下面找到
http://maven.apache.org/xsd/maven-4.0.0.xsd“>4.0.0 com.comcast.iot账户服务0.0.1-snapshot jar 2017账户服务

  1. <parent>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-parent</artifactId>
  4. <version>1.5.6.RELEASE</version>
  5. <relativePath/>
  6. <!-- lookup parent from repository -->
  7. </parent>
  8. <properties>
  9. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  10. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  11. <java.version>1.8</java.version>
  12. <money.scala.version>2.11</money.scala.version>
  13. <money.version>0.9.0-RC2</money.version>
  14. <build.profile.url>http://localhost:8080</build.profile.url>
  15. </properties>
  16. <profiles>
  17. <!-- The Configuration of the development profile -->
  18. <profile>
  19. <id>dev</id>
  20. <activation>
  21. <activeByDefault>true</activeByDefault>
  22. </activation>
  23. <properties>
  24. <build.profile.id>dev</build.profile.id>
  25. <build.profile.url>http://localhost:8080</build.profile.url>
  26. <!--
  27. Only unit tests are run when the development profile is active
  28. -->
  29. <skip.integration.tests>true</skip.integration.tests>
  30. <skip.unit.tests>false</skip.unit.tests>
  31. </properties>
  32. </profile>
  33. <!-- The Configuration of the integration-test profile -->
  34. <profile>
  35. <id>integration-test</id>
  36. <properties>
  37. <build.profile.id>integration-test</build.profile.id>
  38. <build.profile.url>https://account-ms-integration.g3.app.cloud.comcast.net</build.profile.url>
  39. <!--
  40. Only integration tests are run when the integration-test profile is active
  41. -->
  42. <skip.integration.tests>false</skip.integration.tests>
  43. <skip.unit.tests>true</skip.unit.tests>
  44. </properties>
  45. </profile>
  46. </profiles>
  47. <repositories>
  48. <repository>
  49. <id>mortar-releases</id>
  50. <name>Comcast Public Repository</name>
  51. <url>https://nexus.comcast.com/nexus/content/groups/public</url>
  52. <releases>
  53. <enabled>true</enabled>
  54. <updatePolicy>never</updatePolicy>
  55. </releases>
  56. <snapshots>
  57. <enabled>false</enabled>
  58. </snapshots>
  59. </repository>
  60. <repository>
  61. <id>mortar-snapshots</id>
  62. <url>https://nexus.comcast.com/nexus/content/groups/public</url>
  63. <releases>
  64. <enabled>false</enabled>
  65. </releases>
  66. <snapshots>
  67. <enabled>true</enabled>
  68. </snapshots>
  69. </repository>
  70. </repositories>
  71. <distributionManagement>
  72. <repository>
  73. <id>mortar-releases</id>
  74. <url>https://nexus.comcast.com/nexus/content/repositories/releases/</url>
  75. </repository>
  76. <snapshotRepository>
  77. <id>mortar-snapshots</id>
  78. <url>https://nexus.comcast.com/nexus/content/repositories/snapshots/</url>
  79. </snapshotRepository>
  80. </distributionManagement>
  81. <dependencyManagement>
  82. <dependencies>
  83. <dependency>
  84. <groupId>org.springframework.cloud</groupId>
  85. <artifactId>spring-cloud-dependencies</artifactId>
  86. <version>Dalston.SR4</version>
  87. <type>pom</type>
  88. <scope>import</scope>
  89. </dependency>
  90. </dependencies>
  91. </dependencyManagement>
  92. <dependencies>
  93. <dependency>
  94. <groupId>com.comcast.iot</groupId>
  95. <artifactId>dhx-common</artifactId>
  96. <version>0.0.1-SNAPSHOT</version>
  97. </dependency>
  98. <dependency>
  99. <groupId>org.springframework.boot</groupId>
  100. <artifactId>spring-boot-starter-actuator</artifactId>
  101. </dependency>
  102. <dependency>
  103. <groupId>org.springframework.cloud</groupId>
  104. <artifactId>spring-cloud-starter-bus-amqp</artifactId>
  105. </dependency>
  106. <dependency>
  107. <groupId>org.springframework.cloud</groupId>
  108. <artifactId>spring-cloud-starter-config</artifactId>
  109. </dependency>
  110. <dependency>
  111. <groupId>org.springframework.boot</groupId>
  112. <artifactId>spring-boot-starter</artifactId>
  113. </dependency>
  114. <dependency>
  115. <groupId>org.springframework.boot</groupId>
  116. <artifactId>spring-boot-starter-test</artifactId>
  117. <scope>test</scope>
  118. </dependency>
  119. <dependency>
  120. <groupId>org.springframework.boot</groupId>
  121. <artifactId>spring-boot-starter-web</artifactId>
  122. </dependency>
  123. <dependency>
  124. <groupId>org.apache.commons</groupId>
  125. <artifactId>commons-lang3</artifactId>
  126. <version>3.6</version>
  127. </dependency>
  128. <dependency>
  129. <groupId>javax.inject</groupId>
  130. <artifactId>javax.inject</artifactId>
  131. <version>1</version>
  132. </dependency>
  133. <dependency>
  134. <groupId>com.fasterxml.jackson.datatype</groupId>
  135. <artifactId>jackson-datatype-jsr310</artifactId>
  136. <version>2.6.5</version>
  137. </dependency>
  138. <dependency>
  139. <groupId>io.springfox</groupId>
  140. <artifactId>springfox-swagger2</artifactId>
  141. <version>2.6.1</version>
  142. </dependency>
  143. <!-- Redis -->
  144. <dependency>
  145. <groupId>org.springframework.boot</groupId>
  146. <artifactId>spring-boot-starter-data-redis</artifactId>
  147. </dependency>
  148. <dependency>
  149. <groupId>redis.clients</groupId>
  150. <artifactId>jedis</artifactId>
  151. </dependency>
  152. <!-- Eureka -->
  153. <dependency>
  154. <groupId>org.springframework.cloud</groupId>
  155. <artifactId>spring-cloud-starter-eureka</artifactId>
  156. </dependency>
  157. </dependencies>
  158. <build>
  159. <filters>
  160. <filter>profiles/${build.profile.id}/config.properties</filter>
  161. </filters>
  162. <resources>
  163. <resource>
  164. <filtering>true</filtering>
  165. <directory>src/main/resources</directory>
  166. </resource>
  167. </resources>
  168. <plugins>
  169. <plugin>
  170. <groupId>org.springframework.boot</groupId>
  171. <artifactId>spring-boot-maven-plugin</artifactId>
  172. </plugin>
  173. <plugin>
  174. <groupId>org.apache.maven.plugins</groupId>
  175. <artifactId>maven-compiler-plugin</artifactId>
  176. <configuration>
  177. <source>${java.version}</source>
  178. <target>${java.version}</target>
  179. <encoding>${project.encoding}</encoding>
  180. </configuration>
  181. </plugin>
  182. <plugin>
  183. <groupId>org.apache.maven.plugins</groupId>
  184. <artifactId>maven-source-plugin</artifactId>
  185. <version>2.4</version>
  186. <executions>
  187. <execution>
  188. <id>attach-sources</id>
  189. <goals>
  190. <goal>jar-no-fork</goal>
  191. </goals>
  192. </execution>
  193. </executions>
  194. </plugin>
  195. <plugin>
  196. <groupId>org.apache.maven.plugins</groupId>
  197. <artifactId>maven-javadoc-plugin</artifactId>
  198. <version>2.10.3</version>
  199. <configuration>
  200. <sourcepath>src/main/java/</sourcepath>
  201. <show>public</show>
  202. <failOnError>true</failOnError>
  203. </configuration>
  204. <executions>
  205. <execution>
  206. <id>attach-javadocs</id>
  207. <goals>
  208. <goal>jar</goal>
  209. </goals>
  210. </execution>
  211. </executions>
  212. </plugin>
  213. <plugin>
  214. <groupId>org.apache.maven.plugins</groupId>
  215. <artifactId>maven-resources-plugin</artifactId>
  216. <version>2.7</version>
  217. <configuration>
  218. <encoding>${project.encoding}</encoding>
  219. </configuration>
  220. </plugin>
  221. <plugin>
  222. <groupId>org.apache.maven.plugins</groupId>
  223. <artifactId>maven-surefire-plugin</artifactId>
  224. <version>2.18.1</version>
  225. <configuration>
  226. <!-- Skips unit tests if the value of skip.unit.tests property is true -->
  227. <skipTests>${skip.unit.tests}</skipTests>
  228. <!-- Excludes integration tests when unit tests are run -->
  229. <excludes>
  230. <exclude>**/IT*.java</exclude>
  231. </excludes>
  232. <enableAssertions>true</enableAssertions>
  233. </configuration>
  234. </plugin>
  235. <plugin>
  236. <groupId>org.jacoco</groupId>
  237. <artifactId>jacoco-maven-plugin</artifactId>
  238. <version>0.7.7.201606060606</version>
  239. <configuration>
  240. <rules>
  241. <rule>
  242. <element>CLASS</element>
  243. <limits>
  244. <limit>
  245. <counter>LINE</counter>
  246. <value>COVEREDRATIO</value>
  247. <minimum>0.80</minimum>
  248. </limit>
  249. <limit>
  250. <counter>BRANCH</counter>
  251. <value>COVEREDRATIO</value>
  252. <minimum>0.80</minimum>
  253. </limit>
  254. <limit>
  255. <counter>INSTRUCTION</counter>
  256. <value>COVEREDRATIO</value>
  257. <minimum>0.80</minimum>
  258. </limit>
  259. <limit>
  260. <counter>BRANCH</counter>
  261. <value>COVEREDRATIO</value>
  262. <minimum>0.80</minimum>
  263. </limit>
  264. <limit>
  265. <counter>COMPLEXITY</counter>
  266. <value>COVEREDRATIO</value>
  267. <minimum>0.80</minimum>
  268. </limit>
  269. <limit>
  270. <counter>METHOD</counter>
  271. <value>COVEREDRATIO</value>
  272. <minimum>0.80</minimum>
  273. </limit>
  274. <limit>
  275. <counter>CLASS</counter>
  276. <value>COVEREDRATIO</value>
  277. <minimum>0.80</minimum>
  278. </limit>
  279. </limits>
  280. <excludes>
  281. <!-- <exclude>com.comcast.digitalhome.das.molecule.dao.MoleculeClientDaoImpl</exclude> -->
  282. </excludes>
  283. </rule>
  284. </rules>
  285. </configuration>
  286. <executions>
  287. <execution>
  288. <goals>
  289. <goal>prepare-agent</goal>
  290. </goals>
  291. </execution>
  292. <execution>
  293. <id>report</id>
  294. <phase>test</phase>
  295. <goals>
  296. <goal>report</goal>
  297. <!-- <goal>check</goal> -->
  298. </goals>
  299. </execution>
  300. </executions>
  301. </plugin>
  302. <plugin>
  303. <groupId>org.codehaus.mojo</groupId>
  304. <artifactId>build-helper-maven-plugin</artifactId>
  305. <version>1.9.1</version>
  306. <executions>
  307. <execution>
  308. <id>add-integration-test-sources</id>
  309. <phase>generate-test-sources</phase>
  310. <goals>
  311. <goal>add-test-source</goal>
  312. </goals>
  313. <configuration>
  314. <sources>
  315. <source>src/integration-test/java</source>
  316. </sources>
  317. </configuration>
  318. </execution>
  319. <!-- Add a new resource directory to our build -->
  320. <execution>
  321. <id>add-integration-test-resources</id>
  322. <phase>generate-test-resources</phase>
  323. <goals>
  324. <goal>add-test-resource</goal>
  325. </goals>
  326. <configuration>
  327. <resources>
  328. <resource>
  329. <filtering>true</filtering>
  330. <directory>src/integration-test/resources</directory>
  331. </resource>
  332. </resources>
  333. </configuration>
  334. </execution>
  335. </executions>
  336. </plugin>
  337. <plugin>
  338. <groupId>org.apache.maven.plugins</groupId>
  339. <artifactId>maven-failsafe-plugin</artifactId>
  340. <version>2.18</version>
  341. <executions>
  342. <execution>
  343. <id>integration-test</id>
  344. <goals>
  345. <goal>verify</goal>
  346. </goals>
  347. <configuration>
  348. <environmentVariables>
  349. <build.profile.url>${build.profile.url}</build.profile.url>
  350. </environmentVariables>
  351. <!--
  352. Skips integration tests if the value of skip.integration.tests
  353. property is true
  354. -->
  355. <skipTests>${skip.integration.tests}</skipTests>
  356. </configuration>
  357. </execution>
  358. </executions>
  359. </plugin>
  360. </plugins>
  361. </build>
  362. </project>

使用这个命令mvnverify-p integration test,我将获得system.getproperty的空值(“build.profile.url”)。但是,命令mvn verify-dbuild.profile.url=http://localhost:8080-p集成测试工作正常。请帮我解决这个问题。谢谢

esbemjvw

esbemjvw1#

如果您希望failsafe插件与系统属性一起运行(例如 -Dbuild.profile.url=... )然后必须提供如下配置:

  1. <configuration>
  2. <systemPropertyVariables>
  3. <build.profile.url>${build.profile.url}</build.profile.url>
  4. </systemPropertyVariables>
  5. </configuration>

更多细节见文件。
这样maven的财产- ${build.profile.url} -您已经在配置文件中填充的内容将被传播到failsafe插件启动的任何jvm。
注意:你已经做了一些非常接近这一点,但你正在设置 environmentVariables 而不是 systemPropertyVariables .

相关问题