org.apache.maven.plugin.ide

Class AbstractIdeSupportMojo

public abstract class AbstractIdeSupportMojo extends AbstractMojo implements LogEnabled

Abstract base plugin which takes care of the common stuff usually needed by maven IDE plugins. A plugin extending AbstractIdeSupportMojo should implement the setup() and writeConfiguration() methods, plus the getters needed to get the various configuration flags and required components. The lifecycle:
       *** calls setup() where you can configure your specific stuff and stop the mojo from execute if appropriate ***
       - manually resolve project dependencies, NOT failing if a dependency is missing
       - compute project references (reactor projects) if the getUseProjectReferences() flag is set
       - download sources/javadocs if the getDownloadSources() flag is set
       *** calls writeConfiguration(), passing the list of resolved referenced dependencies ***
       - report the list of missing sources or just tell how to turn this feature on if the flag was disabled
 

Version: $Id: AbstractIdeSupportMojo.java 392813 2006-04-09 19:42:06Z fgiust $

Author: Fabrizio Giustina

Field Summary
protected ArtifactCollectorartifactCollector
Artifact collector, needed to resolve dependencies.
protected ArtifactFactoryartifactFactory
Artifact factory, needed to download source jars for inclusion in classpath.
protected ArtifactMetadataSourceartifactMetadataSource
protected ArtifactResolverartifactResolver
Artifact resolver, needed to download source jars for inclusion in classpath.
protected booleandownloadSources
Enables/disables the downloading of source attachments.
protected MavenProjectexecutedProject
The currently executed project (can be a reactor project).
protected ArtifactRepositorylocalRepository
Local maven repository.
protected MavenProjectproject
The project whose project files to create.
protected ListreactorProjects
If the executed project is a reactor project, this will contains the full list of projects in the reactor.
protected ListremoteArtifactRepositories
Remote repositories which will be searched for source attachments.
Method Summary
protected IdeDependency[]doDependencyResolution()
Resolve project dependencies.
voidenableLogging(Logger logger)
voidexecute()
ArtifactFactorygetArtifactFactory()
Getter for artifactFactory.
ArtifactMetadataSourcegetArtifactMetadataSource()
Getter for artifactMetadataSource.
ArtifactResolvergetArtifactResolver()
Getter for artifactResolver.
booleangetDownloadSources()
Getter for downloadSources.
MavenProjectgetExecutedProject()
Getter for executedProject.
ArtifactRepositorygetLocalRepository()
Getter for localRepository.
MavenProjectgetProject()
Getter for project.
ListgetReactorProjects()
Getter for reactorProjects.
ListgetRemoteArtifactRepositories()
Getter for remoteArtifactRepositories.
protected abstract booleangetUseProjectReferences()
return false if projects available in a reactor build should be considered normal dependencies, true if referenced project will be linked and not need artifact resolution.
voidsetArtifactFactory(ArtifactFactory artifactFactory)
Setter for artifactFactory.
voidsetArtifactMetadataSource(ArtifactMetadataSource artifactMetadataSource)
Setter for artifactMetadataSource.
voidsetArtifactResolver(ArtifactResolver artifactResolver)
Setter for artifactResolver.
voidsetDownloadSources(boolean downloadSources)
Setter for downloadSources.
voidsetExecutedProject(MavenProject executedProject)
Setter for executedProject.
voidsetLocalRepository(ArtifactRepository localRepository)
Setter for localRepository.
voidsetProject(MavenProject project)
Setter for project.
voidsetReactorProjects(List reactorProjects)
Setter for reactorProjects.
voidsetRemoteArtifactRepositories(List remoteArtifactRepositories)
Setter for remoteArtifactRepositories.
protected abstract booleansetup()
Hook for preparation steps before the actual plugin execution.
protected abstract voidwriteConfiguration(IdeDependency[] deps)
Main plugin method where dependencies should be processed in order to generate IDE configuration files.

Field Detail

artifactCollector

protected ArtifactCollector artifactCollector
Artifact collector, needed to resolve dependencies.

UNKNOWN: role="org.apache.maven.artifact.resolver.ArtifactCollector"

artifactFactory

protected ArtifactFactory artifactFactory
Artifact factory, needed to download source jars for inclusion in classpath.

UNKNOWN: role="org.apache.maven.artifact.factory.ArtifactFactory"

artifactMetadataSource

protected ArtifactMetadataSource artifactMetadataSource

UNKNOWN: role="org.apache.maven.artifact.metadata.ArtifactMetadataSource" hint="maven"

artifactResolver

protected ArtifactResolver artifactResolver
Artifact resolver, needed to download source jars for inclusion in classpath.

UNKNOWN: role="org.apache.maven.artifact.resolver.ArtifactResolver"

downloadSources

protected boolean downloadSources
Enables/disables the downloading of source attachments. Defaults to false.

