简体   繁体   English

在build.xml中解决来自另一个项目的ivy依赖项

[英]Resolve ivy dependencies from another project in build.xml

Disclaimer: I am a newbie using Ant + Ivy 免责声明:我是使用Ant + Ivy的新手

I have the following eclipse configuration : 我有以下Eclipse配置:

ProjectA depends on ProjectB and ProjectC ProjectA取决于ProjectBProjectC

ProjectB depends on ProjectC ProjectB取决于ProjectC

Each project has its owns ivy.xml file. 每个项目都有自己的ivy.xml文件。

ProjectA has a build.xml file like this: ProjectA具有一个build.xml文件,如下所示:

(...)

<ivy:resolve file="../ProjectC/ivy.xml" />
<ivy:cachepath pathid="ivy.deps.default" conf="default" />
<ivy:cachefileset setid="ivy.deps.default.fileset" conf="default"/>


<ivy:resolve file="../ProjectB/ivy.xml" />
<ivy:cachepath pathid="ivy.deps.default" conf="default" />
<ivy:cachefileset setid="ivy.deps.default.fileset" conf="default"/>


<ivy:resolve file="ivy.xml" />
<ivy:cachepath pathid="ivy.deps.default" conf="default" />
<ivy:cachefileset setid="ivy.deps.default.fileset" conf="default"/>

<path id="classpath">
    <fileset dir="${webroot}/WEB-INF/lib" erroronmissingdir="no">
        <include name="*.jar"/>
    </fileset>
    <fileset dir="${libraries}" erroronmissingdir="no">
        <include name="*.jar"/>
    </fileset>
    <path refid="ivy.deps.default"/>
</path>

    (...)

<javac destdir="c:/abc" includeantruntime="yes" classpathref="ivy.deps.default">
                        <src path="../ProjectC/src"/>
                        <classpath refid="classpath"/>
                    </javac>

 (... Compile ProjectB ...)
 (... Compile ProjectA ...)

So, running this build.xml results in error, saying that ProjectC could not compile because it was missing a *.jar file that should have been resolved by ivy:resolve command. 因此,运行此build.xml会导致错误,表示ProjectC无法编译,因为它缺少本应由ivy:resolve命令解决的* .jar文件。

My question is: 我的问题是:

  • How do I make a build.xml that automatically retrieve the dependencies from child projects and also compile all child projects? 我该如何构建一个build.xml来自动从子项目中检索依赖项并编译所有子项目?

Looks like you have an ivy file for each project, but you do not have a build file for each project. 看起来每个项目都有一个常春藤文件,但是每个项目都没有构建文件。 As Mark said in the above comment, each project should build individually. 正如Mark在上述评论中所说,每个项目应单独构建。

For example: 例如:

  • Build ProjectB to a directory like "SharedLibrary" on your drive. 将ProjectB生成到驱动器上类似“ SharedLibrary”的目录。 (Nice little JAR file) (不错的JAR小文件)
    • Take note of ProjectB's IVY file. 记下ProjectB的IVY文件。 It sets the org, artifact name, version, etc 它设置组织,工件名称,版本等
  • Add the "SharedLibrary" to your ivy <resolvers> list so that IVY looks for dependencies there 将“ SharedLibrary”添加到您的常春藤<resolvers>列表中,以便IVY在此处查找依赖项
  • Add the ProjectB as a dependency of ProjectA (Using the noted information from ProjectB's ivy) 将ProjectB添加为ProjectA的依赖项(使用来自ProjectB常春藤的注释信息)

That should get you off to the races! 那应该让您参加比赛!

Pro Tip: instead of a "SharedLibrary" directory, consider using something like Artifactory to manage the artifacts and pull from there instead. 专业提示:而不是“SharedLibrary”目录下,可以考虑使用喜欢的事Artifactory的管理文物,并从那里,而不是拉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM