maven - 如何配置 maven-enforcer-plugin 以排除测试范围内的某些规则?

标签 maven testing scope maven-enforcer-plugin

如何配置 maven-enforcer-plugin 以排除 test 范围内的某些规则?

我有这样的配置:

<executions>
  <execution>
    <id>enforce-bytecode-version</id>
    <goals>
      <goal>enforce</goal>
    </goals>
    <configuration>
      <rules>
        <enforceBytecodeVersion>
          <maxJdkVersion>1.7</maxJdkVersion>
        </enforceBytecodeVersion>
      </rules>
      <fail>true</fail>
    </configuration>
  </execution>
</executions>

但我只想检查常规代码的 JDK 版本,而不是测试范围。

最佳答案

这可以简单地通过使用 appropriate configuration 来完成:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.0.0-M1</version>
        <executions>
          <execution>
            <id>enforce-bytecode-version</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <enforceBytecodeVersion>
                  <maxJdkVersion>1.7</maxJdkVersion>
                  <ignoredScopes>
                     <ignoreScope>test</ignoreScope>
                   </ignoredScopes>
                </enforceBytecodeVersion>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-7</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

我还建议使用更新版本的 maven-enforcer-plugin .

关于maven - 如何配置 maven-enforcer-plugin 以排除测试范围内的某些规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49531075/

相关文章:

maven - 找不到 application.xml 中定义的子模块 [portal-service-ejb-1.4-SNAPSHOT.jar]

iphone - 在 Lion 上运行 xcode 3.2.2 时出错

javascript - 无法从 JS 函数访问组合日期

Python 全局变量/范围混淆

java - 无法让基本的 Hello World Spring MVC 项目正常工作

maven - Spring 启动 : is there a way to show the POM version number in some endpoint easily?

java - 线程 "main"java.io.FileNotFoundException : when running maven project using java -cp command 中出现异常

testing - 服务器的 "skipUncaughtErrors"标志是什么意思?

Selenium Webdriver 拖放不适用于 google.com

javascript - 局部变量在 javascript 的回调函数中变得未定义