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:
ContextEnabled, Mojo, org.codehaus.plexus.logging.LogEnabled
Direct Known Subclasses:
MyEclipsePlugin, RadPlugin

@Mojo(name="eclipse")
@Execute(phase=GENERATE_RESOURCES)
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 1681500 2015-05-24 17:25:06Z agudian $
Author:
Trygve Laugstøl, Fabrizio Giustina

Field Summary
static String ASPECTJ_FILE_PATTERN
           
protected static String ASPECTJ_RT_CONTAINER
           
protected static String BUILDER_WST_VALIDATION
           
protected  boolean classpathContainersLast
          Put classpath container entries last in eclipse classpath configuration.
protected static String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER
           
static String JAVA_FILE_PATTERN
           
protected  String jeeversion
          The plugin is often capable in predicting the required jee version based on the dependencies of the project.
protected  boolean limitProjectReferencesToWorkspace
          Limit the use of project references to the current workspace.
protected  boolean testSourcesLast
          Whether to place test resources after main resources.
protected  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 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(MavenProject project, File basedir, File buildOutputDirectory)
           
protected  void checkDeprecationsExtras()
          Extension point for subclasses.
protected  void convertBuildCommandList(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(String packaging)
          Fill getBuildcommands() with values.
protected  void fillDefaultClasspathContainers(String packaging)
          Fill getClasspathContainers() with values.
protected  void fillDefaultNatures(String packaging)
          Fill getProjectnatures() with values.
 List getAdditionalBuildcommands()
          Getter for additionalBuildcommands.
 List getAdditionalProjectnatures()
          Getter for additionalProjectnatures.
 List getBuildcommands()
          Getter for buildcommands.
 File getBuildOutputDirectory()
          Getter for buildOutputDirectory.
 List getClasspathContainers()
          Getter for classpathContainers.
 File getEclipseProjectDir()
          Getter for eclipseProjectDir.
 List getExcludes()
           
 List getLinkedResources()
           
 String getProjectNameForArifact(Artifact artifact)
          Find the name of the project as used in eclipse.
 String getProjectNameTemplate()
          Getter for projectNameTemplate
 List getProjectnatures()
          Getter for projectnatures.
 boolean getUseProjectReferences()
          Getter for useProjectReferences.
protected  IdeDependency[] getWorkspaceArtefacts()
          
 WorkspaceConfiguration getWorkspaceConfiguration()
           
 String getWtpversion()
          Getter for wtpversion.
protected  boolean hasToResolveJar(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 isAvailableAsAReactorProject(Artifact artifact)
          Utility method that locates a project producing the given artifact and verifies if it's a valid Eclipse project.
protected  boolean isJavaProject()
           
 void setAddGroupIdToProjectName(boolean addGroupIdToProjectName)
          Setter for addGroupIdToProjectName.
 void setAdditionalBuildcommands(List additionalBuildcommands)
          Setter for additionalBuildcommands.
 void setAdditionalProjectnatures(List additionalProjectnatures)
          Setter for additionalProjectnatures.
 void setAddVersionToProjectName(boolean addVersionToProjectName)
          Setter for addVersionToProjectName.
 void setBuildcommands(List buildcommands)
          Setter for buildcommands.
 void setBuildOutputDirectory(File buildOutputDirectory)
          Setter for buildOutputDirectory.
 void setClasspathContainers(List classpathContainers)
          Setter for classpathContainers.
 void setEclipseProjectDir(File eclipseProjectDir)
          Setter for eclipseProjectDir.
 void setLinkedResources(List linkedResources)
           
 void setProjectNameTemplate(String projectNameTemplate)
          Setter for projectNameTemplate.
 void setProjectnatures(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(String wtpversion)
          Setter for wtpversion.
protected  boolean useProjectReference(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, 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 String BUILDER_WST_VALIDATION
See Also:
Constant Field Values

COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER

protected static final String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER
See Also:
Constant Field Values

ASPECTJ_RT_CONTAINER

protected static final String ASPECTJ_RT_CONTAINER
See Also:
Constant Field Values

WTP_SUPPORTED_VERSIONS

public static final String[] WTP_SUPPORTED_VERSIONS

ASPECTJ_FILE_PATTERN

public static final String ASPECTJ_FILE_PATTERN
See Also:
Constant Field Values

JAVA_FILE_PATTERN

public static final String JAVA_FILE_PATTERN
See Also:
Constant Field Values

workspace

@Parameter(property="eclipse.workspace")
protected 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

limitProjectReferencesToWorkspace

@Parameter(property="eclipse.limitProjectReferencesToWorkspace",
           defaultValue="false")
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.


classpathContainersLast

@Parameter(property="eclipse.classpathContainersLast",
           defaultValue="false")
protected boolean classpathContainersLast
Put classpath container entries last in eclipse classpath configuration. Note that this behaviour, although useful in situations were you want to override resources found in classpath containers, will made JRE classes loaded after 3rd party jars, so enabling it is not suggested.

Since:
2.9

testSourcesLast

@Parameter(property="eclipse.testSourcesLast",
           defaultValue="false")
protected boolean testSourcesLast
Whether to place test resources after main resources. Note that the default behavior of Maven version 2.0.8 or later is to have test dirs before main dirs in classpath so this is discouraged if you need to reproduce the maven behavior during tests. The default behavior is also changed in eclipse plugin version 2.6 in order to better match the maven one. Switching to "test source last" can anyway be useful if you need to run your application in eclipse, since there is no concept in eclipse of "phases" with different set of source dirs and dependencies like we have in maven.

Since:
2.9

jeeversion

@Parameter(property="eclipse.jeeversion")
protected String jeeversion
The plugin is often capable in predicting the required jee version based on the dependencies of the project. By setting this parameter to one of the jeeversion options the version will be locked.
jeeversion EJB version Servlet version JSP version
6.0 3.1 3.0 2.2
5.0 3.0 2.5 2.1
1.4 2.1 2.4 2.0
1.3 2.0 2.3 1.2
1.2 1.1 2.2 1.1

Since:
2.9
Constructor Detail

EclipsePlugin

public EclipsePlugin()
Method Detail

isJavaProject

protected final boolean isJavaProject()

getBuildcommands

public final List getBuildcommands()
Getter for buildcommands.

Returns:
Returns the buildcommands.

setBuildcommands

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

Parameters:
buildcommands - The buildcommands to set.

getBuildOutputDirectory

public final File getBuildOutputDirectory()
Getter for buildOutputDirectory.

Returns:
Returns the buildOutputDirectory.

setBuildOutputDirectory

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

Parameters:
buildOutputDirectory - The buildOutputDirectory to set.

getClasspathContainers

public final List getClasspathContainers()
Getter for classpathContainers.

Returns:
Returns the classpathContainers.

setClasspathContainers

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

Parameters:
classpathContainers - The classpathContainers to set.

getEclipseProjectDir

public final File getEclipseProjectDir()
Getter for eclipseProjectDir.

Returns:
Returns the eclipseProjectDir.

setEclipseProjectDir

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

Parameters:
eclipseProjectDir - The eclipseProjectDir to set.

getProjectnatures

public final List getProjectnatures()
Getter for projectnatures.

Returns:
Returns the projectnatures.

setProjectnatures

public final void setProjectnatures(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 String getWtpversion()
Getter for wtpversion.

Returns:
Returns the wtpversion.

setWtpversion

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

Parameters:
wtpversion - The wtpversion to set.

getAdditionalBuildcommands

public final List getAdditionalBuildcommands()
Getter for additionalBuildcommands.

Returns:
Returns the additionalBuildcommands.

setAdditionalBuildcommands

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

Parameters:
additionalBuildcommands - The additionalBuildcommands to set.

getAdditionalProjectnatures

public final List getAdditionalProjectnatures()
Getter for additionalProjectnatures.

Returns:
Returns the additionalProjectnatures.

setAdditionalProjectnatures

public final void setAdditionalProjectnatures(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 String getProjectNameTemplate()
Getter for projectNameTemplate

Returns:
projectNameTemplate

setProjectNameTemplate

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

Parameters:
projectNameTemplate - projectNameTemplate

getLinkedResources

public List getLinkedResources()
Returns:
the linkedResources

setLinkedResources

public void setLinkedResources(List linkedResources)
Parameters:
linkedResources - the linkedResources to set

setup

public final boolean setup()
                    throws 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:
MojoExecutionException - generic mojo exception
See Also:
Mojo.execute()

convertBuildCommandList

protected final void convertBuildCommandList(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 MojoExecutionException
Extension point for subclasses.

Called during setup.

Throws:
MojoExecutionException - mojo failures.

validateExtras

protected void validateExtras()
                       throws MojoExecutionException
Extension point for subclasses.

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

Throws:
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 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:
MojoExecutionException - generic mojo exception

createEclipseWriterConfig

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

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

writeConfigurationExtras

protected void writeConfigurationExtras(EclipseWriterConfig config)
                                 throws 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:
MojoExecutionException

fillDefaultNatures

protected void fillDefaultNatures(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(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(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(MavenProject project,
                                                   File basedir,
                                                   File buildOutputDirectory)
                                            throws MojoExecutionException
Throws:
MojoExecutionException

getProjectNameForArifact

public String getProjectNameForArifact(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 available in the workspace, to be implemented by the subclasses.

getWorkspaceConfiguration

public final WorkspaceConfiguration getWorkspaceConfiguration()

getExcludes

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

isAvailableAsAReactorProject

protected boolean isAvailableAsAReactorProject(Artifact artifact)
Utility method that locates a project producing the given artifact and verifies if it's a valid Eclipse project.

Overrides:
isAvailableAsAReactorProject in class AbstractIdeSupportMojo
Parameters:
artifact - the artifact a project should produce.
Returns:
true if the artifact is produced by a reactor projectart.

hasToResolveJar

protected final boolean hasToResolveJar(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(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–2015 The Apache Software Foundation. All rights reserved.