# ant-ivy-user mailing list archives

##### Site index · List index
Message view
Top
From "andy@far2gone.com" <a...@far2gone.com>
Subject Re: maven classifier on ant install task
Date Mon, 10 Feb 2014 16:22:15 GMT
```Hi,

I've been deleting my cache prior to running the build.

The only way I can seem to make this work is to have a second resolver which has
the classifier hard-coded, ie:

<chain name="chain" returnFirst="true" dual="true">

<ibiblio name="central" m2compatible="true" checkconsistency="false"

pattern="[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/>

<ibiblio name="central2" m2compatible="true" checkconsistency="false"

pattern="[organisation]/[module]/[revision]/[artifact]-[revision]-jdk15.[ext]"/>

</chain>

This seems to work (at least all the jars I expect to find are being downloaded
to my local repo).

Cheers, Andy

> On 04 February 2014 at 06:55 Marc De Boeck <mdeboec@gmail.com> wrote:
>
>  You may have to remove the json-lib entry in your cache. Check also how the
> artifacts were stored in the cache. Could you find the jdk-specific artifacts
> there ?
>
>  Marc
>
>
>  2014-02-03 andy@far2gone.com <mailto:andy@far2gone.com> <andy@far2gone.com
> <mailto:andy@far2gone.com> >:
>    > >    Hi,
> >
> >
> >    My ivysettings.xml file now looks like:
> >
> >
> >    <ivysettings>
> >
> >      <settings defaultResolver="chain" defaultConflictManager="all" /> <!--
> > get all revisions without any eviction -->
> >
> >      <caches defaultCacheDir="\${ivy.cache.dir}/no-namespace" />
> >
> >      <resolvers>
> >
> >        <filesystem name="fs1">
> >          <ivy
> >
> >             pattern="\${dest.repo.dir}/no-namespace/[organisation]/[module]/ivys/ivy-[revision](-[classifier]).xml"
> > />
> >          <artifact
> >
> >             pattern="\${dest.repo.dir}/no-namespace/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"
> > />
> >
> >
> >        </filesystem>
> >
> >
> >        <chain name="chain" returnFirst="true" dual="true">
> >
> >
> >
> >
> >
> >          <ibiblio name="central" m2compatible="true"
> >
> >             pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/>
> >
> >
> >
> >        </chain>
> >
> >      </resolvers>
> >
> >    </ivysettings>
> >
> >
> >    Unfortunately, when I run the ant task the result is:
> >
> >
> >
> >    [ivy:install] :: installing net.sf.json-lib#json-lib;2.4 ::
> >    [ivy:install] :: resolving dependencies ::
> >    [ivy:install] found net.sf.json-lib#json-lib;2.4 in chain
> >    [ivy:install] :: installing in fs1 ::
> >    [ivy:install] published ivy to
> > c:\tmp\ivy-test\repo\no-namespace\net.sf.json-lib\json-lib\ivys\ivy-2.4.xml
> >    [ivy:install] :: install resolution report ::
> >    [ivy:install] :: resolution report :: resolve 0ms :: artifacts dl 175ms
> >    ---------------------------------------------------------------------
> >    | | modules || artifacts |
> >    | conf | number| search|dwnlded|evicted|| number|dwnlded|
> >    ---------------------------------------------------------------------
> >    | default | 1 | 0 | 0 | 0 || 1 | 0 |
> >    ---------------------------------------------------------------------
> >    [ivy:install]
> >    [ivy:install] :: problems summary ::
> >    [ivy:install] :::: WARNINGS
> >    [ivy:install] [FAILED ] net.sf.json-lib#json-lib;2.4!json-lib.jar: (0ms)
> >    [ivy:install] ==== central: tried
> >
> >   [ivy:install]<http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar>
> >    [ivy:install] ::::::::::::::::::::::::::::::::::::::::::::::
> >    [ivy:install] :: ^ see resolution messages for details ^ ::
> >    [ivy:install] ::::::::::::::::::::::::::::::::::::::::::::::
> >    [ivy:install] :: net.sf.json-lib#json-lib;2.4!json-lib.jar
> >    [ivy:install] ::::::::::::::::::::::::::::::::::::::::::::::
> >    [ivy:install]
> >    [ivy:install]
> >    [ivy:install] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
> >
> >    BUILD FAILED
> >    D:\ar-work\tmp\ivy-classifier-test\build.xml:32: Problem happened while
> > installing modules - see output for details
> >
> >
> >
> >
> >
> >
> >    Cheers, Andy
> >
> >    > On 29 January 2014 at 21:32 Marc De Boeck < mdeboec@gmail.com
> >    > <mailto:mdeboec@gmail.com> > wrote:
> >    >
> >    >
> >    > I could reproduce the problem you are describing.
> >    > It seems that the pom-file of this json-lib is not consistent with the
> >    > published artifacts.
> >    >
> >    > Try to specify the artifact pattern in your central resolver to
> >    > something
> >    > like this:
> >    >
> >    > <ibiblio name="central" m2compatible="true">
> >    > <pattern="[organisation]/[module]/[revision]/[artifact]-[revision]
> >    > (-[classifier]).[ext]"/>
> >    > </ibiblio>
> >    >
> >    > You should also add in the same way the artifact pattern for your cache
> >    > and
> >    > for your local repo. Otherwise, all these artifacts will be mapped to
> >    > the
> >    > same artifact name, and only one of the artifacts will end up in your
> >    > local
> >    > repo.
> >    >
> >    > Regards,
> >    > Marc
> >    >
> >    >
> >    >
> >    >
> >    > 2014-01-29 andy@far2gone.com <mailto:andy@far2gone.com> <
> >    > andy@far2gone.com <mailto:andy@far2gone.com> >
> >    >
> >    > > Hi,
> >    > >
> >    > > I think my use case is straightforward, I want to use Ivy to make a
> >    > > local
> >    > > Ivy
> >    > > repository of libraries available in maven central. This repository
> >    > > is
> >    > > then used
> >    > > to find dependencies declared in a gradle build.
> >    > >
> >    > > The intent is to have a build script that will automatically trundle
> >    > > off
> >    > > and
> >    > > collect all the jars requested in "install" tasks and store them
> >    > > locally
> >    > > (whether on the laptop of a developer who is new to the project or
on
> >    > > a CI
> >    > > server etc.).
> >    > >
> >    > > I think the problem I face is that without declaring a classifier in
> >    > > the
> >    > > install
> >    > >
> >    > > I don't think I'm trying to prematurely refine the content of the
> >    > > repository, in
> >    > > fact I'd be happy if all the available variants were downloaded, the
> >    > > problem is
> >    > >
> >    > > I suspect the reason is as follows, if you take a look at the maven
> >    > > web
> >    > > site
> >    > > page for json-lib at:
> >    > >
> >    > ><http://mvnrepository.com/artifact/net.sf.json-lib/json-lib/2.4>
> >    > >
> >    > >
> >    > >
> >    > ><http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar>
> >    > >
> >    > >
> >    > > Looking in the directory in which the jar files are stored:
> >    > >
> >    > ><http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/>
> >    > >
> >    > > It can be seen that the jar file names all include a jdk13 or a jdk15
> >    > > in
> >    > > the
> >    > > file name.
> >    > >
> >    > > So, I think I need to persuade Ivy to put a jdk15 somewhere in the
> >    > > file
> >    > > name it
> >    > > is expecting?
> >    > >
> >    > > If I were using specific Ivy dependencies I think I would use a
> >    > > classifier
> >    > > in
> >    > > the dependency statement to achieve this.
> >    > >
> >    > > Where I get completely unstuck is figuring out how to persuade an Ivy
> >    > > install to
> >    > > download the files (either all of them or just the ones I ask for)...
> >    > >
> >    > > My setup is copied pretty much verbatim from the Ivy repository
> >    > > tutorial,
> >    > > ivy
> >    > > settings and ant build copied below.
> >    > >
> >    > > Cheers, Andy
> >    > >
> >    > > Ivy settings:
> >    > >
> >    > > <ivysettings>
> >    > >
> >    > > <settings defaultResolver="chain" defaultConflictManager="all" />
> >    > > <!--
> >    > > get all
> >    > > revisions without any eviction -->
> >    > >
> >    > > <caches defaultCacheDir="\${ivy.cache.dir}/no-namespace" />
> >    > >
> >    > > <resolvers>
> >    > >
> >    > > <filesystem name="fs1">
> >    > > <ivy
> >    > >
> >    > > pattern="\${dest.repo.dir}/no-namespace/[organisation]/[module]/ivys/ivy-[revision].xml"
> >    > > />
> >    > > <artifact
> >    > >
> >    > > pattern="\${dest.repo.dir}/no-namespace/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"
> >    > > />
> >    > > </filesystem>
> >    > >
> >    > >
> >    > > <chain name="chain" returnFirst="true" dual="true">
> >    > >
> >    > > <ibiblio name="central" m2compatible="true"/>
> >    > >
> >    > > </chain>
> >    > >
> >    > > <ibiblio name="libraries" m2compatible="true" />
> >    > >
> >    > > </resolvers>
> >    > >
> >    > > </ivysettings>
> >    > >
> >    > >
> >    > > Ant build:
> >    > >
> >    > > <target name="install-libs" description="--> install module from
> >    > > maven 2
> >    > > repository" depends="init-ivy">
> >    > >
> >    > > <property name="dest.repo.dir" value="\${externalBuildDir}/\${repoDir}"
> >    > > />
> >    > > <property name="ivy.cache.dir"
> >    > > value="\${externalBuildDir}/\${ivyCacheDir}"/>
> >    > >
> >    > > <ivy:settings file="\${basedir}/ivysettings.xml"/>
> >    > >
> >    > > <ivy:install organisation="log4j" module="log4j" revision="1.2.17"
> >    > > from="chain"
> >    > > to="fs1" transitive="true" overwrite="true"/>
> >    > >
> >    > > <ivy:install organisation="org.apache.solr" module="solr-solrj"
> >    > > revision="4.5.1"
> >    > > from="chain" to="fs1" transitive="true" overwrite="true"/>
> >    > >
> >    > > <!-- a load of other libraries that install ok -->
> >    > >
> >    > > <!-- the cause of my woe -->
> >    > > <ivy:install organisation="net.sf.json-lib" module="json-lib"
> >    > > revision="2.4"
> >    > > from="chain" to="fs1" transitive="false" overwrite="true" />
> >    > >
> >    > > </target>
> >    > >
> >    > >
> >    > > > On 28 January 2014 at 19:05 Kirby Files < kirby.files@masergy.com
> >    > > > <mailto:kirby.files@masergy.com> > wrote:
> >    > > >
> >    > > >
> >    > > > The install task is for copying entire modules into a repository.
> >    > > > You
> >    > > > typically don't do surgery on the artifacts, filtering by type
or
> >    > > > classifier, at this point. Once it's in your repository, you use
> >    > > > the
> >    > > > retrieve task to pull specific artifacts from dependencies.
> >    > > >
> >    > > > Perhaps you can explain your use case a little more, and
> >    > > > demonstrate
> >    > > > what you hope to accomplish with the install task.
> >    > > >
> >    > > > --Kirby
> >    > > >
> >    > > > Sent from my mobile device
> >    > > >
> >    > > > On Jan 28, 2014, at 1:30 PM, Andy Redhead < andy@far2gone.com
> >    > > > <mailto:andy@far2gone.com> > wrote:
> >    > > >
> >    > > > > Hi,
> >    > > > > Thanks for your reply and if I was using a dependency then
I
> >    > > > > think this
> >    > > > > would be sufficient.
> >    > > > >
> >    > > > > What I really need is the equivalent for the install task.
> >    > > > >
> >    > > > > Cheers, Andy
> >    > > > >
> >    > > > > On 28 Jan 2014 14:44, David Weintraub < qazwart@gmail.com
> >    > > > > <mailto:qazwart@gmail.com> > wrote:
> >    > > > >>
> >    > > > >> There are a couple of things you need:
> >    > > > >>
> >    > > > >> * You need to add the following line to the top of your
ivy.xml
> >    > > > >> file:
> >    > > > >>
> >    > > > >> <ivy-module version="1.0" xmlns:maven="<http://maven.apache.org>
> >    > > > >> ">
> >    > > > >>
> >    > > > >> Note the "xmlns" declaration. It doesn't matter where
it points
> >    > > > >> to (I
> >    > > like
> >    > > > >> using the URL of the project), you just need to declare
the
> >    > > > >> namespace.
> >    > > > >>
> >    > > > >> * Now, you can use that Maven classifier in your dependency
> >    > > declaration:
> >    > > > >>
> >    > > > >> <dependency org="net.sf.json-lib"
> >    > > > >> name="json-lib"
> >    > > > >> rev="2.4"
> >    > > > >> conf="compile->default">
> >    > > > >> <artifact name="json-lib"
> >    > > > >> type="jar"
> >    > > > >> ext="jar"
> >    > > > >> maven:classifier="jdk15"/>
> >    > > > >> </dependency>
> >    > > > >>
> >    > > > >>
> >    > > > >> --
> >    > > > >> David Weintraub
> >    > > > >> qazwart@gmail.com <mailto:qazwart@gmail.com>
> >    > > > >>
> >    > > > >> ================================================
> >    > > > >> Sure, call me crazy. They called Eddie Antar crazy too,
but
> >    > > > >> look at these low, low prices on all of these famous
name brand
> >    > > appliances.
> >    > > > >>
> >    > > > >>
> >    > > > >> On Jan 28, 2014, at 8:40 AM, andy@far2gone.com
> >    > > > >> <mailto:andy@far2gone.com> wrote:
> >    > > > >>
> >    > > > >>> Hi,
> >    > > > >>>
> >    > > > >>> I've been having a go at using the Ivy Install ant
> >    > > > >>> create a
> >    > > local
> >    > > > >>> repository based on libraries downloaded from maven
central.
> >    > > > >>>
> >    > > > >>> Having gone along with the tutorial, all seemed to
be working
> >    > > > >>> :)
> >    > > > >>>
> >    > > > >>> Until...
> >    > > > >>>
> >    > > > >>> One of the dependencies in my project is json-lib.
> >    > > > >>>
> >    > > > >>> It seems that the json-lib project uses a maven classifier
to
> >    > > discriminate
> >    > > > >>> between jars suitable for different versions of the
jvm.
> >    > > > >>>
> >    > > > >>> If I were just declaring a dependency I think I could
do this:
> >    > > > >>>
> >    > > > >>> <dependency>
> >    > > > >>> <groupId>net.sf.json-lib</groupId>
> >    > > > >>> <artifactId>json-lib</artifactId>
> >    > > > >>> <version>2.4</version>
> >    > > > >>> <classifier>jdk15</classifier>
> >    > > > >>> </dependency>
> >    > > > >>>
> >    > > > >>> However, I'm using install tasks that look like:
> >    > > > >>>
> >    > > > >>> <ivy:install organisation="log4j" module="log4j"
> >    > > > >>> revision="1.2.17"
> >    > > > >>> from="chain"
> >    > > > >>> to="fs1" transitive="true" overwrite="true"/>
> >    > > > >>>
> >    > > > >>> How should I declare the "classifier" on an "install"