org.apache.maven.plugin.eclipse
Class EclipsePlugin

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.maven.plugin.ide.AbstractIdeSupportMojo
          extended by org.apache.maven.plugin.eclipse.EclipsePlugin
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.codehaus.plexus.logging.LogEnabled
Direct Known Subclasses:
M2EclipseMojo, MyEclipsePlugin, RadPlugin

public class EclipsePlugin
extends AbstractIdeSupportMojo

Generates the following eclipse configuration files:

If this goal is run on a multiproject root, dependencies between modules will be configured as direct project dependencies in Eclipse (unless useProjectReferences is set to false).

Version:
$Id: EclipsePlugin.java 779829 2009-05-29 03:41:15Z baerrach $
Author:
Trygve Laugstøl, Fabrizio Giustina
Is defined to be executed in:
phase:
generate-resources
Is defined by the goal name:
eclipse

Field Summary
static java.lang.String ASPECTJ_FILE_PATTERN
           
protected static java.lang.String ASPECTJ_RT_CONTAINER
           
protected static java.lang.String BUILDER_WST_VALIDATION
           
protected static java.lang.String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER
           
static java.lang.String JAVA_FILE_PATTERN
           
protected  boolean limitProjectReferencesToWorkspace
          Limit the use of project references to the current workspace.
protected static java.lang.String REQUIRED_PLUGINS_CONTAINER
           
protected  java.io.File workspace
          This eclipse workspace is read and all artifacts detected there will be connected as eclipse projects and will not be linked to the jars in the local repository.
static java.lang.String[] WTP_SUPPORTED_VERSIONS
           
 
Fields inherited from class org.apache.maven.plugin.ide.AbstractIdeSupportMojo
artifactCollector, artifactFactory, artifactMetadataSource, artifactResolver, downloadJavadocs, downloadSources, executedProject, forceRecheck, localRepository, logger, packaging, project, reactorProjects, remoteArtifactRepositories
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
EclipsePlugin()
           
 
Method Summary
 EclipseSourceDir[] buildDirectoryList(org.apache.maven.project.MavenProject project, java.io.File basedir, java.io.File buildOutputDirectory)
           
protected  void checkDeprecationsExtras()
          Extension point for subclasses.
protected  void convertBuildCommandList(java.util.List commands)
          Convert any Strings in the commands List to BuildCommands.
protected  EclipseWriterConfig createEclipseWriterConfig(IdeDependency[] deps)
          Create the EclipseWriterConfig for the specified dependencies.
protected  void fillDefaultBuilders(java.lang.String packaging)
          Fill getBuildcommands() with values.
protected  void fillDefaultClasspathContainers(java.lang.String packaging)
          Fill getClasspathContainers() with values.
protected  void fillDefaultNatures(java.lang.String packaging)
          Fill getProjectnatures() with values.
 java.util.List getAdditionalBuildcommands()
          Getter for additionalBuildcommands.
 java.util.List getAdditionalProjectnatures()
          Getter for additionalProjectnatures.
 java.util.List getBuildcommands()
          Getter for buildcommands.
 java.io.File getBuildOutputDirectory()
          Getter for buildOutputDirectory.
 java.util.List getClasspathContainers()
          Getter for classpathContainers.
 java.io.File getEclipseProjectDir()
          Getter for eclipseProjectDir.
 java.util.List getExcludes()
           
 java.lang.String getProjectNameForArifact(org.apache.maven.artifact.Artifact artifact)
          Find the name of the project as used in eclipse.
 java.lang.String getProjectNameTemplate()
          Getter for projectNameTemplate
 java.util.List getProjectnatures()
          Getter for projectnatures.
 boolean getUseProjectReferences()
          Getter for useProjectReferences.
protected  IdeDependency[] getWorkspaceArtefacts()
          
 WorkspaceConfiguration getWorkspaceConfiguration()
           
 java.lang.String getWtpversion()
          Getter for wtpversion.
protected  boolean hasToResolveJar(org.apache.maven.artifact.Artifact art)
          Checks if jar has to be resolved for the given artifact
 boolean isAddGroupIdToProjectName()
          Getter for addGroupIdToProjectName.
 boolean isAddVersionToProjectName()
          Getter for addVersionToProjectName.
protected  boolean isJavaProject()
           
