Ivy: Obtener Javadocs y fuentes

I'm fairly new to Ivy, but have gotten it to work with jar dependencies. The problem is trying to set it up, so I can fetch javadocs and sources independently of jars.

I have a simple test project, but no matter what I'm doing, I'm fetching the jar with the class files in it.

Tengo lo siguiente ivy.xml archivo:

<ivy-module version="1.0">

        <conf name="default" visibility="public" extends="runtime,master"/>
        <conf name="master" visibility="public"/>
        <conf name="compile" visibility="public"/>
        <conf name="provided" visibility="public"/>
        <conf name="runtime" visibility="public" extends="compile"/>
        <conf name="test" visibility="private" extends="runtime"/>
        <conf name="system" visibility="public"/>
        <conf name="sources" visibility="public"/>
        <conf name="javadoc" visibility="public"/>
        <conf name="optional" visibility="public"/>

        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
            <artifact name="commons-logging" type="sources" ext="jar"/>
        <dependency org="commons-logging" name="commons-logging" rev="1.1.1"
            <artifact name="commons-logging" type="javadoc" ext="jar"/>

Y lo siguiente build.xml:

<project name="ivy-test" default="default" basedir="."

    <property name="ivy.dir" value="${basedir}/ivy.dir"/>
    <import file="${ivy.dir}/ivy.tasks.xml"/>

    <property name="target.dir" value="${basedir}/lib"/>
    <target name="-resolve">

    <target name="clean">
        <delete dir="${target.dir}"/>

    <target name="default"

        <fail message="ivy.conf is not defined">
                    <isset property="ivy.conf"/>

        <delete dir="${target.dir}"/>
        <mkdir dir="${target.dir}"/>
        <ivy:retrieve conf="${ivy.conf}"

At the command line, I'll type:

$ ant -Divy.conf=compile

And, that should download the jarfile with the classes.

However if I type it this:

$ ant -Divy.conf=sources

I want the jar file that contains the sources and not the classes, and when I type this:

$ ant -Divy.conf=javadoc

I want the jar file that contains the javadoc and not the sources.

I'm pretty sure it's my ivy.xml that's not quite right. I originally tried this:

    <dependency org="commons-logging" name="commons-logging" rev="1.1.1">
        <artifact name="commons-logging" type="jar" ext="jar" conf="compile->default"/>
        <artifact name="commons-logging" type="sources" ext="jar" conf="sources->default"/>
        <artifact name="commons-logging" type="javadoc" ext="jar" conf="javadoc->default"/>

That downloaded the jar, the sources, and javadoc, but all at once no matter which configuration I tried.

preguntado el 06 de septiembre de 12 a las 18:09

1 Respuestas

Okay, I think I've figured it out. I was over thinking this whole process. My <dependencies> La sección debería verse así:

    <dependency org="commons-logging" name="commons-logging" rev="1.1.1"

This maps my javadoc to Maven's javadoc y mi sources to Maven's sources. When I mapped conf="sources->default", it was mapping my sources to Maven's default which is the compile dependencies.

I can specify all the configurations in one line, and I don't need separate <artifact> entidades.

Respondido el 06 de Septiembre de 12 a las 18:09

I found if I don't map my configuration to default, I get everything whether I want it or not. In your example, if I said <ivy:retrieve conf="compile"/>, I'll get the jar, the javadoc, and the sources. In that case, I only want the classes jar. If I say <ivy:retrieve conf="javadoc"/> I only want the Javadoc. - David W.

yeah right :) I forgot that default is the maven scope for the single jar. So it could be shortened to conf="javadoc;sources;compile->default" I think. - ofertas

Nope. I tried that and both <ivy:retrieve conf="compile"/> y <ivy:retrieve conf="javadoc"/> will both pull the standard jar with the classes. The problem is that you have to map your compile to Maven's default, Su javadoc to Maven's javadoc, Y su sources to Maven's sources. Por lo tanto, la conf="compile->default;sources->sources;javadoc->javadoc". This maps all three of my configurations to all three of Maven's scopes. This is quite confusing. I worked on it for a few hours, asked at SO, and worked on it another hour before I figured it out. - David W.

It's possible to specify configurations defaultconfmapping="compile->master;runtime->default;sources->@;javadoc->@" and then just use dependencies with conf="compile,javadoc,sources" without unwanted extra mappings. - Vadzim

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.