Ant 继承 Maven 属性 [英] Ant inheriting Maven properties

查看:34
本文介绍了Ant 继承 Maven 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 Ant/Ivy 项目转换为 Ant/Maven-Ant-Tasks.我不想单独使用 Maven,因为我需要对构建过程进行更多控制.

I am considering converting an Ant/Ivy project to Ant/Maven-Ant-Tasks. I do not want to use Maven by itself because I need more control over the build process.

Ant build.xml 文件有没有办法继承在 pom.xml 文件中设置的属性?

Is there any way for the Ant build.xml file inherit properties set in the pom.xml file?

我一直在创建一个通用的 build.xml 文件,它可以在多个项目中使用并加载一个项目特定的 project.properties 文件,但如果我能将所有这些属性放在 pom.xml 文件中会更好.

I have been creating a generic build.xml file that can be used across several projects and loads a project-specific project.properties file, but it would be nicer if I could put all of those properties in the pom.xml file.

谢谢.

推荐答案

我使用 XMLProperty ant 任务来解析和复制这些属性

I use the XMLProperty ant task to parse and copy those properties

http://ant.apache.org/manual/Tasks/xmlproperty.html

<xmlproperty file="<your pom location>" keepRoot="false"/>
<property name="test"   value="${properties.test}"/>

另一种选择,如果您使用 maven Antrun 插件运行构建,则构建文件中将可以使用这些属性

Another option, if you use the maven Antrun plugin to run the build, the properties will be available to use in the build file

http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

这篇关于Ant 继承 Maven 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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