Rob*_*ska 12 ant build-process build ivy dependency-management
有没有一种完善的方式在项目之间共享Ant目标?我目前有一个解决方案,但它有点不优雅.这是我到目前为止所做的.
我ivy-tasks.xml的网络服务器上有一个名为托管的文件.此文件包含用于管理与Ivy的项目依赖关系的样板任务.例如:
<project name="ant-ivy-tasks" default="init-ivy"
xmlns:ivy="antlib:org.apache.ivy.ant">
...
<target name="ivy-download" unless="skip.ivy.download">
<mkdir dir="${ivy.jar.dir}"/>
<echo message="Installing ivy..."/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="ivy-init" depends="ivy-download"
description="-> Defines ivy tasks and loads global settings">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant"
classpathref="ivy.lib.path"/>
<ivy:settings url="http://myserver/ivy/settings/ivysettings-user.xml"/>
</target>
...
</project>
Run Code Online (Sandbox Code Playgroud)
这个文件被托管的原因是因为我不希望:
我在项目的build.xmls中对此文件的处理方式如下:
<property name="download.dir" location="download"/>
<mkdir dir="${download.dir}"/>
<echo message="Downloading import files to ${download.dir}"/>
<get src="http://myserver/ivy/ivy-tasks.xml" dest="${download.dir}/ivy-tasks.xml" usetimestamp="true"/>
<import file="${download.dir}/ivy-tasks.xml"/>
Run Code Online (Sandbox Code Playgroud)
关于这一点的"脏"部分是我必须在目标之外执行上述步骤,因为导入任务必须位于顶层.另外,我仍然需要在所有需要它的build.xml文件中包含这个XML(即仍有一些重复).
最重要的是,可能还有其他情况我可能会执行我想要导入的常见(非常春藤)任务.如果我使用Ivy的依赖管理来提供这些任务,我仍然会遇到问题,因为当我解决了依赖关系时,我必须在build.xml中的目标内部,并且无法导入(由于到上面提到的约束).
对于我想要实现的目标,有更好的解决方案吗?
如果您使用的是ANT 1.8+,则可以直接从托管位置导入build.xml.
http://ant.apache.org/manual/Tasks/import.html
从Ant 1.8.0开始,任务也可以从URL或类路径资源(实际上是URL)导入资源.如果您需要知道当前构建文件的源是文件还是URL,您可以查询属性ant.file.type.projectname(使用与上面相同的示例ant.file.type.builddocs),该属性具有值"文件"或"网址".
<!-- importing.xml -->
<project name="importing" basedir="." default="...">
<import file="http://myserver/ivy/ivy-tasks.xml"/>
</project>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3257 次 |
| 最近记录: |