public abstract class AbstractIdeSupportMojo
extends org.apache.maven.plugin.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 org.apache.maven.artifact.resolver.ArtifactCollector |
artifactCollector
Artifact collector, needed to resolve dependencies.
|
protected org.apache.maven.artifact.factory.ArtifactFactory |
artifactFactory
Artifact factory, needed to download source jars for inclusion in classpath.
|
protected org.apache.maven.artifact.metadata.ArtifactMetadataSource |
artifactMetadataSource |
protected org.apache.maven.artifact.resolver.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 org.apache.maven.project.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.
|
private IdeDependency[] |
ideDeps
Cached array of resolved dependencies.
|
protected org.apache.maven.artifact.repository.ArtifactRepository |
localRepository
Local maven repository.
|
protected org.codehaus.plexus.logging.Logger |
logger
Plexus logger needed for debugging manual artifact resolution.
|
private java.util.List |
missingJavadocDependencies
Not a plugin parameter.
|
private java.util.List |
missingSourceDependencies
Not a plugin parameter.
|
protected java.lang.String |
packaging
The project packaging.
|
protected org.apache.maven.project.MavenProject |
project
The project whose project files to create.
|
protected java.util.List |
reactorProjects
If the executed project is a reactor project, this will contains the full list of projects in the reactor.
|
protected java.util.List |
remoteArtifactRepositories
Remote repositories which will be searched for source attachments.
|
private boolean |
resolveDependencies
Flag for mojo implementations to control whether normal maven dependencies should be resolved.
|
private org.apache.maven.execution.RuntimeInformation |
runtimeInformation
The runtime information for Maven, used to retrieve Maven's version number.
|
private boolean |
skip
Skip the operation when true.
|
| Constructor and Description |
|---|
AbstractIdeSupportMojo() |
| Modifier and Type | Method and Description |
|---|---|
private java.util.Map |
createManagedVersionMap(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory,
java.lang.String projectId,
org.apache.maven.model.DependencyManagement dependencyManagement) |
protected IdeDependency[] |
doDependencyResolution()
Resolve project dependencies.
|
void |
enableLogging(org.codehaus.plexus.logging.Logger logger) |
void |
execute() |
org.apache.maven.artifact.factory.ArtifactFactory |
getArtifactFactory()
Getter for
artifactFactory. |
org.apache.maven.artifact.metadata.ArtifactMetadataSource |
getArtifactMetadataSource()
Getter for
artifactMetadataSource. |
org.apache.maven.artifact.resolver.ArtifactResolver |
getArtifactResolver()
Getter for
artifactResolver. |
boolean |
getDownloadJavadocs()
Getter for
downloadJavadocs. |
boolean |
getDownloadSources()
Getter for
downloadSources. |
abstract java.util.List |
getExcludes() |
org.apache.maven.project.MavenProject |
getExecutedProject()
Getter for
executedProject. |
org.apache.maven.artifact.repository.ArtifactRepository |
getLocalRepository()
Getter for
localRepository. |
org.apache.maven.project.MavenProject |
getProject()
Getter for
project. |
private java.util.Set |
getProjectArtifacts()
Returns the list of project artifacts.
|
abstract java.lang.String |
getProjectNameForArifact(org.apache.maven.artifact.Artifact artifact)
Find the name of the project as used in eclipse.
|
protected org.apache.maven.project.MavenProject |
getReactorProject(org.apache.maven.artifact.Artifact artifact)
Checks the list of reactor projects to see if the artifact is included.
|
java.util.List |
getReactorProjects()
Getter for
reactorProjects. |
java.util.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() |
private void |
handleExclusions(org.apache.maven.artifact.Artifact artifact,
org.apache.maven.model.Dependency dependency)
Apply exclusion filters to direct AND transitive dependencies.
|
protected boolean |
hasToResolveJar(org.apache.maven.artifact.Artifact art)
Checks if jar has to be resolved for the given artifact
|
protected boolean |
isAvailableAsAReactorProject(org.apache.maven.artifact.Artifact artifact)
Utility method that locates a project producing the given artifact.
|
protected boolean |
isMavenVersion(java.lang.String version)
Checks whether the currently running Maven satisfies the specified version (range).
|
protected boolean |
isResolveDependencies() |
private void |
reportMissingArtifacts()
Output a message with the list of missing dependencies and info on how turn download on if it was disabled.
|
private java.util.List |
resolveDependenciesWithClassifier(IdeDependency[] deps,
java.lang.String inClassifier,
boolean includeRemoteRepositories)
Resolve the required artifacts for each of the dependency.
|
private void |
resolveSourceAndJavadocArtifacts(IdeDependency[] deps)
Resolve source artifacts and download them if
downloadSources is true. |
void |
setArtifactFactory(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory)
Setter for
artifactFactory. |
void |
setArtifactMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource)
Setter for
artifactMetadataSource. |
void |
setArtifactResolver(org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver)
Setter for
artifactResolver. |
void |
setDownloadJavadocs(boolean downloadJavadoc)
Setter for
downloadJavadocs. |
void |
setDownloadSources(boolean downloadSources)
Setter for
downloadSources. |
void |
setExecutedProject(org.apache.maven.project.MavenProject executedProject)
Setter for
executedProject. |
void |
setLocalRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository)
Setter for
localRepository. |
void |
setProject(org.apache.maven.project.MavenProject project)
Setter for
project. |
void |
setReactorProjects(java.util.List reactorProjects)
Setter for
reactorProjects. |
void |
setRemoteArtifactRepositories(java.util.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(org.apache.maven.artifact.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.
|
protected org.apache.maven.project.MavenProject project
protected org.apache.maven.project.MavenProject executedProject
protected java.lang.String packaging
protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
protected org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver
protected org.apache.maven.artifact.resolver.ArtifactCollector artifactCollector
protected org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource
private org.apache.maven.execution.RuntimeInformation runtimeInformation
protected java.util.List remoteArtifactRepositories
protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
protected java.util.List reactorProjects
private boolean skip
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.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.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
private java.util.List missingSourceDependencies
private java.util.List missingJavadocDependencies
private IdeDependency[] ideDeps
private boolean resolveDependencies
public org.apache.maven.artifact.metadata.ArtifactMetadataSource getArtifactMetadataSource()
artifactMetadataSource.public void setArtifactMetadataSource(org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource)
artifactMetadataSource.artifactMetadataSource - The artifactMetadataSource to set.public org.apache.maven.project.MavenProject getProject()
project.public void setProject(org.apache.maven.project.MavenProject project)
project.project - The project to set.public java.util.List getReactorProjects()
reactorProjects.public void setReactorProjects(java.util.List reactorProjects)
reactorProjects.reactorProjects - The reactorProjects to set.public java.util.List getRemoteArtifactRepositories()
remoteArtifactRepositories.public void setRemoteArtifactRepositories(java.util.List remoteArtifactRepositories)
remoteArtifactRepositories.remoteArtifactRepositories - The remoteArtifactRepositories to set.public org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
artifactFactory.public void setArtifactFactory(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory)
artifactFactory.artifactFactory - The artifactFactory to set.public org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
artifactResolver.public void setArtifactResolver(org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver)
artifactResolver.artifactResolver - The artifactResolver to set.public org.apache.maven.project.MavenProject getExecutedProject()
executedProject.public void setExecutedProject(org.apache.maven.project.MavenProject executedProject)
executedProject.executedProject - The executedProject to set.public org.apache.maven.artifact.repository.ArtifactRepository getLocalRepository()
localRepository.public void setLocalRepository(org.apache.maven.artifact.repository.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 org.apache.maven.plugin.MojoExecutionException
true if execution should continue or false if not.org.apache.maven.plugin.MojoExecutionException - generic mojo exceptionprotected abstract void writeConfiguration(IdeDependency[] deps) throws org.apache.maven.plugin.MojoExecutionException
deps - list of IdeDependency objects, with artifacts, sources and javadocs already resolvedorg.apache.maven.plugin.MojoExecutionException - generic mojo exceptionpublic void enableLogging(org.codehaus.plexus.logging.Logger logger)
enableLogging in interface org.codehaus.plexus.logging.LogEnabledLogEnabled.enableLogging(org.codehaus.plexus.logging.Logger)public final void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
execute in interface org.apache.maven.plugin.Mojoorg.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionMojo.execute()protected IdeDependency[] doDependencyResolution() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - if dependencies can't be resolvedpublic abstract java.lang.String getProjectNameForArifact(org.apache.maven.artifact.Artifact artifact)
artifact - The artifact to find the eclipse name for.private java.util.Set getProjectArtifacts()
throws org.apache.maven.plugin.MojoExecutionException
resolved property set to true.org.apache.maven.plugin.MojoExecutionException - if unable to parse dependency versionsprivate void handleExclusions(org.apache.maven.artifact.Artifact artifact,
org.apache.maven.model.Dependency dependency)
artifact - dependency - protected boolean isAvailableAsAReactorProject(org.apache.maven.artifact.Artifact artifact)
artifact - the artifact a project should produce.true if the artifact is produced by a reactor projectart.protected org.apache.maven.project.MavenProject getReactorProject(org.apache.maven.artifact.Artifact artifact)
artifact - the artifact to check if it is in the reactorprotected IdeDependency[] getWorkspaceArtefacts()
private java.util.Map createManagedVersionMap(org.apache.maven.artifact.factory.ArtifactFactory artifactFactory,
java.lang.String projectId,
org.apache.maven.model.DependencyManagement dependencyManagement)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void resolveSourceAndJavadocArtifacts(IdeDependency[] deps)
downloadSources is true. Source and
javadocs artifacts will be attached to the IdeDependency Resolve source and javadoc artifacts. The
resolved artifacts will be downloaded based on the downloadSources and downloadJavadocs
attributes. Source anddeps - resolved dependenciesprivate java.util.List resolveDependenciesWithClassifier(IdeDependency[] deps, java.lang.String inClassifier, boolean includeRemoteRepositories)
sources or javadoc artifacts
(depending on the classifier) are attached to the dependency.deps - resolved dependenciesinClassifier - the classifier we are looking for (either sources or javadoc)includeRemoteRepositories - flag whether we should search remote repositories for the artifacts or notprivate void reportMissingArtifacts()
public abstract java.util.List getExcludes()
protected boolean hasToResolveJar(org.apache.maven.artifact.Artifact art)
art - the artifact to checkprotected boolean useProjectReference(org.apache.maven.artifact.Artifact art)
art - the artifact to checkprotected boolean isMavenVersion(java.lang.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.