Convert Maven based web application to support eclipse

In this section, you will learn to convert Maven based web application to support eclipse.

Last Updated: 21, Jan 2013

Search Tutorials

--Ads--

Convert Maven based web application to support eclipse

In this section, you will learn to convert Maven based web application to support eclipse.

The apache-maven-2.2.1 versions is used in the below example.

Note: If you are unaware of creating web application using maven click here.

Follow the Step to to convert Maven based web application to eclipse web application :

Step1 : First, you need to configure maven-eclipse-plugin in pom.xml as follows :

<!--maven-eclipse-plugin-->
<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.9</version>
	<configuration>
		<pde>true</pde>
	</configuration>
</plugin>

Step 2: Run mvn install to install the maven-compiler-plugin.

C:\project_maven\roseindia-webapp>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building roseindia-webapp Maven Webapp
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclips
e-plugin/2.9/maven-eclipse-plugin-2.9.pom
14K downloaded (maven-eclipse-plugin-2.9.pom)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugin
s/22/maven-plugins-22.pom
12K downloaded (maven-plugins-22.pom)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/21/mave
n-parent-21.pom
25K downloaded (maven-parent-21.pom)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclips
e-plugin/2.9/maven-eclipse-plugin-2.9.jar
212K downloaded (maven-eclipse-plugin-2.9.jar)
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] No sources to compile
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\project_maven\roseindia-webapp\src
\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [war:war {execution: default-war}]
[INFO] Packaging webapp
[INFO] Assembling webapp[roseindia-webapp] in [C:\project_maven\roseindia-webapp
\target\roseindia-webapp]
[INFO] Processing war project
[INFO] Copying webapp resources[C:\project_maven\roseindia-webapp\src\main\webap
p]
[INFO] Webapp assembled in[31 msecs]
[INFO] Building war: C:\project_maven\roseindia-webapp\target\roseindia-webapp.w
ar
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\project_maven\roseindia-webapp\target\roseindia-webapp.war
to C:\Documents and Settings\satya\.m2\repository\net\roseindia\roseindia-webapp
\1.0\roseindia-webapp-1.0.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Fri Jul 13 12:24:34 GMT+05:30 2012
[INFO] Final Memory: 11M/28M
[INFO] ------------------------------------------------------------------------

Step 3 :Run mvn eclipse:eclipse -Dwtpversion=2.0 command to convert Maven based web application to support eclipse :

C:\project_maven\roseindia-webapp>mvn eclipse:eclipse -Dwtpversion=2.0

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building roseindia-webapp Maven Webapp
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: C:\
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
[INFO] The Maven Eclipse plugin runs in 'pde'-mode.
[WARNING] The references manifest file doesnt exist, plugin dependencies will no
t be updated: {0}
[INFO] File C:\project_maven\roseindia-webapp\.project already exists.
Additional settings will be preserved, run mvn eclipse:clean if you want
old settings to be removed.
[INFO] Wrote Eclipse project for "roseindia-webapp" to C:\project_maven\roseindi
a-webapp.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Jul 13 13:36:54 GMT+05:30 2012
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------
'cmd' is not recognized as an internal or external command,
operable program or batch file.
C:\project_maven\roseindia-webapp>mvn eclipse:eclipse -Dwtpversion=2.0
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building roseindia-webapp Maven Webapp
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
[INFO] No goals needed for project - skipping
[INFO] [eclipse:eclipse {execution: default-cli}]
[INFO] Adding support for WTP version 2.0.
[INFO] Using Eclipse Workspace: C:\
[INFO] Adding default classpath container: org.eclipse.jdt.launching.JRE_CONTAIN
ER
[INFO] Wrote settings to C:\project_maven\roseindia-webapp\.settings\org.eclipse
.jdt.core.prefs
[INFO] The Maven Eclipse plugin runs in 'pde'-mode.
[WARNING] The references manifest file doesnt exist, plugin dependencies will no
t be updated: {0}
[INFO] Wrote Eclipse project for "roseindia-webapp" to C:\project_maven\roseindi
a-webapp.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Jul 13 13:37:30 GMT+05:30 2012
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------

You can see the newly created folder .settings, and two files .classpath and .project inside your project folder as given below :

Step 4: Import Maven project into Eclipse project as follows :

Go to File menu >Import option >Existing Projects into Workspace>click next

Browse the Maven project and click Finish as given below :

Now, you can see your application(roseindia-webapp) in Eclipse :