You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Alan She <sc...@gmail.com> on 2008/01/01 17:23:42 UTC

How can I retrieve binary files and source files in one shot?

Hi,

Is there any way to retrieve binary and sources
by ibiblio resolver in one shot and put the
binary jar file in lib/ and put the sources jar file in libsrc/  ?

I used maven ant task (an ant task for ant user to load libraries from
maven2 repo) before,
it can do this by something like the following:
    <target name="retrieve-dependencies" description="Load libraries from
maven2 repository.">
        <artifact:dependencies filesetId="dependency.fileset"
                               sourcesFilesetId="sources.dependency.fileset"
                               versionsId="dependency.versions">
            <pom file="pom.xml"/>
        </artifact:dependencies>
        <delete dir="${path.lib}"/>
        <copy todir="${path.lib}">
            <fileset refid="dependency.fileset"/>
            <mapper classpathref="maven-ant-tasks.classpath" classname="
org.apache.maven.artifact.ant.VersionMapper"
                    from="${dependency.versions}" to="flatten"/>
        </copy>
        <delete dir="${path.libsrc}"/>
        <copy todir="${path.libsrc}">
            <fileset refid="sources.dependency.fileset"/>
            <mapper classpathref="maven-ant-tasks.classpath" classname="
org.apache.maven.artifact.ant.VersionMapper"
                    from="${dependency.versions}" to="flatten"/>
        </copy>
    </target>

I noticed that the pattern of ibiblio resolver has a (-[classifier]) which
seems to be useful to this problem.
But I have no idea how to get this work.
Would you mind to give me some hints?

Thanks a lot!

Alan She

Re: How can I retrieve binary files and source files in one shot?

Posted by Xavier Hanin <xa...@gmail.com>.
On Jan 1, 2008 5:23 PM, Alan She <sc...@gmail.com> wrote:

> Hi,
>
> Is there any way to retrieve binary and sources
> by ibiblio resolver in one shot and put the
> binary jar file in lib/ and put the sources jar file in libsrc/  ?

The problem is that the metadata in the maven repository does not provide
any information on the presence or not of sources or javadocs, which is not
how Ivy is designed. In IvyDE we work around this problem by resolving an
artifact (the source artifact) not declared in metadata, so you can do it
also by calling Ivy from java.
There's also a way to declare a dependency artifact from the caller which
could be used here, but this is not as straightforward as with maven tasks.
You'd need something like that in your ivy file:
<dependency org="foo" name="bar" rev="1.0" conf="binary,source->default">
  <include name="*" conf="binary"/>
  <artifact name="bar" ext="jar" type="source" classifier="source"
conf="source" />
</dependency>

Then you'll get the binary artifact in the binary conf and the source
artifact in the source configuration of your module.

HTH,

Xavier


>
> I used maven ant task (an ant task for ant user to load libraries from
> maven2 repo) before,
> it can do this by something like the following:
>    <target name="retrieve-dependencies" description="Load libraries from
> maven2 repository.">
>        <artifact:dependencies filesetId="dependency.fileset"
>                               sourcesFilesetId="sources.dependency.fileset
> "
>                               versionsId="dependency.versions">
>            <pom file="pom.xml"/>
>        </artifact:dependencies>
>        <delete dir="${path.lib}"/>
>        <copy todir="${path.lib}">
>            <fileset refid="dependency.fileset"/>
>            <mapper classpathref="maven-ant-tasks.classpath" classname="
> org.apache.maven.artifact.ant.VersionMapper"
>                    from="${dependency.versions}" to="flatten"/>
>        </copy>
>        <delete dir="${path.libsrc}"/>
>        <copy todir="${path.libsrc}">
>            <fileset refid="sources.dependency.fileset"/>
>            <mapper classpathref="maven-ant-tasks.classpath" classname="
> org.apache.maven.artifact.ant.VersionMapper"
>                    from="${dependency.versions}" to="flatten"/>
>        </copy>
>    </target>
>
> I noticed that the pattern of ibiblio resolver has a (-[classifier]) which
> seems to be useful to this problem.
> But I have no idea how to get this work.
> Would you mind to give me some hints?
>
> Thanks a lot!
>
> Alan She
>



-- 
Xavier Hanin - Independent Java Consultant
http://xhab.blogspot.com/
http://ant.apache.org/ivy/
http://www.xoocode.org/