简体   繁体   English

跳过gmavenplus插件中的编译

[英]Skip compilation in gmavenplus plugin

I currently work in big project built by Maven which has many integration tests modules which are marked as main (not testing) sources. 我目前在由Maven构建的大型项目中工作,该项目具有许多集成测试模块,这些模块被标记为主要 (非测试)源。 I am trying to create a profile which would skip compilation of these modules. 我正在尝试创建一个配置文件,该配置文件将跳过这些模块的编译。 I expected gmaven plugin to allow "skip" configuration parameter but this is not the case. 我希望gmaven插件允许“跳过”配置参数,但事实并非如此。 Is there any way to skip module processing without pointing gmaven plugin to non-existent directory and without copy-paste of all modules except integration tests to a separate profile? 有什么方法可以跳过模块处理,而无需将gmaven插件指向不存在的目录,也无需将所有模块(除了集成测试之外的所有模块)复制粘贴到单独的配置文件中?

You can put the integration test modules in a separate profile of the parent pom where you list the modules. 您可以将集成测试模块放在列出模块的父pom的单独配置文件中。 The profile should be active unless you disable it by setting a property when running the Maven build ( -DskipIntegrationTestModules ). 除非您在运行Maven构建( -DskipIntegrationTestModules )时通过设置属性来禁用配置文件,否则该配置文件应处于活动状态。 ( Don't use activeByDefault .) 不要使用activeByDefault 。)

  <modules>
    <module>my-project</module>
  </modules>

  <profiles>
    <profile>
        <id>build-integration-tests</id>
        <activation>
            <property>
                <name>!skipIntegrationTestModules</name>
            </property>
        </activation>       
        <modules>
            <module>my-project-integration-test</module>
        </modules>
    </profile>
  </profiles>

You can find more details in the Maven Introduction to Build Profiles . 您可以在Maven Build Profiles简介中找到更多详细信息

You should also know that it can be dangerous to have modules in build profiles because they could be accidentally left out when doing release builds. 您还应该知道, 在构建配置文件中包含模块可能很危险,因为在进行发行版本构建时可能会意外地将其遗漏。 I think it should be OK in this case because the profile has to be deactivated explicitly. 我认为在这种情况下应该可以,因为必须显式停用配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM