View Javadoc

1   package org.apache.maven.plugin.eclipse;
2   
3   import java.util.ArrayList;
4   import java.util.Collections;
5   import java.util.List;
6   
7   import org.apache.maven.plugin.MojoExecutionException;
8   
9   /**
10   * Creates an eclipse project that is ready to use with the M2Elipse plugin.
11   * @goal m2eclipse
12   * @execute phase="generate-resources"
13   */
14  public class M2EclipseMojo
15      extends EclipsePlugin
16  {
17  
18      protected static final String M2ECLIPSE_NATURE = "org.maven.ide.eclipse.maven2Nature";
19  
20      protected static final String M2ECLIPSE_BUILD_COMMAND = "org.maven.ide.eclipse.maven2Builder";
21  
22      protected static final String M2ECLIPSE_CLASSPATH_CONTAINER = "org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER";
23  
24      protected void setupExtras()
25          throws MojoExecutionException
26      {
27          // disable normal dependency resolution; the m2eclipse plugin will handle it.
28          setResolveDependencies( false );
29  
30          setAdditionalProjectnatures( new ArrayList( Collections.singletonList( M2ECLIPSE_NATURE ) ) );
31          setAdditionalBuildcommands( new ArrayList( Collections.singletonList( M2ECLIPSE_BUILD_COMMAND ) ) );
32  
33          List classpathContainers = getClasspathContainers();
34          if ( classpathContainers == null )
35          {
36              classpathContainers = new ArrayList();
37  
38              classpathContainers.add( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER );
39  
40              if ( isPdeProject() )
41              {
42                  classpathContainers.add( REQUIRED_PLUGINS_CONTAINER );
43              }
44          }
45  
46          classpathContainers.add( M2ECLIPSE_CLASSPATH_CONTAINER );
47  
48          setClasspathContainers( classpathContainers );
49      }
50  
51  }