Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automating the Import of Existing Maven Project Into Eclipse

Tags:

eclipse

maven

I am creating an installer for a project and would like to import an existing maven project into my eclipse workspace after checking the project out.

I will appreciate any help I can get as soon as possible.

Thanks Guys!

like image 525
Akanmu Sola Avatar asked Jan 23 '26 02:01

Akanmu Sola


1 Answers

I automated setting up eclipse, including importing existing maven projects.

First run mvn eclipse:eclipse on the project

   mvn eclipse:eclipse:

Next grab an eclipse plugin that will perform the headless import of projects into the workspace:

   wget https://github.com/snowch/test.myapp/raw/master/test.myapp_1.0.0.jar

Copy the above jar to your /eclipse/dropins/ folder.

Next find all the directories that can be imported into eclipse and append them with '-import'

IMPORTS=$(find . -type f -name .project)

# Although it is possible to import multiple directories with one 
# invocation of the test.myapp.App, this fails if one of the imports
# was not successful.  Using a for loop is slower, but more robust
for item in ${IMPORTS[*]}; 
do 
   IMPORT="$(dirname $item)/"
   echo "Importing ${IMPORT}"

   # perform the import using the test.myapp_1.0.0.jar
   eclipse -nosplash \
      -application test.myapp.App \
      -data $WORKSPACE \
      -import $IMPORT
done

Finally, add the M2_REPO variable to the workspace

mvn eclipse:configure-workspace
like image 126
Chris Snow Avatar answered Jan 25 '26 23:01

Chris Snow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!