com.atlassian.maven.plugins.licenses.mojos
Class AbstractLicensesMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.atlassian.maven.plugins.licenses.mojos.AbstractLicensesMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
PackageMojo, ValidateMojo

public abstract class AbstractLicensesMojo
extends org.apache.maven.plugin.AbstractMojo

Pre-resolves all transitive dependencies. Provides methods for iterating through dependency projects, searching for the license in the JAR.

Author:
Sherali Karimov

Field Summary
protected  boolean aggregate
          Whether to work at the root, or work on each module independently
protected  org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
           
protected  org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource
           
protected  java.lang.String excludedLibraries
          Comma-separated list of dependencies to be excluded.
protected  java.util.List excludedLibraryList
          List of dependencies to be excluded.
protected  java.util.List excludedScopeList
          List of scopes of dependencies to be excluded
protected  java.lang.String excludedScopes
          Comma-separated list of scopes of dependencies to be excluded.
protected static java.util.List LICENSE_PATH_OPTIONS
          Various locations where people historically have placed their license agreement text inside the JAR files
static java.lang.String LICENSE_TYPE
           
protected  org.apache.maven.artifact.repository.ArtifactRepository localRepository
           
protected  org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
           
protected  org.apache.maven.project.MavenProject project
           
protected  java.util.List remoteRepositories
           
protected  org.apache.maven.artifact.resolver.ArtifactResolver resolver
           
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractLicensesMojo()
           
 
Method Summary
protected  ArtifactExclusionFilter createExclusionFilter()
           
protected  java.lang.String createValidLicenseUrl(org.apache.maven.model.License license, org.apache.maven.artifact.Artifact artifact)
          Attempts to extract the license location for the project.
protected  java.lang.String findLicenseInRepository(org.apache.maven.artifact.Artifact artifact)
          Returns a download URL of the corresponding artifact with classifier 'license' for the given artifact or null if license isn't found in maven repository.
protected  org.apache.maven.artifact.Artifact getLicenseArtifactForProject(org.apache.maven.project.MavenProject project)
           
protected  void visitDependencyProjects(ProjectVisitor visitor)
           
 
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
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
 

Field Detail

LICENSE_PATH_OPTIONS

protected static final java.util.List LICENSE_PATH_OPTIONS
Various locations where people historically have placed their license agreement text inside the JAR files


LICENSE_TYPE

public static final java.lang.String LICENSE_TYPE
See Also:
Constant Field Values

resolver

protected org.apache.maven.artifact.resolver.ArtifactResolver resolver

localRepository

protected org.apache.maven.artifact.repository.ArtifactRepository localRepository

remoteRepositories

protected java.util.List remoteRepositories

artifactFactory

protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory

artifactMetadataSource

protected org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource

mavenProjectBuilder

protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder

project

protected org.apache.maven.project.MavenProject project

excludedScopeList

protected java.util.List excludedScopeList
List of scopes of dependencies to be excluded


excludedScopes

protected java.lang.String excludedScopes
Comma-separated list of scopes of dependencies to be excluded. This is a command-line alternative to the excludedScope parameter, since List parameters are not currently compatible with CLI specification.


excludedLibraryList

protected java.util.List excludedLibraryList
List of dependencies to be excluded. Each item is a groupId:artifactId combination. Wildcard expressions: groupId:* and *:artifactId are also supported.


excludedLibraries

protected java.lang.String excludedLibraries
Comma-separated list of dependencies to be excluded. Each item is a groupId:artifactId combination. Wildcard expressions: groupId:* and *:artifactId are also supported. This is a command-line alternative to the excludedScope parameter, since List parameters are not currently compatible with CLI specification.


aggregate

protected boolean aggregate
Whether to work at the root, or work on each module independently

Constructor Detail

AbstractLicensesMojo

public AbstractLicensesMojo()
Method Detail

getLicenseArtifactForProject

protected org.apache.maven.artifact.Artifact getLicenseArtifactForProject(org.apache.maven.project.MavenProject project)

visitDependencyProjects

protected void visitDependencyProjects(ProjectVisitor visitor)
                                throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

createValidLicenseUrl

protected java.lang.String createValidLicenseUrl(org.apache.maven.model.License license,
                                                 org.apache.maven.artifact.Artifact artifact)
Attempts to extract the license location for the project. If that fails - performs a search for other potential license locations inside the JAR as defined in LICENSE_PATH_OPTIONS

Parameters:
license - - license object from the maven project. If this is null, this method will search the artifact location
artifact - - artifact for which the license is being looked up
Returns:
a valid URL to the license file or null if no valid JAR or entry is found

findLicenseInRepository

protected java.lang.String findLicenseInRepository(org.apache.maven.artifact.Artifact artifact)
Returns a download URL of the corresponding artifact with classifier 'license' for the given artifact or null if license isn't found in maven repository.

Parameters:
artifact -
Returns:
a valid URL to the license file or null if no license isn't in maven repository

createExclusionFilter

protected ArtifactExclusionFilter createExclusionFilter()
                                                 throws org.apache.oro.text.regex.MalformedPatternException
Throws:
org.apache.oro.text.regex.MalformedPatternException


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.