Maven强制实施器插件未强制执行

问题描述

在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强制任何人传递param -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.automation的'dependencies.dependency.artifactId':$ {app} -xyz-extension:值为'$ {app} -taas-extension'的test-jar与有效的ID模式不匹配。 @第18行,第19列

插件元素按如下所示放置在内部版本中:

<build>
<pluginManagement>
  <plugins>
    <plugin>
         ....
    </plugin>
  </plugins>
</pluginManagement>
</build>

我是否缺少执行程序插件的基础知识?

解决方法

Deepak,可能是因为其他一些插件/依赖项在强制插件之前写了占位符$ {app}。

,

我猜您的插件定义在<pluginManagement>内部。将其移至POM的<plugins>部分。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...