org.codehaus.mojo.license
Class AddThirdPartyMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.license.AbstractLicenseMojo
          extended by org.codehaus.mojo.license.AbstractAddThirdPartyMojo
              extended by org.codehaus.mojo.license.AddThirdPartyMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, MavenProjectDependenciesConfigurator

public class AddThirdPartyMojo
extends AbstractAddThirdPartyMojo
implements MavenProjectDependenciesConfigurator

Goal to generate the third-party license file.

This file contains a list of the dependencies and their licenses. Each dependency and it's license is displayed on a single line in the format

   (<license-name>) <project-name> <groupId>:<artifactId>:<version> - <project-url>
 
It will also copy it in the class-path (says add the generated directory as a resource of the build).

Since:
1.0
Author:
tchemit

Field Summary
protected  boolean deployMissingFile
          Deploy the third party missing file in maven repository.
protected  org.apache.maven.artifact.repository.ArtifactRepository localRepository
          Local Repository.
protected  List remoteRepositories
          Remote repositories used for the project.
protected  boolean useRepositoryMissingFiles
          Load from repositories third party missing files.
 
Fields inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
artifactLicenseMapping, bundleThirdPartyPath, excludedArtifacts, excludedGroups, excludedScopes, failIfWarning, force, generateBundle, groupByLicense, includedArtifacts, includedGroups, includedScopes, includeTransitiveDependencies, licenseMerges, missingFile, NO_DEPENDENCIES_MESSAGE, outputDirectory, thirdPartyFilename, useMissingFile
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AddThirdPartyMojo()
           
 
Method Summary
protected  boolean checkPackaging()
          Check if the project packaging is acceptable for the mojo.
protected  boolean checkSkip()
          Checks if the mojo execution should be skipped.
protected  boolean computeDoGenerateMissingFile(SortedProperties unsafeMappings, SortedSet<org.apache.maven.project.MavenProject> unsafeDependencies)
           
protected  SortedProperties createUnsafeMapping()
           
protected  void doAction()
          Do plugin action.
 org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()
           
 List getRemoteRepositories()
           
 boolean isDeployMissingFile()
           
 boolean isDoGenerateMissing()
           
 boolean isIncludeTransitiveDependencies()
          
 boolean isUseRepositoryMissingFiles()
           
protected  SortedMap<String,org.apache.maven.project.MavenProject> loadDependencies()
           
 void setDoGenerateMissing(boolean doGenerateMissing)
           
protected  void writeMissingFile()
           
 
Methods inherited from class org.codehaus.mojo.license.AbstractAddThirdPartyMojo
checkUnsafeDependencies, copyToFileSystem, copyToFileSystem, createLicenseMap, exists, getArtifactCache, getArtifactLicenseMapping, getBundleThirdPartyPath, getExcludedArtifacts, getExcludedGroups, getExcludedScopes, getIncludedArtifacts, getIncludedGroups, getIncludedScopes, getInputStream, getLicenseMap, getMissingFile, getOutputDirectory, getProjectDependencies, getThirdPartyFile, getThirdPartyFilename, getThirdPartyTool, getUnsafeDependencies, getUnsafeMappings, init, isDoGenerate, isDoGenerateBundle, isFailIfWarning, isForce, isGenerateBundle, isGroupByLicense, isUseMissingFile, setArtifactLicenseMapping, setBundleThirdPartyPath, setDoGenerate, setDoGenerateBundle, setExcludedArtifacts, setExcludedGroups, setExcludedScopes, setFailIfWarning, setForce, setGenerateBundle, setGroupByLicense, setIncludedArtifacts, setIncludedGroups, setIncludedScopes, setMissingFile, setOutputDirectory, setThirdPartyFile, setThirdPartyFilename, setThirdPartyTool, setUnsafeDependencies, setUseMissingFile, writeThirdPartyFile
 
