Har*_*own 6 command-line maven-plugin maven-3 maven maven-enforcer-plugin
我想通过命令行执行Maven Enforcer插件。
我试过了:
mvn enforcer:enforce -Drules=[requireReleaseDeps]
mvn enforcer:enforce -Drules=requireReleaseDeps
Run Code Online (Sandbox Code Playgroud)
我总是收到此错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (default-cli) on project lkww-util-app-wurm-admin-rs-api: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce are missing or invalid -> [He
lp 1]
Run Code Online (Sandbox Code Playgroud)
我该如何指定rules参数?
您还可以<executions>在 POM 的主要部分中预先配置您的配置文件,而不是使用配置文件,然后使用<execution>'s<id>从命令行调用它们(有关更多信息,请参阅配置插件指南在这个语法上):
mvn enforcer:enforcer@my-execution-id
Run Code Online (Sandbox Code Playgroud)
由于默认情况下任何目标<execution>都将enforce目标绑定到validate阶段,但是,my-execution-id执行也运行在正常的mvn clean install. 如果不需要,请<skip>true</true>在命令行上配置执行并覆盖它:
mvn enforcer:enforcer@my-execution-id -Denforcer.skip=false
Run Code Online (Sandbox Code Playgroud)
这是否比maven-enforcer-plugin在 POM 的主要部分中传播配置更清晰,并且<profiles>是个人喜好的问题。
强制执行器插件不允许通过命令行参数选择/参与规则。
该插件存在一个未解决的问题,因此您可以投票支持。
同时,如果您选择的规则可以分为少量选择,那么您也许可以创建配置文件并将规则与配置文件相关联,从而允许通过指定配置文件为选定的规则子集运行构建。在下面的示例中,有两个配置文件,每个配置文件都有不同的执行器规则:
<profiles>
<profile>
<id>EnforceBannedPlugins</id>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-banned-plugins</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedPlugins>
...
</bannedPlugins>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</profile>
<profile>
<id>EnforceMavenVersion</id>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-maven-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
...
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
当然,如果您在运行时指定执行器规则的要求可以通过一些固定配置来满足,那么这只是一个运行程序。但是,如果要求是支持任何可能的强制执行者规则,那么您就不走运了,因为该插件不支持这一点。
| 归档时间: |
|
| 查看次数: |
2364 次 |
| 最近记录: |