com.sun.enterprise.build
Class AnalyzeMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.sun.enterprise.build.AnalyzeMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class AnalyzeMojo
extends org.apache.maven.plugin.AbstractMojo

Analyzes dependency declaration and see if there's anything redundantly declared.

The common issue we have is that often distribution modules like PE and nucleus end up containing tons of modules, which makes it unclear as to what functionalities are really added.

This mojo is intended to be used interactively to solve this problem. The mojo will list up all the dependencies that are declared explicitly in POM, yet it's also available through transitive dependencies.

It is then a human's job to decide if the explicit dependency is justified; for exmaple, if your module X depends on another module Y, and both just so happens to rely on the same utility code Z, then you still want to keep that dependency explicit, because Y might stop depending on Z any time. On the other hand, if you depend on JSP, then the dependency to servlet is implified in JSP, so your explicit dependency to servle is probably unnecessary.

Author:
Kohsuke Kawaguchi

Nested Class Summary
protected static interface AbstractGlassfishMojo.ArtifactFilter
           
 
Field Summary
protected  org.apache.maven.project.MavenProject project
          The maven project.
protected  org.apache.maven.project.MavenProjectBuilder projectBuilder
           
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AnalyzeMojo()
           
 
Method Summary
 void execute()
           
protected  Set<org.apache.maven.artifact.Artifact> findArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts, AbstractGlassfishMojo.ArtifactFilter filter)
          Finds artifacts that match the given filter.
protected  Set<org.apache.maven.artifact.Artifact> findArtifactsOfScope(Set<org.apache.maven.artifact.Artifact> artifacts, String scope)
           
protected  Set<org.apache.maven.artifact.Artifact> findArtifactsOfType(Set<org.apache.maven.artifact.Artifact> artifacts, String type)
          Returns a set of Artifacts that have the given type.
protected  boolean isModule(org.apache.maven.artifact.Artifact a)
           
protected  org.apache.maven.project.MavenProject loadPom(org.apache.maven.artifact.Artifact artifact)
          Resolves the POM of the given artifact and parses it into MavenProject.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

project

protected org.apache.maven.project.MavenProject project
The maven project.


projectBuilder

protected org.apache.maven.project.MavenProjectBuilder projectBuilder
Constructor Detail

AnalyzeMojo

public AnalyzeMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

isModule

protected boolean isModule(org.apache.maven.artifact.Artifact a)
                    throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

loadPom

protected org.apache.maven.project.MavenProject loadPom(org.apache.maven.artifact.Artifact artifact)
                                                 throws org.apache.maven.project.ProjectBuildingException
Resolves the POM of the given artifact and parses it into MavenProject.

Throws:
org.apache.maven.project.ProjectBuildingException

findArtifacts

protected Set<org.apache.maven.artifact.Artifact> findArtifacts(Set<org.apache.maven.artifact.Artifact> artifacts,
                                                                AbstractGlassfishMojo.ArtifactFilter filter)
Finds artifacts that match the given filter.


findArtifactsOfType

protected Set<org.apache.maven.artifact.Artifact> findArtifactsOfType(Set<org.apache.maven.artifact.Artifact> artifacts,
                                                                      String type)
Returns a set of Artifacts that have the given type.


findArtifactsOfScope

protected Set<org.apache.maven.artifact.Artifact> findArtifactsOfScope(Set<org.apache.maven.artifact.Artifact> artifacts,
                                                                       String scope)


Copyright © 2011 GlassFish Community. All Rights Reserved.