在我的Maven構建中,我有一小塊Ant代碼需要在Surefire開始執行一些配置之前運行。如何在testCompile和測試階段之間執行Maven的antrun(在Surefire執行之前)?
該代碼與antrun執行,但我不能得到antrun在Surefire之前執行。
這是我構建的輸出中的相關章節:
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ com...tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\...\com...tests\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.16:test (default-test) @ com...tests ---
[INFO] Surefire report directory: C:\...\com...tests\target\surefire-reports
基本上我需要antrun maven-compiler-plugin:3.1:testCompile
和maven-surefire-plugin:2.16:test
之間執行。
我嘗試將antrun綁定到測試階段,並將它放在POM文件中的surefire插件之前,但它始終在Surefire插件之後執行。我也嘗試將它配置爲在testCompile階段運行,並將其放在maven-compiler-plugin插件之後,但是沒有成功。它在surefire之後執行。
有誰知道如何讓它在這兩者之間執行?
謝謝!
愛德華
通過Ant無法通過Maven完成什麼?你能給我們更多的細節嗎? – khmarbaise
在這種情況下,我正在更新屬性文件。它可能在Maven中完成,但更新它的命令來自包含'sed'命令的文件,因此antrun似乎是讀取該文件並在測試運行之前執行sed命令的最簡單方法。 –
爲什麼你要更新屬性文件,因爲你在src/test/resources'中有第二個集合用於測試,而不會干擾'src/main/resources'中的生產屬性文件。 – khmarbaise