IAmYourFaja
IAmYourFaja

Reputation: 56904

How to use Ivy to get artifacts other than JARs?

There is a Java library I want to use as part of my build, but it contains an external resources/ directory that has to be visible to the runtime classpath in order to work. I'd like to be able to store it as an artifact inside my Ivy repository, but not sure if Ivy can handle this, and if so, how to rig-up the ivy.xml, ivy-settings.xml files, as well as the repo itself.

My repo is actually an Artifactory server and I store artifacts and their ivy files right next to each other:

http://myrepo.com:8080/artifactory/simple/myrepo/
    google/
        guice/
            3.0/
                guice-3.0.jar
                ivy.xml

Etc. I guess I'm looking for a similar setup here:

http://myrepo.com:8080/artifactory/simple/myrepo/
    fizz/
        buzz/
            1.7/
                buzz-1.7.jar
                resources/
                ivy.xml

...and somehow pull down both the jar and its resources/ directory as part of the Ivy resolve/retrieve pattern, and then place resources/ where I need it to be from there.

Is this possible? Any ideas? Thanks in advance!

Edit - If the fact that resources/ is a directory causes a problem, I don't mind zipping it up as resources.zip, and then resolving/retrieving it into my project at buildtime, and then unzipping it. That's just more work to do, if Ivy can't handle directory-artifacts out of the box.

Upvotes: 4

Views: 2034

Answers (1)

oers
oers

Reputation: 18704

You should zip/tar the directory and create the following setup:

http://myrepo.com:8080/artifactory/simple/myrepo/
    fizz/
        buzz/
            1.7/
                buzz-1.7.jar
                resources-1.7.zip
                ivy-1.7.xml

In your ivy.xml you would then declare each file as a publication of this module like this:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
    <info organisation="fizz"
        module="buzz"
        revision="1.7"
        status="release"
        publication="20110531150115"
        default="true"
    />
    <configurations>
        <conf name="default" visibility="public"/>
    </configurations>
    <publications>
      <artifact name="buzz"      type="jar" />
      <artifact name="resources" type="zip" />
    </publications>
</ivy-module>

And if needed you could define separate configurations like:

    <configurations>
            <conf name="default" extends="jar, resources" visibility="public"/>
            <conf name="jar" visibility="public"/>
            <conf name="resources" visibility="public"/>
    </configurations>
    <publications>
      <artifact name="buzz"      type="jar" conf="jar"/>
      <artifact name="resources" type="zip" conf="resources"/>
    </publications>

Upvotes: 2

Related Questions