我使用build-helper-maven-plugin作爲具有非標準樹文件夾的傳統項目。使用build-helper-maven-plugin和多模塊跳過測試
我使用這種方式:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/firstmodule/src</source>
<source>${basedir}/secondmodule/src</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/firstmodule/tests</source>
<source>${basedir}/secondmodule/tests</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
它正常工作,如果我啓動MVN在項目的根目錄安裝,測試通過。
但是,這個項目是一個更大項目中的子模塊。 如果我在父項目的根文件夾中啓動mvn install,maven不會執行測試。
似乎工作萬無一失,但沒有檢測到任何測試:
[INFO] Building MyLegacyProject
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\target
[INFO] [build-helper:add-source {execution: add-source}]
[INFO] Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\firstmodule\src added.
[INFO] Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\secondmodule\src added.
[INFO] [build-helper:add-test-source {execution: add-test-source}]
[INFO] Test Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\firstmodule\tests added.
[INFO] Test Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\secondmodule\tests added.
[debug] execute contextualize
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 40 resources
[INFO] Copying 40 resources
[WARNING] While downloading com.sun.xml:saaj-impl:1.3
This artifact has been relocated to com.sun.xml.messaging.saaj:saaj-impl:1.3.
[WARNING] While downloading javax.xml:jaxb-api:2.1
This artifact has been relocated to javax.xml.bind:jaxb-api:2.1.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 752 source files to C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\target\classes
[debug] execute contextualize
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 34 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 15 source files to C:\DEV\perforce\1992\depot\MyLegacyProject\release\BUG_FIXING\MyLegacyProject\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\DEV\perforce\1992\depot\MyLegacyProject\release\BUG_FIXING\MyLegacyProject\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.381 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
任何想法如何做這項工作?
那麼,15個測試類被編譯。你有自定義的surefire配置嗎? – Raghuram 2012-02-13 10:43:47
不,surefire未配置,我使用默認設置 – 2012-02-13 18:04:40