maven - 使用 build-helper-maven-plugin 和 multi modul

我将 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 install,它会正常工作,测试通过。

但是,这个项目是一个更大项目中的一个子模块。 如果我在父项目的根文件夹中启动 mvn install,maven 不会执行测试。

它似乎有效,但 surefire 没有检测到任何测试:

[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

知道如何使这项工作成功吗?

最佳答案

尝试使用 Debug模式 (-X) 启动 mvn 以查看 surefire 使用的属性对于您的树文件夹是否正确。

关于maven - 使用 build-helper-maven-plugin 和 multi module 跳过测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9258485/

相关文章:

python - 如何使用 setuptools 和 setup.py 从包中排除单个文件

encryption - Microsoft CNG BCryptEncrypt 返回密文 == 明

emacs - 在 emacs(或 DDD)中使用 gdb 时无法设置断点

asp.net - 签署网络表格 - 数字签名选项

vb.net - 创建后如何释放 MS Access LDB 锁定文件

sql - 假阴性 : Job Step History

google-maps - 在 Google Maps Static 上呈现比例尺

ruby-on-rails - 使用设计在 Rails 3.1 和 2.3.12 之间共享 sess

git - 克隆存储库时写入错误

oracle - 创建实体化 View 比创建表慢得多