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$AbstractPar
ser.checkErrors(AbstractModuleDescriptorParser.java:89)
at
org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser$AbstractPar
ser.getModuleDescriptor(AbstractModuleDescriptorParser.java:342)
at
org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser.parseDescrip
tor(XmlModuleDescriptorParser.java:103)
at
org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry.parseDescri
ptor(ModuleDescriptorParserRegistry.java:86)
at
org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser.parseDescri
ptor(AbstractModuleDescriptorParser.java:48)
at
com.netapp.common.module.ParallelSubAnt.buildModuleItems(ParallelSubAnt.
java:736)
at
com.netapp.common.module.ParallelSubAnt.doExecute(ParallelSubAnt.java:69
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(DelegatingMethodAccessor
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:[email protected]]
> Sent: Monday, December 20, 2010 7:55 AM
> To: [email protected]
> 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" <[email protected]>
> To: [email protected]
> 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
>
>
>