2011-01-25 34 views
0

我有一堆需要在構建/部署階段使用maven-antrun-plugin執行相同順序的ant任務的maven項目。在maven插件中包裝一堆ant任務?

我不想在父項目中重寫maven-antrun-plugin的實現,所以使用此插件的所有其他項目都將繼承這些步驟。

因此,我正在尋找編寫我自己的maven插件,它可以作爲一個maven-antrun-plugin包裝器,並具有特殊的ant任務序列。但目前我沒有做到這一點。

我已經看過:

http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html

但碰上這裏描述了同樣的問題:

http://www.mail-archive.com/[email protected]/msg92676.html

(使用上述職位建議的版本並沒有解決問題)

和來自: http://www.mail-archive.com/[email protected]/msg115264.html 它看起來像本教程僅適用於在Maven2:

我也試圖從這裏偷東西:

http://maven.apache.org/guides/plugin/guide-java-plugin-development.html

,但仍然沒有工作的插件。

,我想包裝插件看起來是這樣的:

 <plugin> 
     <artifactId>maven-antrun-plugin</artifactId> 
     <executions> 
      <execution> 
      <id>test</id> 
      <phase>deploy</phase> 
      <goals> 
       <goal>run</goal> 
      </goals> 
      <configuration> 
       <tasks> 
       <!-- execute task A,B and D --> 
       </tasks> 
      </configuration> 
      </execution> 
     </executions> 
     <dependencies> 
      <dependency> 
      <groupId>org.apache.ant</groupId> 
      <artifactId>ant-jsch</artifactId> 
      <version>1.8.1</version> 
      </dependency> 
     </dependencies> 
     </plugin> 
    </plugins> 
    </build> 

是否有可能把任務A,B和C的順序列於其他插件的再使用過的位置需要的插件?

我也試圖給antrun插件移動到家長和禁用它的一些孩子們設置繼承假的:

http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_inherited_Tag_In_Build_Plugins

,但在父定義的任務仍在執行,從而將繼承設置爲false似乎不起作用。

回答

0

如果您想要在父級中定義<plugin>,並允許孩子使用它,則可以在<pluginManagement>部分中對其進行定義。通過這樣做,父母將不會執行插件。它只會執行那些在他們的pom中定義這個插件的孩子。

至於Ant任務排序,豈不是更簡單的建立在Ant腳本,調用任務A,B和C序列task並繼續使用默認maven-antrun-plugin功能?