在 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 ;为此,我正在使用强制插件:
<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 的错误
[错误] 构建无法读取 1 个项目-> [帮助 1] org.apache.maven.project.ProjectBuildingException:处理 POM 时遇到一些问题:[错误] com.abc 的“dependencies.dependency.artifactId”。自动化:${app}-xyz-extension:test-jar 的值为 '${app}-taas-extension' 与有效的 id 模式不匹配。@ 第 18 行,第 19 列
Plugins 元素放置在 build 中,如下所示:
<build>
<pluginManagement>
<plugins>
<plugin>
....
</plugin>
</plugins>
</pluginManagement>
</build>
我错过了强制插件的基础知识吗?