go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Java Deploying » Maven -- Import Java project into Eclipse IDE
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Maven -- Import Java project into Eclipse IDE
Alex_Raj
member
offline   
 
posts: 99
joined: 05/16/2006
from: San Jose, CA
  posted on: 03/27/2012 07:21:46 PM    Edit  |   Quote  |   Report 
Maven -- Import Java project into Eclipse IDE
Once you have a Maven generated project, how can you convert it into Eclipse IDE?

Type in the following command where your poject with the pom.xml resides:

mvn eclipse:eclipse


Output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-eclipse-plugin:2.9:eclipse (default-cli) @ MyProject >>>
[INFO]
[INFO] <<< maven-eclipse-plugin:2.9:eclipse (default-cli) @ MyProject <<<
[INFO]
[INFO] --- maven-eclipse-plugin:2.9:eclipse (default-cli) @ MyProject ---
[INFO] Using Eclipse Workspace: null
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
[INFO] Not writing settings - defaults suffice
[INFO] Wrote Eclipse project for "MyProject" to C:\HelloWorld\Maven\MyFirstProje
ct\MyProject.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.402s
[INFO] Finished at: Tue Mar 27 17:16:21 PDT 2012
[INFO] Final Memory: 7M/124M
[INFO] ------------------------------------------------------------------------
 Profile | Reply Points Earned: 0
Alex_Raj
member
offline   
 
posts: 99
joined: 05/16/2006
from: San Jose, CA
  posted on: 03/27/2012 07:43:08 PM    Edit  |   Quote  |   Report 
What have been done?
Two files have been created for your project:

.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>MyProject</name>
  <comment>NO_M2ECLIPSE_SUPPORT: Project files created 
with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
  <projects/>
  <buildSpec>
    <buildCommand>
      <name>org.eclipse.jdt.core.javabuilder</name>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
  </natures>
</projectDescription>



.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
  <classpathentry kind="output" path="target/classes"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
</classpath>


It should be noted a classpath variable M2_REPO has been referenced which must be declared in your Eclipse project build path.
 Profile | Reply Points Earned: 0
Alex_Raj
member
offline   
 
posts: 99
joined: 05/16/2006
from: San Jose, CA
  posted on: 03/27/2012 08:25:47 PM    Edit  |   Quote  |   Report 
Import into Eclipse IDE
You can import it into Eclipse IDE now.

File -> Import… -> General -> Existing Projects into Workspace:

1)Type in your project folder in the Select root directory box: C:\HelloWorld\Maven\MyFirstProject\MyProject

2)Check Copy projects into workspace checkbox.

3)Click on Finish button.

 Profile | Reply Points Earned: 0

 
Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
 
Get your own forum today. It's easy and free.