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. > 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). You can read my thread about cycle detection from a couple months ago here: http://maven.40175.n5.nabble.com/Why-is-Maven-allowing-cycles-td3355428.html Phillip --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org