Methods inherited from class org.codehaus.mojo.license.AbstractLicenseMojo
acceptPackaging, addResourceDir, afterExecute, checkEncoding, execute, getBuildTimestamp, getEncoding, getProject, getSession, hasClassPath, isVerbose, rejectPackaging, setEncoding, setProject, setSession, setVerbose
 
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.codehaus.mojo.license.MavenProjectDependenciesConfigurator
getExcludedArtifacts, getExcludedGroups, getExcludedScopes, getIncludedArtifacts, getIncludedGroups, getIncludedScopes, isVerbose
 

Field Detail

localRepository

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

Since:
1.0.0

remoteRepositories

protected List remoteRepositories
Remote repositories used for the project.

Since:
1.0.0

deployMissingFile

protected boolean deployMissingFile
Deploy the third party missing file in maven repository.

Since:
1.0

useRepositoryMissingFiles

protected boolean useRepositoryMissingFiles
Load from repositories third party missing files.

Since:
1.0
Constructor Detail

AddThirdPartyMojo

public AddThirdPartyMojo()
Method Detail

checkPackaging

protected boolean checkPackaging()
Description copied from class: AbstractLicenseMojo
Check if the project packaging is acceptable for the mojo.

By default, accept all packaging types.

Note: This method is the first instruction to be executed in the AbstractLicenseMojo.execute().

Tip: There is two method to simplify the packaging check :

AbstractLicenseMojo.acceptPackaging(String...)

and

AbstractLicenseMojo.rejectPackaging(String...)

Overrides:
checkPackaging in class AbstractLicenseMojo
Returns:
true if can execute the goal for the packaging of the project, false otherwise.

loadDependencies

protected SortedMap<String,org.apache.maven.project.MavenProject> loadDependencies()
Specified by:
loadDependencies in class AbstractAddThirdPartyMojo

createUnsafeMapping

protected SortedProperties createUnsafeMapping()
                                        throws org.apache.maven.project.ProjectBuildingException,
                                               IOException,
                                               ThirdPartyToolException
Specified by:
createUnsafeMapping in class AbstractAddThirdPartyMojo
Throws:
org.apache.maven.project.ProjectBuildingException
IOException
ThirdPartyToolException

computeDoGenerateMissingFile

protected boolean computeDoGenerateMissingFile(SortedProperties unsafeMappings,
                                               SortedSet<org.apache.maven.project.MavenProject> unsafeDependencies)
                                        throws IOException
Parameters:
unsafeMappings - the unsafe mapping coming from the missing file
unsafeDependencies - the unsafe dependencies from the project
Returns:
true if missing ifle should be (re-)generated, false otherwise
Throws:
IOException - if any IO problem
Since:
1.0

checkSkip

protected boolean checkSkip()
Description copied from class: AbstractLicenseMojo
Checks if the mojo execution should be skipped.

Overrides:
checkSkip in class AbstractLicenseMojo
Returns:
false if the mojo should not be executed.

doAction

protected void doAction()
                 throws Exception
Description copied from class: AbstractLicenseMojo
Do plugin action.

The method AbstractLicenseMojo.execute() invoke this method only and only if :

Specified by:
doAction in class AbstractLicenseMojo
Throws:
Exception - if any

writeMissingFile

protected void writeMissingFile()
                         throws IOException
Throws:
IOException

isDoGenerateMissing

public boolean isDoGenerateMissing()

setDoGenerateMissing

public void setDoGenerateMissing(boolean doGenerateMissing)

getLocalRepository

public org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()

getRemoteRepositories

public List getRemoteRepositories()

isIncludeTransitiveDependencies

public boolean isIncludeTransitiveDependencies()

Specified by:
isIncludeTransitiveDependencies in interface MavenProjectDependenciesConfigurator
Returns:
true if should include transitive dependencies, false to include only direct dependencies.

isDeployMissingFile

public boolean isDeployMissingFile()

isUseRepositoryMissingFiles

public boolean isUseRepositoryMissingFiles()


Copyright © 2010-2012 The Kuali Foundation. All Rights Reserved.