ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "andy@far2gone.com" <a...@far2gone.com>
Subject Re: maven classifier on ant install task
Date Wed, 29 Jan 2014 11:34:57 GMT
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
task, non of the json-lib jars are downloaded at all.

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
that nothing is downloaded.

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

The link it gives to download the jar is:

    http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4.jar

Which gives a 404 Not Found.

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> 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> 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> 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
> >>
> >> ================================================
> >> 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 wrote:
> >>
> >>> Hi,
> >>>
> >>> I've been having a go at using the Ivy Install ant task to 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" task?
> >>>
> >>> Thanks, Andy
> >>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message