protected  boolean isPdeProject()
           
 void setAddGroupIdToProjectName(boolean addGroupIdToProjectName)
          Setter for addGroupIdToProjectName.
 void setAdditionalBuildcommands(java.util.List additionalBuildcommands)
          Setter for additionalBuildcommands.
 void setAdditionalProjectnatures(java.util.List additionalProjectnatures)
          Setter for additionalProjectnatures.
 void setAddVersionToProjectName(boolean addVersionToProjectName)
          Setter for addVersionToProjectName.
 void setBuildcommands(java.util.List buildcommands)
          Setter for buildcommands.
 void setBuildOutputDirectory(java.io.File buildOutputDirectory)
          Setter for buildOutputDirectory.
 void setClasspathContainers(java.util.List classpathContainers)
          Setter for classpathContainers.
 void setEclipseProjectDir(java.io.File eclipseProjectDir)
          Setter for eclipseProjectDir.
 void setProjectNameTemplate(java.lang.String projectNameTemplate)
          Setter for projectNameTemplate.
 void setProjectnatures(java.util.List projectnatures)
          Setter for projectnatures.
 boolean setup()
          Hook for preparation steps before the actual plugin execution.
protected  void setupExtras()
          Extension point for subclasses.
 void setUseProjectReferences(boolean useProjectReferences)
          Setter for useProjectReferences.
 void setWtpversion(java.lang.String wtpversion)
          Setter for wtpversion.
protected  boolean useProjectReference(org.apache.maven.artifact.Artifact art)
          Checks if a projects reference has to be used for the given artifact
protected  void validateExtras()
          Extension point for subclasses.
 void writeConfiguration(IdeDependency[] deps)
          Main plugin method where dependencies should be processed in order to generate IDE configuration files.
protected  void writeConfigurationExtras(EclipseWriterConfig config)
          Write any extra configuration information for the Eclipse project.
 
Methods inherited from class org.apache.maven.plugin.ide.AbstractIdeSupportMojo
doDependencyResolution, enableLogging, execute, getArtifactFactory, getArtifactMetadataSource, getArtifactResolver, getDownloadJavadocs, getDownloadSources, getExecutedProject, getLocalRepository, getProject, getReactorProject, getReactorProjects, getRemoteArtifactRepositories, isAvailableAsAReactorProject, isMavenVersion, isResolveDependencies, setArtifactFactory, setArtifactMetadataSource, setArtifactResolver, setDownloadJavadocs, setDownloadSources, setExecutedProject, setLocalRepository, setProject, setReactorProjects, setRemoteArtifactRepositories, setResolveDependencies
 
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
 

Field Detail

BUILDER_WST_VALIDATION

protected static final java.lang.String BUILDER_WST_VALIDATION
See Also:
Constant Field Values

COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER

protected static final java.lang.String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER
See Also:
Constant Field Values

ASPECTJ_RT_CONTAINER

protected static final java.lang.String ASPECTJ_RT_CONTAINER
See Also:
Constant Field Values

REQUIRED_PLUGINS_CONTAINER

protected static final java.lang.String REQUIRED_PLUGINS_CONTAINER
See Also:
Constant Field Values

WTP_SUPPORTED_VERSIONS

public static final java.lang.String[] WTP_SUPPORTED_VERSIONS

ASPECTJ_FILE_PATTERN

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

JAVA_FILE_PATTERN

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

workspace

protected java.io.File workspace
This eclipse workspace is read and all artifacts detected there will be connected as eclipse projects and will not be linked to the jars in the local repository. Requirement is that it was created with the similar wtp settings as the reactor projects, but the project name template my differ. The pom's in the workspace projects may not contain variables in the artefactId, groupId and version tags. If workspace is not defined, then an attempt to locate it by checking up the directory hierarchy will be made.

Since:
2.5
Is defined by:
expression:
${eclipse.workspace}

limitProjectReferencesToWorkspace

protected boolean limitProjectReferencesToWorkspace
Limit the use of project references to the current workspace. No project references will be created to projects in the reactor when they are not available in the workspace.

Is defined by:
expression:
${eclipse.limitProjectReferencesToWorkspace}
default-value:
false
Constructor Detail

EclipsePlugin

public EclipsePlugin()
Method Detail

isJavaProject

protected final boolean isJavaProject()

isPdeProject

protected final boolean isPdeProject()

getBuildcommands

public final java.util.List getBuildcommands()
Getter for buildcommands.

Returns:
Returns the buildcommands.

setBuildcommands

public final void setBuildcommands(java.util.List buildcommands)
Setter for buildcommands.

Parameters:
buildcommands - The buildcommands to set.

