有没有完善的分享方式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>
托管此文件的原因是因为我不想:
我在项目的 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"/>
关于此的“肮脏”部分是我必须在目标之外执行上述步骤,因为 import task必须在顶层。另外,我仍然必须将这个 XML 包含在所有需要它的 build.xml 文件中(即仍有一些重复)。
除此之外,在其他情况下,我可能需要导入一些常见(非 Ivy)任务。如果我要使用 Ivy 的依赖项管理来提供这些任务,我仍然会遇到问题,因为当我解决依赖项时,我必须在 build.xml 中的目标内,并且无法导入(由于到上面提到的约束)。
对于我想要完成的事情有更好的解决方案吗?
最佳答案
如果您使用的是 ANT 1.8+,那么您可以直接从托管位置导入 build.xml。
http://ant.apache.org/manual/Tasks/import.html
Since Ant 1.8.0 the task can also import resources from URLs or classpath resources (which are URLs, really). If you need to know whether the current build file's source has been a file or an URL you can consult the property ant.file.type.projectname (using the same example as above ant.file.type.builddocs) which either have the value "file" or "url".
<!-- importing.xml -->
<project name="importing" basedir="." default="...">
<import file="http://myserver/ivy/ivy-tasks.xml"/>
</project>
https://stackoverflow.com/questions/1829051/
相关文章:
android - 构建错误 : Ice cream sandwich emulator on Ub
ios - 通过脚本在 Xcode 项目上启用 iCloud
ios - Xcode 4 - 专用配置设置 : build settings and scheme
iphone - Xcode:为不同的构建配置设置 GCC_PREPROCESSOR_DEFINIT
java - 无法解析不同风格android studio的方法 'getAllUserGroupB
build - 有人有使用 Gradle 构建 Eclipse RCP 应用程序的经验吗?