简体   繁体   English

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

[英]How to confiugure maven-enforcer-plugin to exclude some rule in test scope?

How to confiugure maven-enforcer-plugin to exclude some rule in test scope? 如何配置maven-enforcer-plugin以排除测试范围中的某些规则?

I have such a configuration: 我有这样的配置:

<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>

But I would like to check JDK version only for regular code and not for test scope. 但是我只想检查JDK版本的常规代码,而不是测试范围。

This can simply being done by using the 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>

I also would recommend to use a more recent version of maven-enforcer-plugin . 我也建议使用更新版本的maven-enforcer-plugin

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

相关问题 Maven 插件问题:maven-enforcer-plugin:3.0.0-M3:enforce 有些 Enforcer 规则失败 - Problem with Maven plugin :maven-enforcer-plugin:3.0.0-M3:enforce Some Enforcer rules have failed maven-enforcer-plugin-在Maven中配置的位置 - maven-enforcer-plugin - where to configure in Maven 无法执行Maven-Enforcer-Plug - Failed to execute maven-enforcer-plugin maven-enforcer-plugin和child pom - maven-enforcer-plugin and child pom maven-enforcer-plugin 误报 RequireJavaVersion - maven-enforcer-plugin False Positive RequireJavaVersion 使 maven-enforcer-plugin 依赖收敛规则忽略次要版本的工件 - Make maven-enforcer-plugin dependency convergence rule ignore minor version of artifact 使用 YAML 配置 Maven - maven-enforcer-plugin 特定 - 不起作用 - Configuring Maven with YAML - maven-enforcer-plugin to be specific - not working 如何消除“maven-enforcer-plugin(目标”强制执行“)被m2e”eclipse警告忽略? - How to eliminate the “maven-enforcer-plugin (goal ”enforce“) is ignored by m2e” warning by eclipse? 了解如何在某些pom文件中使用maven-enforcer-plugin - Find out how maven-enforcer-plugin is used in certain pom files 如何在maven-enforcer-plugin的当前pom.xml中获取依赖项的版本? - How can I get a dependency's version in the current pom.xml for maven-enforcer-plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM