Return-Path: Delivered-To: apmail-incubator-ivy-user-archive@locus.apache.org Received: (qmail 7021 invoked from network); 6 Oct 2007 19:52:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Oct 2007 19:52:23 -0000 Received: (qmail 65779 invoked by uid 500); 6 Oct 2007 19:52:10 -0000 Delivered-To: apmail-incubator-ivy-user-archive@incubator.apache.org Received: (qmail 65625 invoked by uid 500); 6 Oct 2007 19:52:10 -0000 Mailing-List: contact ivy-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ivy-user@incubator.apache.org Delivered-To: mailing list ivy-user@incubator.apache.org Received: (qmail 65615 invoked by uid 99); 6 Oct 2007 19:52:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Oct 2007 12:52:09 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Nascif.AbousalhNeto@sas.com designates 149.173.6.153 as permitted sender) Received: from [149.173.6.153] (HELO mercav06.na.sas.com) (149.173.6.153) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Oct 2007 19:52:12 +0000 Received: from mercmbx08.na.sas.com ([10.16.9.158]) by mercav06.na.sas.com with InterScan Message Security Suite; Sat, 06 Oct 2007 15:51:50 -0400 X-MIMEOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Using Extra Attributes Date: Sat, 6 Oct 2007 15:51:48 -0400 Message-ID: <72A37CC27F2CAB44BD13E814D2F4FE0E04C92A46@mercmbx08.na.sas.com> In-Reply-To: <635a05060710060818v15863e32ned0f456651da42b0@mail.gmail.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Using Extra Attributes thread-index: AcgILDIKAGrzIQfbQMOfMPReUFTvQQAJdNRg References: <4704F74F.6060307@apache.org> <72A37CC27F2CAB44BD13E814D2F4FE0E04C922B6@mercmbx08.na.sas.com> <635a05060710050021w17481cc5ja02bceff02a14097@mail.gmail.com> <72A37CC27F2CAB44BD13E814D2F4FE0E04C926E2@mercmbx08.na.sas.com> <635a05060710051000u71d31d32wbfc05bcb9c270091@mail.gmail.com> <72A37CC27F2CAB44BD13E814D2F4FE0E04C928EE@mercmbx08.na.sas.com> <635a05060710060818v15863e32ned0f456651da42b0@mail.gmail.com> From: "Nascif Abousalh-Neto" To: X-Virus-Checked: Checked by ClamAV on apache.org I am using 1.4.1 because it is the stable version. It would be easier for our team to fix bugs and provide patches against the beta once it is released. Unfortunately this is for production and consumed by a really large number of developers in our corporation, and management just doesn't like the sound of "alpha"...=20 I will add the unit test to a jira entry.=20 Thanks, Nascif -----Original Message----- From: Xavier Hanin [mailto:xavier.hanin@gmail.com]=20 Sent: Saturday, October 06, 2007 11:18 AM To: ivy-user@incubator.apache.org Subject: Re: Using Extra Attributes On 10/5/07, Nascif Abousalh-Neto wrote: > > Thanks for the explanation. Perhaps some clarification that using extra > attributes require that you use the attribute as part of the pattern if > they are to be used to resolve dynamic versions should be added to the > web site. Indeed, extra attributes would deserve some more documentation. Maybe a tutorial, or a follow up to another tutorial... Since you have worked in this direction, maybe you could contribute something in this area? This is all I found in > http://incubator.apache.org/ivy/history/trunk/concept.html#extra > > Then you can use the extra attribute when you declare a dependency on > foo: > > > And since "1.5+" is a dynamic version I got the impression thar color > could be used to influence how it would be resolved. It should be possible if you use the color in your pattern. Anyway I tried to create a unit test to validate my use case: > public void testExtraAttributesWithLatestInPattern() throws > Exception { > Ivy ivy =3D new Ivy(); > ivy.configure(new > File("test/repositories/extra-attributes-multiple-versions/ivyconf.xml") > ); > > // without extra attribute in pattern > //ResolveReport report =3D > ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-latest-no-patte > rn.xml"), > > //with extra attribute in pattern > ResolveReport report =3D > ivy.resolve(ResolveTest.class.getResource("ivy-extra-att-latest-in-patte > rn.xml"), > null, new String[] {"*"}, _cache, null, false); > assertFalse(report.hasError()); > > assertTrue(new File(_cache, > "jayasoft/mymodule/task1/1854/ivy.xml").exists()); > assertTrue(new File(_cache, > "jayasoft/mymodule/task1/1854/mymodule-windows.jar").exists()); > assertTrue(new File(_cache, > "jayasoft/mymodule/task1/1854/mymodule-linux.jar").exists()); > } > > Where mymodule has also another version, 2854 with eatt =3D=3D task2, = and > where I use "eatt" in the pattern as in the original test case. The > result was not much better: > > name=3D"testExtraAttributesWithLatestInPattern" time=3D"0.031"> > type=3D"java.lang.NullPointerException">java.lang.NullPointerException > at > fr.jayasoft.ivy.repository.url.URLResource.getName(URLResource.java:30) > at > fr.jayasoft.ivy.external.m2.PomModuleDescriptorParser.accept(PomModuleDe > scriptorParser.java:262) > at > fr.jayasoft.ivy.parser.ModuleDescriptorParserRegistry.getParser(ModuleDe > scriptorParserRegistry.java:58) > at fr.jayasoft.ivy.Ivy.resolve(Ivy.java:1083) > at fr.jayasoft.ivy.Ivy.resolve(Ivy.java:1071) > at fr.jayasoft.ivy.Ivy.resolve(Ivy.java:1068) > at fr.jayasoft.ivy.Ivy.resolve(Ivy.java:1025) > at fr.jayasoft.ivy.Ivy.resolve(Ivy.java:1022) > at > fr.jayasoft.ivy.ResolveTest.testExtraAttributesWithLatestInPattern(Resol > veTest.java:2595) Could you open an issue and provide your unit test as a patch? It would be easier for us to see exactly what you are testing, and to include the test if it is relevant. BTW, it seems you are using 1.4, a patch against current trunk would be more appreciated :-) Xavier I think I found another way to implement my needs though. > Thanks, > Nascif > > -----Original Message----- > From: Xavier Hanin [mailto:xavier.hanin@gmail.com] > Sent: Friday, October 05, 2007 1:01 PM > To: ivy-user@incubator.apache.org > Subject: Re: Using Extra Attributes > > On 10/5/07, Nascif Abousalh-Neto wrote: > > > > I apologise, I should have included the snippets in the first e-mail. > > > > I am testing this by making changes to the multi-project example. > > So I tweaked ivy.xml and published the following revisions of the > > "version" project (below are snippets for each version's published > > ivy.xml in the repository): > > > > > > > status=3D"release" publication=3D"20071004180756" week=3D"41"/> > > > > > > > status=3D"release" publication=3D"20071004180824" week=3D"42"/> > > > > > > > status=3D"integration" publication=3D"20071004180848"/> > > > > The in the consumer project "list", I changed the dependency to read: > > > week=3D"41"/> > > > > and executed "ant resolve" with a clean cache. From the logs I can see > > that Ivy goes over all the versions > > [ivy:retrieve] pre 1.3 ivy file: using exactOrRegexp as default > matcher > > [ivy:retrieve] shared: parsed downloaded md file for [ jayasoft | > > version | latest.release ] parsed=3D[ jayasoft | version | 7 ] > > > > > > [ivy:retrieve] pre 1.3 ivy file: using exactOrRegexp as default > matcher > > [ivy:retrieve] shared: parsed downloaded md file for [ jayasoft | > > version | latest.release ] parsed=3D[ jayasoft | version | 8 ] > > > > [ivy:retrieve] pre 1.3 ivy file: using exactOrRegexp as default > matcher > > [ivy:retrieve] shared: parsed downloaded md file for [ jayasoft | > > version | latest.release ] parsed=3D[ jayasoft | version | 9 ] > > > > [ivy:retrieve] pre 1.3 ivy file: using exactOrRegexp as default > matcher > > [ivy:retrieve] shared: parsed downloaded md file for [ jayasoft | > > version | latest.release ] parsed=3D[ jayasoft | version | 9 ] > > > > After reading all the revisions in the repository, Ivy decides to ask > > for the revision "8" jar file. > > > > [ivy:retrieve] listing all in > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/ivy-[revision].xml > > [ivy:retrieve] using tpj to list all in > > > C:/home/dev/IvyNextGen/multi-project/projects/list/../../common/../tpj/j > > ayasoft/version > > [ivy:retrieve] tpj: unable to list resources for [ jayasoft | version > | > > latest.release ]: > > > pattern=3DC:\home\dev\IvyNextGen\multi-project\projects\list/../../common= / > > ../tpj/[organisation]/[module]/ivy-[revision].[ext] > > [ivy:retrieve] trying > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/jars/version-latest.release.jar > > [ivy:retrieve] listing all in > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/jars/version-[revision].jar > > [ivy:retrieve] using tpj to list all in > > > C:/home/dev/IvyNextGen/multi-project/projects/list/../../common/../tpj/j > > ayasoft/version/jars > > [ivy:retrieve] tpj: unable to list resources for [ jayasoft | version > | > > latest.release ]: > > > pattern=3DC:\home\dev\IvyNextGen\multi-project\projects\list/../../common= / > > ../tpj/[organisation]/[module]/jars/[artifact]-[revision].[ext] > > [ivy:retrieve] tpj: no ivy file nor artifact found for [ jayasoft | > > version | latest.release ] > > [ivy:retrieve] tried > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/ivy-latest.release.xml > > [ivy:retrieve] tried > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/ivy-[any release].xml > > [ivy:retrieve] tried > > > C:\home\dev\IvyNextGen\multi-project\projects\list/../../common/../tpj/j > > ayasoft/version/jars/version-latest.release.jar > > [ivy:retrieve] found [ jayasoft | version | 8 ] in shared > > [ivy:retrieve] [8] [ jayasoft | version | latest.release ] > > > > I would think it should ask for revision "7" since it is the one with > > the "week=3D41" attribute. > > > Ok, let's say that this is a limitation of what you can do with extra > attributes. With most of the version matchers Ivy tries to avoid to > read > the module descriptor to know if a version match or not. In your case > you > use a version constraint which needs to load the ivy files, but Ivy do > not > take advantage of this to filter the extra attributes. This could be > changed, but then it would be strange that when you use > latest.integration(which do not require module descriptor loading), > Ivy wouldn't take care of > the extra attribute. Loading module descriptors systematically as soon > as > you use extra attributes is not a good idea either: may users use extra > attributes without this need. > > So, what's the solution? You need to add your extra attribute in your > pattern, so that Ivy can know the value of the extra attribute depending > on > the ivy file location only, and not its content. Then your > latest.releasewith your "week" extra attribute should work properly. > > On a related question, can I use the "publication" attribute to retrieve > > a dependency? > > > Do you mean as a constraint on the dependency you select? Out of the box > you > can't, but maybe you can write a custom VersionMatcher for that. But you > will need to parse the module descriptor to do so, which can be quite > expensive. > > Xavier > > Thanks, > > Nascif > > > > > > -----Original Message----- > > From: Xavier Hanin [mailto:xavier.hanin@gmail.com] > > Sent: Friday, October 05, 2007 3:21 AM > > To: ivy-user@incubator.apache.org > > Subject: Re: Using Extra Attributes > > > > On 10/5/07, Nascif Abousalh-Neto wrote: > > > > > > I can't get extra attributes to work in 1.4.1, is this really > > supported? > > > I am looking at the functionality described in > > > http://incubator.apache.org/ivy/history/1.4.html > > > Under "Core features" > > > > > > and I tried a lot of combinations with extra attribute. I can see > them > > > in the published ivy.xml, but there is no way that I can use them to > > > influence the result of my retrieve as suggested in the examples. > > > > > > Is anybody using this feature? > > > > > > I have in the past, and we have some unit tests checking it's working, > > so > > I'd be surprised if it doesn't work at all. Could you provide some > > snippets > > of what you do and what you expect? > > > > Xavier > > > > Thanks, > > > Nascif > > > > > > > > > > > > > > > -- > > Xavier Hanin - Independent Java Consultant > > http://xhab.blogspot.com/ > > http://incubator.apache.org/ivy/ > > http://www.xoocode.org/ > > > > > > -- > Xavier Hanin - Independent Java Consultant > http://xhab.blogspot.com/ > http://incubator.apache.org/ivy/ > http://www.xoocode.org/ > --=20 Xavier Hanin - Independent Java Consultant http://xhab.blogspot.com/ http://incubator.apache.org/ivy/ http://www.xoocode.org/