我正在使用Apache Ivy和Eclipse(IvyDE)并尝试解决以下问题 . I have two projects, IvyParent and IvyChild, where the child depends on the parent. 我为Eclipse Ivy Classpath Container选择了选项"Resolve dependencies in workspace" .
Eclipse autobuilder工作得很好 - 我下载并包含了所有的Ivy依赖项 . I have both the parent and child projects open and I can make realtime edits to the parent and see the compilation changes in the child.
问题是当我尝试使用Ant将子项目构建到jar中时 . 我的问题是, how can I leverage the Workspace resolver during an explicit Ant build?
我已经研究了常 Spring 藤文件系统解析器,但是我想避免的是在Ant构建子项之前必须明确重建父项目 .
我得到的错误如下:
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] module not found: org.example#ParentModule;latest.integration
[ivy:retrieve] ==== local: tried
[ivy:retrieve] ...
[ivy:retrieve] ==== shared: tried
[ivy:retrieve] ...
[ivy:retrieve] ==== public: tried
[ivy:retrieve] ...
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: UNRESOLVED DEPENDENCIES ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: org.example#ParentModule;latest.integration: not found
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
BUILD FAILED
C:\Users\user\workspace\IvyExampleChild\build.xml:15: impossible to resolve dependencies:
resolve failed - see output for details
这是父项目ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org.example" module="ParentModule" status="integration" />
<dependencies>
<dependency org="commons-lang" name="commons-lang" rev="2.6"/>
</dependencies>
</ivy-module>
这是子项目ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org.example" module="ChildModule" status="integration" />
<dependencies>
<dependency org="org.example" name="ParentModule" rev="latest.integration"/>
</dependencies>
</ivy-module>
这是子build.xml:
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="ChildModule" default="release">
<property name="build.dir" value="build" />
<property name="build.dir.classes" value="${build.dir}/classes" />
<property name="src.dir" value="src" />
<property name="output.jar" value="${build.dir}/${ant.project.name}.jar" />
<target name="clean">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${build.dir}" />
</delete>
</target>
<target name="apache-ivy" depends="clean">
<ivy:retrieve />
<ivy:cachepath pathid="ivy.build.path" conf="default" />
</target>
<target name="release" depends="apache-ivy">
<echo message="compiling ${src.dir}..." />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.dir.classes}" />
<javac srcdir="${src.dir}" destdir="${build.dir.classes}" classpathref="ivy.build.path"/>
<jar destfile="${output.jar}" basedir="${build.dir}"/>
</target>
</project>
1 回答
这是一个解析器和发布问题 . 您的ParentModule构建需要将其jar“发布”到特定目录 . 然后你的子模块构建应该使用可以找到这个特定目录的解析器 .
所以..例如,ivy_settings可能看起来像:
和你的build.xml文件应该有
这里发生的事情是我们告诉ivy关于本地构建jar文件的目录(..... / repository) .
所以你的父版本现在在它的build.xml中有一个'publish'目标:
所以..运行它并确认您的ParentModule.jar文件显示在您的存储库目录中 .
在那里,您的子模块应该能够“解析”您的父模块jar文件 .