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   * 
12   * @goal m2eclipse
13   * @execute phase="generate-resources"
14   * @since 2.4
15   */
16  public class M2EclipseMojo
17      extends EclipsePlugin
18  {
19  
20      protected static final String M2ECLIPSE_NATURE = "org.maven.ide.eclipse.maven2Nature";
21  
22      protected static final String M2ECLIPSE_BUILD_COMMAND = "org.maven.ide.eclipse.maven2Builder";
23  
24      protected static final String M2ECLIPSE_CLASSPATH_CONTAINER = "org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER";
25  
26      protected void setupExtras()
27          throws MojoExecutionException
28      {
29          // disable normal dependency resolution; the m2eclipse plugin will handle it.
30          setResolveDependencies( false );
31  
32          setAdditionalProjectnatures( new ArrayList( Collections.singletonList( M2ECLIPSE_NATURE ) ) );
33          setAdditionalBuildcommands( new ArrayList( Collections.singletonList( M2ECLIPSE_BUILD_COMMAND ) ) );
34  
35          List classpathContainers = getClasspathContainers();
36          if ( classpathContainers == null )
37          {
38              classpathContainers = new ArrayList();
39  
40              classpathContainers.add( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER );
41  
42              if ( isPdeProject() )
43              {
44                  classpathContainers.add( REQUIRED_PLUGINS_CONTAINER );
45              }
46          }
47  
48          classpathContainers.add( M2ECLIPSE_CLASSPATH_CONTAINER );
49  
50          setClasspathContainers( classpathContainers );
51      }
52  
53  }