public abstract class AbstractIdeSupportMojo extends AbstractMojo implements org.codehaus.plexus.logging.LogEnabled
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
Modifier and Type | Field and Description |
---|---|
protected ArtifactCollector |
artifactCollector
Artifact collector, needed to resolve dependencies.
|
protected ArtifactFactory |
artifactFactory
Artifact factory, needed to download source jars for inclusion in classpath.
|
protected ArtifactMetadataSource |
artifactMetadataSource |
protected ArtifactResolver |
artifactResolver
Artifact resolver, needed to download source jars for inclusion in classpath.
|
protected boolean |
downloadJavadocs
Enables/disables the downloading of javadoc attachments.
|
protected boolean |
downloadSources
Enables/disables the downloading of source attachments.
|
protected MavenProject |
executedProject
The currently executed project (can be a reactor project).
|
protected boolean |
forceRecheck
Enables/disables the rechecking of the remote repository for downloading source/javadoc attachments.
|
protected ArtifactRepository |
localRepository
Local maven repository.
|
protected org.codehaus.plexus.logging.Logger |
logger
Plexus logger needed for debugging manual artifact resolution.
|
protected String |
packaging
The project packaging.
|
protected MavenProject |
project
The project whose project files to create.
|
protected List |
reactorProjects
If the executed project is a reactor project, this will contains the full list of projects in the reactor.
|
protected List |
remoteArtifactRepositories
Remote repositories which will be searched for source attachments.
|
Constructor and Description |
---|
AbstractIdeSupportMojo() |
Modifier and Type | Method and Description |
---|---|
protected IdeDependency[] |
doDependencyResolution()
Resolve project dependencies.
|
void |
enableLogging(org.codehaus.plexus.logging.Logger logger) |
void |
execute() |
ArtifactFactory |
getArtifactFactory()
Getter for
artifactFactory . |
ArtifactMetadataSource |
getArtifactMetadataSource()
Getter for
artifactMetadataSource . |
ArtifactResolver |
getArtifactResolver()
Getter for
artifactResolver . |
boolean |
getDownloadJavadocs()
Getter for
downloadJavadocs . |
boolean |
getDownloadSources()
Getter for
downloadSources . |
abstract List |
getExcludes() |
MavenProject |
getExecutedProject()
Getter for
executedProject . |
ArtifactRepository |
getLocalRepository()
Getter for
localRepository . |
MavenProject |
getProject()
Getter for
project . |
abstract String |
getProjectNameForArifact(Artifact artifact)
Find the name of the project as used in eclipse.
|
protected MavenProject |
getReactorProject(Artifact artifact)
Checks the list of reactor projects to see if the artifact is included.
|
List |
getReactorProjects()
Getter for
reactorProjects . |
List |
getRemoteArtifactRepositories()
Getter for
remoteArtifactRepositories . |
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. |
protected IdeDependency[] |
getWorkspaceArtefacts() |
protected boolean |
hasToResolveJar(Artifact art)
Checks if jar has to be resolved for the given artifact
|
protected boolean |
isAvailableAsAReactorProject(Artifact artifact)
Utility method that locates a project producing the given artifact.
|
protected boolean |
isMavenVersion(String version)
Checks whether the currently running Maven satisfies the specified version (range).
|
protected boolean |
isResolveDependencies() |
void |
setArtifactFactory(ArtifactFactory artifactFactory)
Setter for
artifactFactory . |
void |
setArtifactMetadataSource(ArtifactMetadataSource artifactMetadataSource)
Setter for
artifactMetadataSource . |
void |
setArtifactResolver(ArtifactResolver artifactResolver)
Setter for
artifactResolver . |
void |
setDownloadJavadocs(boolean downloadJavadoc)
Setter for
downloadJavadocs . |
void |
setDownloadSources(boolean downloadSources)
Setter for
downloadSources . |
void |
setExecutedProject(MavenProject executedProject)
Setter for
executedProject . |
void |
setLocalRepository(ArtifactRepository localRepository)
Setter for
localRepository . |
void |
setProject(MavenProject project)
Setter for
project . |
void |
setReactorProjects(List reactorProjects)
Setter for
reactorProjects . |
void |
setRemoteArtifactRepositories(List remoteArtifactRepositories)
Setter for
remoteArtifactRepositories . |
protected void |
setResolveDependencies(boolean resolveDependencies) |
protected abstract boolean |
setup()
Hook for preparation steps before the actual plugin execution.
|
protected boolean |
useProjectReference(Artifact art)
Checks if a projects reference has to be used for the given artifact
|
protected abstract void |
writeConfiguration(IdeDependency[] deps)
Main plugin method where dependencies should be processed in order to generate IDE configuration files.
|
getLog, getPluginContext, setLog, setPluginContext
@Parameter(property="project", required=true, readonly=true) protected MavenProject project
@Parameter(property="executedProject", readonly=true) protected MavenProject executedProject
@Parameter(property="project.packaging") protected String packaging
@Component(role=org.apache.maven.artifact.factory.ArtifactFactory.class) protected ArtifactFactory artifactFactory
@Component(role=org.apache.maven.artifact.resolver.ArtifactResolver.class) protected ArtifactResolver artifactResolver
@Component(role=org.apache.maven.artifact.resolver.ArtifactCollector.class) protected ArtifactCollector artifactCollector
@Component(role=org.apache.maven.artifact.metadata.ArtifactMetadataSource.class, hint="maven") protected ArtifactMetadataSource artifactMetadataSource
@Parameter(property="project.remoteArtifactRepositories", required=true, readonly=true) protected List remoteArtifactRepositories
@Parameter(property="localRepository", required=true, readonly=true) protected ArtifactRepository localRepository
@Parameter(property="reactorProjects", required=true, readonly=true) protected List reactorProjects
@Parameter(property="downloadSources") protected boolean downloadSources
true
remote repositories are checked for sources: in order to avoid repeated check for unavailable source archives, a
status cache is mantained. With versions 2.6+ of the plugin to reset this cache run
mvn eclipse:remove-cache
, or use the forceRecheck
option with versions. With older
versions delete the file mvn-eclipse-cache.properties
in the target directory.@Parameter(property="downloadJavadocs") protected boolean downloadJavadocs
true
remote repositories are checked for javadocs: in order to avoid repeated check for unavailable javadoc archives,
a status cache is mantained. With versions 2.6+ of the plugin to reset this cache run
mvn eclipse:remove-cache
, or use the forceRecheck
option with versions. With older
versions delete the file mvn-eclipse-cache.properties
in the target directory.@Parameter(property="forceRecheck") protected boolean forceRecheck
true
and the source or javadoc attachment has a status cache to indicate
that it is not available, then the remote repository will be rechecked for a source or javadoc attachment and the
status cache updated to reflect the new state.protected org.codehaus.plexus.logging.Logger logger
public ArtifactMetadataSource getArtifactMetadataSource()
artifactMetadataSource
.public void setArtifactMetadataSource(ArtifactMetadataSource artifactMetadataSource)
artifactMetadataSource
.artifactMetadataSource
- The artifactMetadataSource to set.public MavenProject getProject()
project
.public void setProject(MavenProject project)
project
.project
- The project to set.public List getReactorProjects()
reactorProjects
.public void setReactorProjects(List reactorProjects)
reactorProjects
.reactorProjects
- The reactorProjects to set.public List getRemoteArtifactRepositories()
remoteArtifactRepositories
.public void setRemoteArtifactRepositories(List remoteArtifactRepositories)
remoteArtifactRepositories
.remoteArtifactRepositories
- The remoteArtifactRepositories to set.public ArtifactFactory getArtifactFactory()
artifactFactory
.public void setArtifactFactory(ArtifactFactory artifactFactory)
artifactFactory
.artifactFactory
- The artifactFactory to set.public ArtifactResolver getArtifactResolver()
artifactResolver
.public void setArtifactResolver(ArtifactResolver artifactResolver)
artifactResolver
.artifactResolver
- The artifactResolver to set.public MavenProject getExecutedProject()
executedProject
.public void setExecutedProject(MavenProject executedProject)
executedProject
.executedProject
- The executedProject to set.public ArtifactRepository getLocalRepository()
localRepository
.public void setLocalRepository(ArtifactRepository localRepository)
localRepository
.localRepository
- The localRepository to set.public boolean getDownloadJavadocs()
downloadJavadocs
.public void setDownloadJavadocs(boolean downloadJavadoc)
downloadJavadocs
.downloadJavadoc
- The downloadJavadocs to set.public boolean getDownloadSources()
downloadSources
.public void setDownloadSources(boolean downloadSources)
downloadSources
.downloadSources
- The downloadSources to set.protected void setResolveDependencies(boolean resolveDependencies)
protected boolean isResolveDependencies()
protected abstract boolean getUseProjectReferences()
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.true
if referenced project will be linked and not need artifact resolutionprotected abstract boolean setup() throws MojoExecutionException
true
if execution should continue or false
if not.MojoExecutionException
- generic mojo exceptionprotected abstract void writeConfiguration(IdeDependency[] deps) throws MojoExecutionException
deps
- list of IdeDependency
objects, with artifacts, sources and javadocs already resolvedMojoExecutionException
- generic mojo exceptionpublic void enableLogging(org.codehaus.plexus.logging.Logger logger)
enableLogging
in interface org.codehaus.plexus.logging.LogEnabled
LogEnabled.enableLogging(org.codehaus.plexus.logging.Logger)
public final void execute() throws MojoExecutionException, MojoFailureException
execute
in interface Mojo
MojoExecutionException
MojoFailureException
Mojo.execute()
protected IdeDependency[] doDependencyResolution() throws MojoExecutionException
MojoExecutionException
- if dependencies can't be resolvedpublic abstract String getProjectNameForArifact(Artifact artifact)
artifact
- The artifact to find the eclipse name for.protected boolean isAvailableAsAReactorProject(Artifact artifact)
artifact
- the artifact a project should produce.true
if the artifact is produced by a reactor projectart.protected MavenProject getReactorProject(Artifact artifact)
artifact
- the artifact to check if it is in the reactorprotected IdeDependency[] getWorkspaceArtefacts()
public abstract List getExcludes()
protected boolean hasToResolveJar(Artifact art)
art
- the artifact to checkprotected boolean useProjectReference(Artifact art)
art
- the artifact to checkprotected boolean isMavenVersion(String version)
version
- The version range to test for, must not be null
.true
if the current Maven version matches the specified version range, false
otherwise.Copyright © 2002–2015 The Apache Software Foundation. All rights reserved.