I am so happy someone brought this up. I actually hit this issue several
times but never got around to mentioning it. Please submit a JIRA issue!


On Tue, Feb 11, 2014 at 3:41 PM, Barrie Treloar <baerr...@gmail.com> wrote:

> On 12 February 2014 07:41, laredotornado-3 <laredotorn...@gmail.com>
> wrote:
> > Hi,
> >
> > I'm using Maven 3.1.1 on Mac 10.9.1.  When I ran "mvn
> dependency:analyze" on
> > my project, I got results that included:
> >
> >         [WARNING] Unused declared dependencies found:
> >         ...
> >         [WARNING]    junit:junit:jar:4.11:test
> >
> > So I commented out the above junit dependency in my pom (declared like
> so):
> [del]
> >         java.lang.NoSuchFieldError: NULL
> >                 at
> org.junit.runners.ParentRunner.<init>(ParentRunner.java:48)
> >                 at
> >
> org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:58)
> >                 at
> >
> org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:104)
> >
> > This isn't the only dependency that the analyze goal lists that wreaks
> havoc
> > when I comment it out.  Is there another way to detect what dependencies
> are
> > truly not needed by my project?
>
> Unfortunately this stuff is not documented well enough in the plugin.
> You're welcome to submit a patch!
>
> Have a look at
> http://maven.apache.org/plugins/maven-dependency-plugin/faq.html#unused
>
> I think Maven is missing a scope, it needs to break up test into two
> phases; testCompile and testRuntime instead of having one scope which
> means both.
> This means that the analyze code can't tell what stuff is needed for
> tests at compile time and what is needed at runtime.
>
> If my memory serves me right, that would mean for your example that
> Spring is a compile time dependency but junit would be a runtime
> dependency.
> Hence the incorrect "Unused declared dependencies found" error.
>
> I would manually ignore anything found in the test scope from the error
> list.
> I never found the time to go hacking the plugin to work better - i.e.
> if it is test scope it really can't tell the difference between unused
> dependencies and shouldn't report them.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


-- 
Cheers,
Paul

Reply via email to