簡體   English   中英

Maven 執行器插件未強制執行

[英]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 ; 為此,我使用了執行器插件:

 <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:值為“${app}-taas-extension”的test-jar 與有效的ID 模式不匹配。 @ 第 18 行,第 19 列

Plugins 元素放置在 build 中,如下所示:

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

我是否缺少執行器插件的基礎知識?

Deepak,這可能是因為某些其他插件/依賴項在強制插件之前編寫了占位符 ${app}。

我猜你的插件定義在<pluginManagement>里面。 將它移動到 POM 的<plugins>部分。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM