在重用多模块Maven构建ANT-片段 [英] Reusing ant-snippets in multi-module maven build

查看:187
本文介绍了在重用多模块Maven构建ANT-片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能重用在多个项目上的蚂蚁片段?可以说,我有我的根以下的pom.xml

How can I reuse an ant snippet in multiple projects? Lets say I have the following in my root pom.xml:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>gen-index</id>
            <phase>package</phase>
            <configuration>
                <target>
                    ... some non-trivial ant stuff here ...
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        <execution>
    </executions>
</plugin>

我怎么能对选定的子项目执行该蚂蚁片段?我试着加入&LT;插件&GT; ...&LT; /插件&GT; 以上部分&LT; pluginManagement&GT; ... ,但我无法弄清楚如何指定哪些子项目蚂蚁段应运行。

How can I have this ant snippet executed for selected sub-projects? I've tried adding the <plugin>...</plugin> part above to <pluginManagement>..., but I can't figure out how to specify for which sub-projects the ant snippet should be run.

推荐答案

我假设你的目标实现你的插件的定义是父pom.xml中的pluginManagement部分内部

i assume that your plugin definition with your target implementation is inside a pluginManagement section of a parent pom.xml

您Ant目标是创指数标识的执行中。它应该是工作,如果你宣布一些像这样的事情在你的孩子的项目(但这次不是pluginManagement部分内... !!!):

your ant target is inside a execution identified by "gen-index". it should be work if you declare some thing like this in your child project (but this time not inside a pluginManagement section...!!!):

<build>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>gen-index</id>
                <execution>
            </executions>
        </plugin>
    </plugins>
</build>

这执行由父POM继承与同identifiert目标。

this executes the target inherited by the parent pom with the same identifiert.

我希望这个作品4你。我用这几次这样的..

i hope this works four you. i used this several times like this..

这个星座的,你可以在你的父母的pom.xml多个相同的插件里面。

with this constellation you could have more than one inside the same plugin in your parent pom.xml.

我创建了一个GitHub的资源库和一个工作示例: https://github.com/StefanHeimberg/stackoverflow -16056194

I have created a GitHub repository with a working example: https://github.com/StefanHeimberg/stackoverflow-16056194

这篇关于在重用多模块Maven构建ANT-片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