UNKNOWN: expression="${downloadSources}"

executedProject

protected MavenProject executedProject
The currently executed project (can be a reactor project).

UNKNOWN: expression="${executedProject}"

localRepository

protected ArtifactRepository localRepository
Local maven repository.

UNKNOWN: expression="${localRepository}"

project

protected MavenProject project
The project whose project files to create.

UNKNOWN: expression="${project}"

reactorProjects

protected List reactorProjects
If the executed project is a reactor project, this will contains the full list of projects in the reactor.

UNKNOWN: expression="${reactorProjects}"

remoteArtifactRepositories

protected List remoteArtifactRepositories
Remote repositories which will be searched for source attachments.

UNKNOWN: expression="${project.remoteArtifactRepositories}"

Method Detail

doDependencyResolution

protected IdeDependency[] doDependencyResolution()
Resolve project dependencies. Manual resolution is needed in order to avoid resoltion of multiproject artifacts (if projects will be linked each other an installed jar is not needed) and to avoid a failure when a jar is missing.

Returns: resoved IDE dependencies, with attached jars for non-reactor dependencies

Throws: MojoExecutionException if dependencies can't be resolved

enableLogging

public void enableLogging(Logger logger)

See Also: org.codehaus.plexus.logging.LogEnabled#enableLogging(org.codehaus.plexus.logging.Logger)

execute

public final void execute()

See Also: org.apache.maven.plugin.Mojo#execute()

getArtifactFactory

public ArtifactFactory getArtifactFactory()
Getter for artifactFactory.

Returns: Returns the artifactFactory.

getArtifactMetadataSource

public ArtifactMetadataSource getArtifactMetadataSource()
Getter for artifactMetadataSource.

Returns: Returns the artifactMetadataSource.

getArtifactResolver

public ArtifactResolver getArtifactResolver()
Getter for artifactResolver.

Returns: Returns the artifactResolver.

getDownloadSources

public boolean getDownloadSources()
Getter for downloadSources.

Returns: Returns the downloadSources.

getExecutedProject

public MavenProject getExecutedProject()
Getter for executedProject.

Returns: Returns the executedProject.

getLocalRepository

public ArtifactRepository getLocalRepository()
Getter for localRepository.

Returns: Returns the localRepository.

getProject

public MavenProject getProject()
Getter for project.

Returns: Returns the project.

getReactorProjects

public List getReactorProjects()
Getter for reactorProjects.

Returns: Returns the reactorProjects.

getRemoteArtifactRepositories

public List getRemoteArtifactRepositories()
Getter for remoteArtifactRepositories.

Returns: Returns the remoteArtifactRepositories.

getUseProjectReferences

protected abstract boolean getUseProjectReferences()
return false if projects available in a reactor build should be considered normal dependencies, true if referenced project will be linked and not need artifact resolution.

Returns: true if referenced project will be linked and not need artifact resolution

setArtifactFactory

public void setArtifactFactory(ArtifactFactory artifactFactory)
Setter for artifactFactory.

Parameters: artifactFactory The artifactFactory to set.

setArtifactMetadataSource

public void setArtifactMetadataSource(ArtifactMetadataSource artifactMetadataSource)
Setter for artifactMetadataSource.

Parameters: artifactMetadataSource The artifactMetadataSource to set.

setArtifactResolver

public void setArtifactResolver(ArtifactResolver artifactResolver)
Setter for artifactResolver.

Parameters: artifactResolver The artifactResolver to set.

setDownloadSources

public void setDownloadSources(boolean downloadSources)
Setter for downloadSources.

Parameters: downloadSources The downloadSources to set.

setExecutedProject

public void setExecutedProject(MavenProject executedProject)
Setter for executedProject.

Parameters: executedProject The executedProject to set.

setLocalRepository

public void setLocalRepository(ArtifactRepository localRepository)
Setter for localRepository.

Parameters: localRepository The localRepository to set.

setProject

public void setProject(MavenProject project)
Setter for project.

Parameters: project The project to set.

setReactorProjects

public void setReactorProjects(List reactorProjects)
Setter for reactorProjects.

Parameters: reactorProjects The reactorProjects to set.

setRemoteArtifactRepositories

public void setRemoteArtifactRepositories(List remoteArtifactRepositories)
Setter for remoteArtifactRepositories.

Parameters: remoteArtifactRepositories The remoteArtifactRepositories to set.

setup

protected abstract boolean setup()
Hook for preparation steps before the actual plugin execution.

Returns: true if execution should continue or false if not.

Throws: MojoExecutionException generic mojo exception

writeConfiguration

protected abstract void writeConfiguration(IdeDependency[] deps)
Main plugin method where dependencies should be processed in order to generate IDE configuration files.

Parameters: deps list of IdeDependency objects, with artifacts, sources and javadocs already resolved

Throws: MojoExecutionException generic mojo exception

Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.