getBuildOutputDirectory

public final java.io.File getBuildOutputDirectory()
Getter for buildOutputDirectory.

Returns:
Returns the buildOutputDirectory.

setBuildOutputDirectory

public final void setBuildOutputDirectory(java.io.File buildOutputDirectory)
Setter for buildOutputDirectory.

Parameters:
buildOutputDirectory - The buildOutputDirectory to set.

getClasspathContainers

public final java.util.List getClasspathContainers()
Getter for classpathContainers.

Returns:
Returns the classpathContainers.

setClasspathContainers

public final void setClasspathContainers(java.util.List classpathContainers)
Setter for classpathContainers.

Parameters:
classpathContainers - The classpathContainers to set.

getEclipseProjectDir

public final java.io.File getEclipseProjectDir()
Getter for eclipseProjectDir.

Returns:
Returns the eclipseProjectDir.

setEclipseProjectDir

public final void setEclipseProjectDir(java.io.File eclipseProjectDir)
Setter for eclipseProjectDir.

Parameters:
eclipseProjectDir - The eclipseProjectDir to set.

getProjectnatures

public final java.util.List getProjectnatures()
Getter for projectnatures.

Returns:
Returns the projectnatures.

setProjectnatures

public final void setProjectnatures(java.util.List projectnatures)
Setter for projectnatures.

Parameters:
projectnatures - The projectnatures to set.

getUseProjectReferences

public final boolean getUseProjectReferences()
Getter for useProjectReferences.

Specified by:
getUseProjectReferences in class AbstractIdeSupportMojo
Returns:
Returns the useProjectReferences.

setUseProjectReferences

public final void setUseProjectReferences(boolean useProjectReferences)
Setter for useProjectReferences.

Parameters:
useProjectReferences - The useProjectReferences to set.

getWtpversion

public final java.lang.String getWtpversion()
Getter for wtpversion.

Returns:
Returns the wtpversion.

setWtpversion

public final void setWtpversion(java.lang.String wtpversion)
Setter for wtpversion.

Parameters:
wtpversion - The wtpversion to set.

getAdditionalBuildcommands

public final java.util.List getAdditionalBuildcommands()
Getter for additionalBuildcommands.

Returns:
Returns the additionalBuildcommands.

setAdditionalBuildcommands

public final void setAdditionalBuildcommands(java.util.List additionalBuildcommands)
Setter for additionalBuildcommands.

Parameters:
additionalBuildcommands - The additionalBuildcommands to set.

getAdditionalProjectnatures

public final java.util.List getAdditionalProjectnatures()
Getter for additionalProjectnatures.

Returns:
Returns the additionalProjectnatures.

setAdditionalProjectnatures

public final void setAdditionalProjectnatures(java.util.List additionalProjectnatures)
Setter for additionalProjectnatures.

Parameters:
additionalProjectnatures - The additionalProjectnatures to set.

isAddVersionToProjectName

public final boolean isAddVersionToProjectName()
Getter for addVersionToProjectName.


setAddVersionToProjectName

public final void setAddVersionToProjectName(boolean addVersionToProjectName)
Setter for addVersionToProjectName.


isAddGroupIdToProjectName

public final boolean isAddGroupIdToProjectName()
Getter for addGroupIdToProjectName.


setAddGroupIdToProjectName

public final void setAddGroupIdToProjectName(boolean addGroupIdToProjectName)
Setter for addGroupIdToProjectName.


getProjectNameTemplate

public final java.lang.String getProjectNameTemplate()
Getter for projectNameTemplate

Returns:
projectNameTemplate

setProjectNameTemplate

public final void setProjectNameTemplate(java.lang.String projectNameTemplate)
Setter for projectNameTemplate.

Parameters:
projectNameTemplate - projectNameTemplate

setup

public final boolean setup()
                    throws org.apache.maven.plugin.MojoExecutionException
Description copied from class: AbstractIdeSupportMojo
Hook for preparation steps before the actual plugin execution.

Specified by:
setup in class AbstractIdeSupportMojo
Returns:
true if execution should continue or false if not.
Throws:
org.apache.maven.plugin.MojoExecutionException - generic mojo exception
See Also:
Mojo.execute()

convertBuildCommandList

protected final void convertBuildCommandList(java.util.List commands)
Convert any Strings in the commands List to BuildCommands. The conversion happens in situ.

Parameters:
commands - a list of commands to convert into BuildCommand

setupExtras

