簡體   English   中英

如何直接從命令行執行 maven 插件執行?

[英]How to execute maven plugin execution directly from command line?

我有一個配置了執行的插件 (antrun),它有一個 id 並且沒有綁定到任何階段。 我可以直接從命令行執行這個執行嗎?

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>my-execution</id>
      ...
    </execution>
  </executions>
</plugin>

用類似的東西運行它:

mvn my-execution

或者至少

mvn magicplugin:execute -DexecutionId=my-execution

此功能已被實現MNG-5768 ,並且可在Maven的3.3.1。

變化將:

擴展直接插件調用語法以允許可選的@execution-id 參數,例如 org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId。

所以,在你的情況下:

mvn antrun:run

使用default-cli執行 ID,並且:

mvn antrun:run@my-execution

使用在你的 pom.xml 中配置的執行。

執行 Maven 插件最直接的方法是直接在命令行上指定插件目標。

mvn groupId:artifactId:version:goal

更多信息請訪問: Maven 插件開發指南

您正在尋找的內容在Default+Plugin+Execution+IDs 中捕獲,但據我所知,目前不支持。 但是,根據MNG-3401的評論(閱讀到最后):

對於直接從命令行調用的 mojo,您可以使用 executionId: 'default-cli' 從 POM 提供配置,如下所示:

 <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>default-cli</id> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>project</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin>

這應該適用於 Maven 2.2.0 和 3.x。

也許這對你來說就足夠了。

暫無
暫無

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

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