org.whitesource.maven
Class AgentMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.whitesource.maven.WhitesourceMojo
          extended by org.whitesource.maven.AgentMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
CheckPoliciesMojo, UpdateMojo

public abstract class AgentMojo
extends WhitesourceMojo

Concrete implementation holding common functionality to all goals in this plugin that use the agent API.

Author:
tom.shapira

Field Summary
protected  String[] excludes
          Optional.
protected  boolean ignore
          Optional.
protected  boolean ignorePomModules
          Optional.
protected  boolean ignoreTestScopeDependencies
          Optional.
protected  String[] includes
          Optional.
protected  Map<String,String> moduleTokens
          Optional.
protected  String orgToken
          Unique identifier of the organization to update.
protected  File outputDirectory
          Output directory for checking policies results.
static String POM
           
protected  String product
          Product to update Name or Unique identifier.
protected  String productVersion
          Product to update version.
protected  String projectToken
          Optional.
protected  Collection<org.apache.maven.project.MavenProject> reactorProjects
           
protected  Properties specialModuleTokens
          Optional.
static String TYPE
           
 
Fields inherited from class org.whitesource.maven.WhitesourceMojo
failOnError, mavenProject, projectDependenciesResolver, repoSession, service, session, skip
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AgentMojo()
           
 
Method Summary
protected  Collection<org.whitesource.agent.api.model.DependencyInfo> collectDependencyStructure(org.apache.maven.project.MavenProject project)
          Build the dependency graph of the project in order to resolve all transitive dependencies.
protected  Collection<org.whitesource.agent.api.model.DependencyInfo> collectDirectDependencies(org.apache.maven.project.MavenProject project)
           
protected  Map<org.apache.maven.model.Dependency,org.apache.maven.artifact.Artifact> createLookupTable(org.apache.maven.project.MavenProject project)
           
protected  void debugProjectInfos(Collection<org.whitesource.agent.api.model.AgentProjectInfo> projectInfos)
           
protected  org.whitesource.agent.api.model.Coordinates extractCoordinates(org.apache.maven.project.MavenProject mavenProject)
           
protected  Collection<org.whitesource.agent.api.model.AgentProjectInfo> extractProjectInfos()
           
protected  void generateReport(org.whitesource.agent.api.dispatch.CheckPoliciesResult result)
           
protected  org.whitesource.agent.api.model.DependencyInfo getDependencyInfo(org.apache.maven.model.Dependency dependency)
           
protected  boolean match(org.apache.maven.model.Dependency dependency, org.apache.maven.artifact.Artifact artifact)
           
protected  boolean matchAny(String value, String[] patterns)
           
protected  org.whitesource.agent.api.model.AgentProjectInfo processProject(org.apache.maven.project.MavenProject project)
           
protected  boolean shouldProcess(org.apache.maven.project.MavenProject project)
           
 
Methods inherited from class org.whitesource.maven.WhitesourceMojo
createService, debug, debug, doExecute, error, error, execute, handleError, info, warn, warn
 
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

POM

public static final String POM
See Also:
Constant Field Values

TYPE

public static final String TYPE
See Also:
Constant Field Values

orgToken

@Parameter(alias="orgToken",
           property="org.whitesource.orgToken",
           required=true)
protected String orgToken
Unique identifier of the organization to update.


product

@Parameter(alias="product",
           property="org.whitesource.product",
           required=false)
protected String product
Product to update Name or Unique identifier.


productVersion

@Parameter(alias="productVersion",
           property="org.whitesource.productVersion",
           required=false)
protected String productVersion
Product to update version.


ignoreTestScopeDependencies

@Parameter(alias="ignoreTestScopeDependencies",
           property="org.whitesource.ignoreTestScopeDependencies",
           required=false,
           defaultValue="true")
protected boolean ignoreTestScopeDependencies
Optional. Set to false to include test scope dependencies.


outputDirectory

@Parameter(alias="outputDirectory",
           property="org.whitesource.outputDirectory",
           required=false,
           defaultValue="${project.reporting.outputDirectory}")