protected void setupExtras()
                    throws org.apache.maven.plugin.MojoExecutionException
Extension point for subclasses.

Called during setup.

Throws:
org.apache.maven.plugin.MojoExecutionException - mojo failures.

validateExtras

protected void validateExtras()
                       throws org.apache.maven.plugin.MojoExecutionException
Extension point for subclasses.

Called during setup and used to validate that the configuration is sane.

Throws:
org.apache.maven.plugin.MojoExecutionException - mojo failures.

checkDeprecationsExtras

protected void checkDeprecationsExtras()
Extension point for subclasses.

Check for any extra deprecations and log warnings. Called during setup


writeConfiguration

public final void writeConfiguration(IdeDependency[] deps)
                              throws org.apache.maven.plugin.MojoExecutionException
Description copied from class: AbstractIdeSupportMojo
Main plugin method where dependencies should be processed in order to generate IDE configuration files.

Specified by:
writeConfiguration in class AbstractIdeSupportMojo
Parameters:
deps - list of IdeDependency objects, with artifacts, sources and javadocs already resolved
Throws:
org.apache.maven.plugin.MojoExecutionException - generic mojo exception

createEclipseWriterConfig

protected final EclipseWriterConfig createEclipseWriterConfig(IdeDependency[] deps)
                                                       throws org.apache.maven.plugin.MojoExecutionException
Create the EclipseWriterConfig for the specified dependencies.

Parameters:
deps - the project dependencies
Returns:
a configured EclipseWriterConfig
Throws:
org.apache.maven.plugin.MojoExecutionException - mojo failures.

writeConfigurationExtras

protected void writeConfigurationExtras(EclipseWriterConfig config)
                                 throws org.apache.maven.plugin.MojoExecutionException
Write any extra configuration information for the Eclipse project. This is an extension point, called before the main configurations are written.
NOTE: This could change the config!

Parameters:
config -
Throws:
org.apache.maven.plugin.MojoExecutionException

fillDefaultNatures

protected void fillDefaultNatures(java.lang.String packaging)
Fill getProjectnatures() with values.

Subclasses should call super and then calculate their own additions and insert them via getProjectnatures().addAll().

Parameters:
packaging - the pom's packaging

fillDefaultClasspathContainers

protected void fillDefaultClasspathContainers(java.lang.String packaging)
Fill getClasspathContainers() with values.

Subclasses should call super and then calculate their own additions and insert them via getClasspathContainers().addAll().

Parameters:
packaging - the pom's packaging

fillDefaultBuilders

protected void fillDefaultBuilders(java.lang.String packaging)
Fill getBuildcommands() with values.

Subclasses should call super and then calculate their own additions and insert them via getBuildcommands().addAll().

Parameters:
packaging - the pom's packaging

buildDirectoryList

public final EclipseSourceDir[] buildDirectoryList(org.apache.maven.project.MavenProject project,
                                                   java.io.File basedir,
                                                   java.io.File buildOutputDirectory)
                                            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getProjectNameForArifact

public java.lang.String getProjectNameForArifact(org.apache.maven.artifact.Artifact artifact)
Find the name of the project as used in eclipse.

Specified by:
getProjectNameForArifact in class AbstractIdeSupportMojo
Parameters:
artifact - The artifact to find the eclipse name for.
Returns:
The name os the eclipse project.

getWorkspaceArtefacts

protected final IdeDependency[] getWorkspaceArtefacts()

Overrides:
getWorkspaceArtefacts in class AbstractIdeSupportMojo
Returns:
an array with all dependencies avalaible in the workspace, to be implemented by the subclasses.

getWorkspaceConfiguration

public final WorkspaceConfiguration getWorkspaceConfiguration()

getExcludes

public final java.util.List getExcludes()
Specified by:
getExcludes in class AbstractIdeSupportMojo
Returns:
List of dependencies to exclude from eclipse classpath.

hasToResolveJar

protected final boolean hasToResolveJar(org.apache.maven.artifact.Artifact art)
Checks if jar has to be resolved for the given artifact

Overrides:
hasToResolveJar in class AbstractIdeSupportMojo
Parameters:
art - the artifact to check
Returns:
true if resolution should happen

useProjectReference

protected final boolean useProjectReference(org.apache.maven.artifact.Artifact art)
Checks if a projects reference has to be used for the given artifact

Overrides:
useProjectReference in class AbstractIdeSupportMojo
Parameters:
art - the artifact to check
Returns:
true if a project reference has to be used.


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