guilhermecgs
guilhermecgs

Reputation: 3041

Resolve ivy dependencies from another project in build.xml

Disclaimer: I am a newbie using Ant + Ivy

I have the following eclipse configuration :

ProjectA depends on ProjectB and ProjectC

ProjectB depends on ProjectC

Each project has its owns ivy.xml file.

ProjectA has a build.xml file like this:

(...)

<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.

My question is:

Upvotes: 1

Views: 1416

Answers (1)

brostbeef
brostbeef

Reputation: 366

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.

For example:

  • Build ProjectB to a directory like "SharedLibrary" on your drive. (Nice little JAR file)
    • Take note of ProjectB's IVY file. It sets the org, artifact name, version, etc
  • Add the "SharedLibrary" to your ivy <resolvers> list so that IVY looks for dependencies there
  • Add the ProjectB as a dependency of ProjectA (Using the noted information from ProjectB's ivy)

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.

Upvotes: 1

Related Questions