Thanks for the detailed reply Philip, Comments inline
On Sat, Mar 26, 2011 at 3:43 AM, Phillip Hellewell <ssh...@gmail.com> wrote: > On Fri, Mar 25, 2011 at 8:45 AM, Wendy Smoak <wsm...@gmail.com> wrote: > > On Fri, Mar 25, 2011 at 5:55 AM, Caoilte O'Connor <caoi...@gmail.com> > wrote: > >> Hi, > >> I've just discovered the enforcer plugin and would like to use it to > reduce > >> our dependency conflicts but a bigger problem for us when it does turn > up > >> are circular dependencies. The Dependency Tree plugin spots these, but > does > >> anyone have any rules for the enforcer plugin to fail the build if it > >> occurs? > > I wrote a plugin to do it. It uses > org.apache.maven.shared.dependency.tree.DependencyTreeBuilder to get > the list of DependencyNode. Then it cycles through each one calling > getArtifact() and compares it to see if it is the same as the main > project's Artifact (same group id and artifact id). > > In other words, if any of my dependencies are myself, then it throws > an exception. > Were you able to release this anywhere or is it something I could re-develop easily enough with the DependencyTreeBuilder. > > > In what situation does the build get far enough to use a plugin to > > detect this? I thought Maven would just stop with an error if it > > encountered a cycle. > > I have heard that it will catch a cycle in a reactor build, but > otherwise no, it won't catch it. That's why I submitted this bug a > couple months ago: http://jira.codehaus.org/browse/MNG-4999 > > I don't think it is really possible to introduce a cycle when using > releases, but it is definitely possible with snapshots (just follow > the steps in the bug). > I think we were able to introduce this bug by having Version 2 of Project A depending on version 1 of Project B which depends on version 1 of Project A. Regards Caoilte