protected File outputDirectory
Output directory for checking policies results.


projectToken

@Parameter(alias="projectToken",
           property="org.whitesource.projectToken",
           required=false)
protected String projectToken
Optional. Unique identifier of the White Source project to update. If omitted, default naming convention will apply.


moduleTokens

@Parameter(alias="moduleTokens",
           property="org.whitesource.moduleTokens",
           required=false)
protected Map<String,String> moduleTokens
Optional. Map of module artifactId to White Source project token.


specialModuleTokens

@Parameter(alias="specialModuleTokens",
           property="org.whitesource.specialModuleTokens",
           required=false)
protected Properties specialModuleTokens
Optional. Use name value pairs for specifying the project tokens to use for modules whose artifactId is not a valid XML tag.


ignore

@Parameter(alias="ignore",
           property="org.whitesource.ignore",
           required=false,
           defaultValue="false")
protected boolean ignore
Optional. Set to true to ignore this maven project. Overrides any include patterns.


includes

@Parameter(alias="includes",
           property="org.whitesource.includes",
           required=false,
           defaultValue="")
protected String[] includes
Optional. Only modules with an artifactId matching one of these patterns will be processed by the plugin.


excludes

@Parameter(alias="excludes",
           property="org.whitesource.excludes",
           required=false,
           defaultValue="")
protected String[] excludes
Optional. Modules with an artifactId matching any of these patterns will not be processed by the plugin.


ignorePomModules

@Parameter(alias="ignorePomModules",
           property="org.whitesource.ignorePomModules",
           required=false,
           defaultValue="true")
protected boolean ignorePomModules
Optional. Set to true to ignore this maven modules of type pom.


reactorProjects

@Parameter(defaultValue="${reactorProjects}",
           required=true,
           readonly=true)
protected Collection<org.apache.maven.project.MavenProject> reactorProjects
Constructor Detail

AgentMojo

public AgentMojo()
Method Detail

getDependencyInfo

protected org.whitesource.agent.api.model.DependencyInfo getDependencyInfo(org.apache.maven.model.Dependency dependency)

debugProjectInfos

protected void debugProjectInfos(Collection<org.whitesource.agent.api.model.AgentProjectInfo> projectInfos)

processProject

protected org.whitesource.agent.api.model.AgentProjectInfo processProject(org.apache.maven.project.MavenProject project)
                                                                   throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

collectDirectDependencies

protected Collection<org.whitesource.agent.api.model.DependencyInfo> collectDirectDependencies(org.apache.maven.project.MavenProject project)

collectDependencyStructure

protected Collection<org.whitesource.agent.api.model.DependencyInfo> collectDependencyStructure(org.apache.maven.project.MavenProject project)
                                                                                         throws org.apache.maven.project.DependencyResolutionException
Build the dependency graph of the project in order to resolve all transitive dependencies. By default resolves filters scopes test and provided, and transitive optional dependencies.

Parameters:
project - The maven project.
Returns:
A collection of DependencyInfo resolved with children.
Throws:
org.apache.maven.project.DependencyResolutionException - Exception thrown if dependency resolution fails.

extractCoordinates

protected org.whitesource.agent.api.model.Coordinates extractCoordinates(org.apache.maven.project.MavenProject mavenProject)

createLookupTable

protected Map<org.apache.maven.model.Dependency,org.apache.maven.artifact.Artifact> createLookupTable(org.apache.maven.project.MavenProject project)

matchAny

protected boolean matchAny(String value,
                           String[] patterns)

match

protected boolean match(org.apache.maven.model.Dependency dependency,
                        org.apache.maven.artifact.Artifact artifact)

extractProjectInfos

protected Collection<org.whitesource.agent.api.model.AgentProjectInfo> extractProjectInfos()
                                                                                    throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

shouldProcess

protected boolean shouldProcess(org.apache.maven.project.MavenProject project)

generateReport

protected void generateReport(org.whitesource.agent.api.dispatch.CheckPoliciesResult result)
                       throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException


Copyright © 2011-2014 White Source. All Rights Reserved.