maven classifier on ant install task
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: net.sf.json-lib json-lib 2.4 jdk15 However, I'm using install tasks that look like: How should I declare the "classifier" on an "install" task? Thanks, Andy
Re: maven classifier on ant install task
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: Ant build: > On 28 January 2014 at 19:05 Kirby Files 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 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 wrote: > >> > >> There are a couple of things you need: > >> > >> * You need to add the following line to the top of your ivy.xml file: > >> > >> 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: > >> > >> >> name="json-lib" > >> rev="2.4" > >> conf="compile->default"> > >> >> type="jar" > >> ext="jar" > >> maven:classifier="jdk15"/> > >> > >> > >> > >> -- > >> David Weintraub > >> qazw...@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, a...@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: > >>> > >>> > >>> net.sf.json-lib > >>> json-lib > >>> 2.4 > >>> jdk15 > >>> > >>> > >>> However, I'm using install tasks that look like: > >>> > >>> >>> from="chain" > >>> to="fs1" transitive="true" overwrite="true"/> > >>> > >>> How should I declare the "classifier" on an "install" task? > >>> > >>> Thanks, Andy > >>
Re: maven classifier on ant install task
Hi, thanks for your answer once again. My ivysettings.xml file now looks like: 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] :: downloading artifacts to cache :: [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] :: FAILED DOWNLOADS :: [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 The other libraries are downloaded as expected. Cheers, Andy > On 29 January 2014 at 21:32 Marc De Boeck 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: > > > (-[classifier]).[ext]"/> > > > 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 a...@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 > > 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 repos
Re: maven classifier on ant install task
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: 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 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 a...@far2gone.com <mailto:a...@far2gone.com> <mailto:a...@far2gone.com> >: >> >Hi, > > > >thanks for your answer once again. > > > >My ivysettings.xml file now looks like: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > pattern="${dest.repo.dir}/no-namespace/[organisation]/[module]/ivys/ivy-[revision](-[classifier]).xml" > > /> > > > > > > > pattern="${dest.repo.dir}/no-namespace/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]" > > /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/> > > > > > > > > > > > > > > > > > > > > > >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] :: downloading artifacts to cache :: > >[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] :: FAILED DOWNLOADS :: > >[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 > > > > > > > >The other libraries are downloaded as expected. > > > > > > > >Cheers, Andy > > > >> On 29 January 2014 at 21:32 Marc De Boeck < mdeb...@gmail.com > >> <mailto:mdeb...@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: > >> > >> > >> >> (-[classifier]).[ext]"/> > >> > >> > >> You should also add in the same way the artifact pattern for your cache > >> and > >> for your local repo. O