Maven enforcer 插件不强制执行
Maven enforcer plugin is not enforcing
在 pom 中,我有一个工件 ID 的参数:
<dependency>
<groupId>com.abc.automation</groupId>
<artifactId>${app}-xyz-extension</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
我打算强制任何使用此 pom 的人传递参数 -Dapp;为此,我正在使用 enforcer 插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-property</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>app</property>
<message>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You must set the app property!
This is used to determine which app is being tested and load the
corresponding extension.
Example: -Dapp=sampeapp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
</message>
<!--<regex>.*\d.*</regex>-->
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
然而,这并不是强制要求 -Dapp 必须是基础的,而是我得到的是来自 pom 的错误
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.artifactId' for com.abc.automation:${app}-xyz-extension:test-jar with value '${app}-taas-extension' does not match a valid id pattern. @ line 18, column 19
Plugins 元素放置在内部构建中,如下所示:
<build>
<pluginManagement>
<plugins>
<plugin>
....
</plugin>
</plugins>
</pluginManagement>
</build>
我是否缺少 enforcer 插件的基础知识?
我猜你的插件定义在 <pluginManagement>
里面。将其移动到 POM 的 <plugins>
部分。
Deepak,可能是因为其他plugin/dependency在强制插件之前写了占位符${app}。
在 pom 中,我有一个工件 ID 的参数:
<dependency>
<groupId>com.abc.automation</groupId>
<artifactId>${app}-xyz-extension</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
我打算强制任何使用此 pom 的人传递参数 -Dapp;为此,我正在使用 enforcer 插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-property</id>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>app</property>
<message>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You must set the app property!
This is used to determine which app is being tested and load the
corresponding extension.
Example: -Dapp=sampeapp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
</message>
<!--<regex>.*\d.*</regex>-->
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
然而,这并不是强制要求 -Dapp 必须是基础的,而是我得到的是来自 pom 的错误
[ERROR] The build could not read 1 project -> [Help 1] org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs: [ERROR] 'dependencies.dependency.artifactId' for com.abc.automation:${app}-xyz-extension:test-jar with value '${app}-taas-extension' does not match a valid id pattern. @ line 18, column 19
Plugins 元素放置在内部构建中,如下所示:
<build>
<pluginManagement>
<plugins>
<plugin>
....
</plugin>
</plugins>
</pluginManagement>
</build>
我是否缺少 enforcer 插件的基础知识?
我猜你的插件定义在 <pluginManagement>
里面。将其移动到 POM 的 <plugins>
部分。
Deepak,可能是因为其他plugin/dependency在强制插件之前写了占位符${app}。