在我调用ivy.xml时,有选择使用哪个ivy:retrieve文件的方法吗?
从在文件上的角度看,我似乎可以使用settingsRef属性来选择要使用哪个常春藤设置文件,但它不是我希望修改的ivysettings.xml文件,而是ivy.xml。我的用例如下:
ivy.xml文件,用于获取编译时和运行时依赖项。ivy.xml文件中识别这些依赖项,这样我就可以简单地跨项目复制这些依赖项。发布于 2017-02-14 18:34:34
最后我就是这样做的:
<target name="fetch-buildsystem-deps" depends="configure-ivy-settings">
<ivy:resolve file="ivy-buildsystem.xml"/>
<ivy:retrieve conf="build-system"
pattern="${lib-ivy-buildsystem.dir}/[artifact]-[revision](-[classifier]).[ext]"
sync="true"
type="jar, bundle"/>
</target>…其中,文件ivy-buildsystem.xml只标识我的常春藤任务的依赖项。例如,包含以下内容:
<configurations>
<conf name="build-system" description="artifacts needed by the build-system itself"/>
</configurations>
<dependencies>
<!--dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="build-system->master"/-->
<dependency org="com.puppycrawl.tools" name="checkstyle" rev="5.9" conf="build-system->default"/>
<dependency org="com.google.code.findbugs" name="findbugs-ant" rev="3.0.0" conf="build-system->default"/>
<dependency org="net.sourceforge.pmd" name="pmd-java" rev="5.5.3" conf="build-system->default"/>
</dependencies>发布于 2017-02-11 10:15:49
是的,但是必须在艾薇:决心中指定文件,参数称为file。他的原因是检索是一个后解决任务。
发布于 2017-02-11 12:12:31
使用常春藤配置:
http://ant.apache.org/ivy/history/latest-milestone/tutorial/conf.html
常春藤配置可用于为不同目的对依赖项进行分组。你不需要多个常春藤档案。
示例
我的目标是:
<target name="resolve" description="Download dependencies and setup classpaths">
<ivy:resolve/>
<ivy:report todir='${reports.dir}/ivy' graph='false' xml='false'/>
<ivy:cachepath pathid="compile.path" conf="compile"/>
<ivy:cachepath pathid="test.path" conf="test"/>
<ivy:cachepath pathid="build.path" conf="build"/>
</target>,然后可以直接用于需要类路径的各种任务。
<!-- Compiling code -->
<javac srcdir="${src.dir}"... classpathref="compile.path"/>
<!-- Testing code -->
<junit haltonfailure="yes" fork="true">
<classpath>
<path refid="test.path"/>
<pathelement path="${classes.dir}"/>
<pathelement path="${test.classes.dir}"/>
</classpath>
..
</junit>
<!-- 3rd party ANT tasks -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="build.path"/>
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml" classpathref="build.path"/>
..就我个人而言,我只使用检索任务来构建档案。在这里,我再次使用配置来控制我想要的jars:
<ivy:retrieve pattern="${build.dir}/libs/[artifact].[ext]" conf="runtime"/>
<war destfile="${war.file}" webxml="${resources.dir}/web.xml">
<fileset dir="${resources.dir}" excludes="web.xml"/>
<classes dir="${build.dir}/classes"/>
<lib dir="${build.dir}/libs"/>
</war>常春藤档案
<ivy-module version="2.0">
<info organisation="com.myspotontheweb" module="demo"/>
<configurations>
<conf name="compile" description="Required to compile application"/>
<conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
<conf name="test" description="Required for test only" extends="runtime"/>
<conf name="build" description="ANT task dependencies"/>
</configurations>
<dependencies>
<!-- compile dependencies -->
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="compile->default"/>
<!-- runtime dependencies -->
<dependency org="org.slf4j" name="slf4j-log4j12" rev="1.7.5" conf="runtime->default"/>
<!-- test dependencies -->
<dependency org="junit" name="junit" rev="4.11" conf="test->default"/>
<!-- Build dependencies -->
<dependency org="org.codehaus.sonar-plugins" name="sonar-ant-task" rev="2.1" conf="build->default"/>
<dependency org="org.jacoco" name="org.jacoco.ant" rev="0.6.3.201306030806" conf="build->default"/>
</dependencies>
</ivy-module>所需的配置在顶部声明。注意一些是如何设置操作的。例如,“编译”依赖项自动成为“运行时”和“测试”的一部分。
其次,配置映射至关重要:
https://stackoverflow.com/questions/42166680
复制相似问题