// private methods --------------------------------------------------------
private boolean checkDependencies()
throws MojoExecutionException
{
ProjectDependencyAnalysis analysis;
try
{
analysis = createProjectDependencyAnalyzer().analyze( project );
}
catch ( ProjectDependencyAnalyzerException exception )
{
throw new MojoExecutionException( "Cannot analyze dependencies", exception );
}
Set<Artifact> usedDeclared = analysis.getUsedDeclaredArtifacts();
Set<Artifact> usedUndeclared = analysis.getUsedUndeclaredArtifacts();
Set<Artifact> unusedDeclared = analysis.getUnusedDeclaredArtifacts();
if ( ignoreNonCompile )
{
Set<Artifact> filteredUnusedDeclared = new HashSet<Artifact>( unusedDeclared );
Iterator<Artifact> iter = filteredUnusedDeclared.iterator();
while ( iter.hasNext() )
{
Artifact artifact = iter.next();
if ( !artifact.getScope().equals( Artifact.SCOPE_COMPILE ) )
{
iter.remove();
}
}
unusedDeclared = filteredUnusedDeclared;
}
if ( ( !verbose || usedDeclared.isEmpty() ) && usedUndeclared.isEmpty() && unusedDeclared.isEmpty() )
{
getLog().info( "No dependency problems found" );
return false;
}
if ( verbose && !usedDeclared.isEmpty() )
{
getLog().info( "Used declared dependencies found:" );
logArtifacts( analysis.getUsedDeclaredArtifacts(), false );
}
if ( !usedUndeclared.isEmpty() )
{
getLog().warn( "Used undeclared dependencies found:" );