Though I still do not fully understand the Ivy internal processing of
dependencies, I was able to get our new StrictWithForceConflictManager
working as desired for our projects. I have opened JIRA incident
IVY-1256 (https://issues.apache.org/jira/browse/IVY-1256) and provided
the code of our conflict manager subclass.

Thanks for all the help.

Greg

> -----Original Message-----
> From: Burcher, Greg
> Sent: Tuesday, December 21, 2010 11:53 AM
> To: ivy-user@ant.apache.org
> Subject: RE: Need StrictConflictManager to respect force
> 
> I'm having some trouble because I do not understand the internals of
> how
> Ivy handles the dependency metadata. I copied the algorithm from
> LatestConflictManager for resolution of conflict via the "force"
> attribute:
> 
>         for (Iterator iter = conflicts.iterator(); iter.hasNext();) {
>             IvyNode node = (IvyNode) iter.next();
>             DependencyDescriptor dd =
> node.getDependencyDescriptor(parent);
>             if (dd != null && dd.isForce()
>                     &&
> parent.getResolvedId().equals(dd.getParentRevisionId())) {
>                 return Collections.singleton(node);
>             }
>         }
> 
> I have looked some into the Ivy code, but it is difficult to tell
> exactly how this algorithm relates to the ivy.xml metadata that I need
> to provide, specifically where to place my "force" attribute to force
> resolution to a specific revision of a module.
> 
> Looking instead from the outside in, I tried to infer the algorithm by
> watching what Ivy did with various attempts to place the "force"
> attribute in different places. In general, it seems that I need to
> place
> the "force" attribute in the ivy.xml dependencies for the IvyNode
> passed
> as parent to the resolveConflicts() method. BTW, it might be nice to
> include trace of the parent name in the StrictConflictException.
> 
> I was thinking I should put the "force" in the root IvyNode, but this
> does not seem to work. Placing the "force" in the IvyNode passed as
> parent seems to work most of the time. The curious part is I'm not
sure
> what is the meaning of "parent" as opposed to "root" and why placing
> the
> "force" at the root would not carry down through all transitive
> dependencies.
> 
> In some cases, I have found that even placing the "force" at the
> IvyNode
> passed as parent does not work. In fact, I cannot find any place to
put
> the "force" that resolves the conflict. Is it possible that the
> algorithm to utilize "force" could be changed to make this process
> easier for the user? Could someone offer an explanation of the
> algorithm
> that does not presume intimate understanding of the Ivy code?
> 
> Thanks,
> 
> Greg
> 
> > -----Original Message-----
> > From: Maarten Coene [mailto:maarten_co...@yahoo.com]
> > Sent: Monday, December 20, 2010 6:03 PM
> > To: ivy-user@ant.apache.org
> > Subject: Re: Need StrictConflictManager to respect force
> >
> > Excellent news! :-)
> >
> > thanks,
> > Maarten
> >
> >
> >
> >
> > ----- Original Message ----
> > From: "Burcher, Greg" <gregory.burc...@netapp.com>
> > To: ivy-user@ant.apache.org
> > Sent: Mon, December 20, 2010 10:33:43 PM
> > Subject: RE: Need StrictConflictManager to respect force
> >
> > Thanks Maarten. That was exactly the bit of information that I
> needed.
> > All appears to be working now. Once I have the solution fully
> verified,
> > I will post to the ivy jira.
> >
> > Greg
> >
> > > -----Original Message-----
> > > From: Maarten Coene [mailto:maarten_co...@yahoo.com]
> > > Sent: Monday, December 20, 2010 4:18 PM
> > > To: ivy-user@ant.apache.org
> > > Subject: Re: Need StrictConflictManager to respect force
> > >
> > > You have to add your custom conflictmanager using the <classpath
/>
> > > element in
> > > your settings.xml.
> > >
> > > Here you can find a little example for adding a custom resolver:
> > > http://ant.apache.org/ivy/history/latest-
> > > milestone/settings/classpath.html
> > >
> > > hope this helps you getting started...
> > >
> > > regards,
> > > Maarten
> > >
> > >
> > >
> > > ----- Original Message ----
> > > From: "Burcher, Greg" <gregory.burc...@netapp.com>
> > > To: ivy-user@ant.apache.org
> > > Sent: Mon, December 20, 2010 7:55:15 PM
> > > Subject: RE: Need StrictConflictManager to respect force
> > >
> > > We actually need this immediately so I will fully implement/verify
> > and
> > > then I will also submit to jira. I could do with some help with a
> > > problem that I am having trouble resolving. I have coded my
> > > StrictConflictManager subclass and added my code in a jar in the
> > > ivy.classpath. I have actually added my jar to the org.apache.ivy
> > > v2.1.0
> > > module and added my jar as a publication in the ivy.xml for the
ivy
> > > module.
> > >
> > > The Ivy configuration documentation does not have examples, nor
> could
> > I
> > > find any, on the exact syntax to set define a custom conflict
> > manager.
> > >
> > > This is what I have in my ivysettings.xml:
> > >
> > >     <typedef name="strict-with-force"
> > > classname="com.netapp.common.ivy.StrictWithForceConflictManager"/>
> > >     <conflict-managers>
> > >         <strict-with-force/>
> > >     </conflict-managers>
> > >
> > > Later, in my project ivy.xml file, I have this:
> > >
> > >     <conflict manager="strict-with-force"/>
> > >
> > > Does this all look correct in terms of syntax?
> > >
> > > When I run my build.xml from the linux command line, the xml in
the
> > > ivysettings.xml file seems to parse and be handled fine. However,
I
> > get
> > > this error when my ivy.xml file is parsed:
> > >
> > > /u/burcher/myproject/build.xml:332: The following error occurred
> > while
> > > executing this line:
> > > /u/burcher/myproject/build.xml:150: impossible to parse ivy file
> for
> > > /u/burcher/myproject/build.xml:
> ivyfile=/u/burcher/myproject/ivy.xml
> > > exception=java.text.ParseException: [unknown conflict manager:
> > > strict-with-force in file:/u/burcher/myproject/ivy.xml
> > > ]
> > >         at
> > >
> >
>
org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractPa
> > > r
> > > ser.checkErrors(AbstractModuleDescriptorParser.java:89)
> > >         at
> > >
> >
>
org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractPa
> > > r
> > > ser.getModuleDescriptor(AbstractModuleDescriptorParser.java:342)
> > >         at
> > >
> >
>
org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescri
> > > p
> > > tor(XmlModuleDescriptorParser.java:103)
> > >         at
> > >
> >
>
org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry.parseDescr
> > > i
> > > ptor(ModuleDescriptorParserRegistry.java:86)
> > >         at
> > >
> >
>
org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescr
> > > i
> > > ptor(AbstractModuleDescriptorParser.java:48)
> > >         at
> > >
> >
>
com.netapp.common.module.ParallelSubAnt.buildModuleItems(ParallelSubAnt
> > > .
> > > java:736)
> > >         at
> > >
> >
>
com.netapp.common.module.ParallelSubAnt.doExecute(ParallelSubAnt.java:6
> > > 9
> > > 7)
> > >         at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:277)
> > >         at
> > >
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
> > >         at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown
> > Source)
> > >         at
> > >
> >
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
> > > r
> > > Impl.java:25)
> > >         at java.lang.reflect.Method.invoke(Method.java:597)
> > >         at
> > >
> >
>
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
> > > 1
> > > 06)
> > >         at org.apache.tools.ant.Task.perform(Task.java:348)
> > >         at
> > >
> org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
> > >         at ...
> > >
> > > Running my build.xml instead in eclipse, I see this error message:
> > >
> > > Error while resolving the ivy instance for ivy.xml in 'myproject':
> > >   The ivy settings file
> > > 'file:h:/p4/netapp_ivy_repo/main/ivysettings.xml' could not be
> > parsed:
> > > failed to load settings from
> > > file:/h:/p4/netapp_ivy_repo/main/ivysettings.xml: impossible to
> > define
> > > new type: class not found:
> > > com.netapp.common.ivy.StrictWithForceConflictManager in [] nor Ivy
> > > classloader
> > > Error while resolving the ivy instance for ivy.xml in
'dfm-common':
> > >
> > > Here the error is in the ivysettings.xml file, as though my custom
> > > class
> > > cannot be found.
> > >
> > > I will continue to dig into these problems, but any suggestions
> would
> > > be
> > > appreciated.
> > >
> > > Thanks,
> > >
> > > Greg
> > >
> > > > -----Original Message-----
> > > > From: Maarten Coene [mailto:maarten_co...@yahoo.com]
> > > > Sent: Monday, December 20, 2010 7:55 AM
> > > > To: ivy-user@ant.apache.org
> > > > Subject: Re: Need StrictConflictManager to respect force
> > > >
> > > > If possible, could you create a JIRA issue for this and attach a
> > > patch
> > > > file to
> > > > it?
> > > > https://issues.apache.org/jira/browse/IVY
> > > >
> > > > thanks,
> > > > Maarten
> > > >
> > > >
> > > >
> > > >
> > > > ----- Original Message ----
> > > > From: "Burcher, Greg" <gregory.burc...@netapp.com>
> > > > To: ivy-user@ant.apache.org
> > > > Sent: Fri, December 17, 2010 8:53:24 PM
> > > > Subject: Need StrictConflictManager to respect force
> > > >
> > > > Neither StrictConflictManager nor
LatestCompatibleConflictManager
> > > > appear
> > > > to respect the 'force="true" attribute value on dependency. We
> > would
> > > > like to have the behavior of StrictConflictManager with the
> > > enhancement
> > > > that it would recognize the dependency force attribute as an
> > override
> > > > to
> > > > strict conflict resolution. This appears to be fairly easy to
> code
> > by
> > > > extending StrictConflictManager something like this:
> > > >
> > > >
> > > >
> > > > public class StrictPlusForceConflictManager extends
> > > > StrictConflictManager {
> > > >
> > > >
> > > >
> > > >     @Override
> > > >
> > > >     public Collection resolveConflicts(IvyNode parent,
Collection
> > > > conflicts) {
> > > >
> > > >         /*
> > > >
> > > >          * Before using algorithm of StrictConflictManager,
> > > >
> > > >          * first check for "force" revision  using code from
> > > > LatestConflictManager.
> > > >
> > > >          */
> > > >
> > > >         if (conflicts.size() < 2) {
> > > >
> > > >             return conflicts;
> > > >
> > > >         }
> > > >
> > > >         for (Iterator iter = conflicts.iterator();
> iter.hasNext();)
> > {
> > > >
> > > >             IvyNode node = (IvyNode) iter.next();
> > > >
> > > >             DependencyDescriptor dd =
> > > > node.getDependencyDescriptor(parent);
> > > >
> > > >             if (dd != null && dd.isForce()
> > > >
> > > >                     &&
> > > > parent.getResolvedId().equals(dd.getParentRevisionId())) {
> > > >
> > > >                 return Collections.singleton(node);
> > > >
> > > >             }
> > > >
> > > >         }
> > > >
> > > >         return super.resolveConflicts(parent, conflicts);
> > > >
> > > >     }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > We have not yet tested because it is a non-trivial task to
create
> > our
> > > > own ConflictManager subclass, configure to ivy, and deploy the
> > > compiled
> > > > class into an appropriate classpath for our build process. For
> now
> > we
> > > > are working around this issue by using a strategy based on the
> > > > dependency exclude attribute. However, this strategy is not as
> > clean
> > > > for
> > > > us as it would be to use the dependency force attribute.
> > > >
> > > >
> > > >
> > > > Is it possible that combined strict/force conflict management
> > support
> > > > could be added to Ivy? Or maybe someone can suggest a strategy
to
> > > > achieve something similar using support already provided?
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > >
> > > >
> > > > Greg Burcher
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >

Reply via email to