Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven/Eclipse with Vagrant

I'm trying to convert a Java project which builds in Maven (and Gradle and Ant... it's complicated unfortunately) to use Vagrant. I already have most of the machine provisioned with Puppet, and it's awesome having a portable, destructible development environment and not having to install and configure all of this software on my own personal machines.

The problem I'm currently facing is this: how will I resolve my classpath in Eclipse? My build tools (Maven, Gradle, Ant) are installed on the Vagrant box, and they download archives to the local machine in /home/vagrant/.m2 etc.

Here's what I can do fairly easily over the Vagrant machine:

  1. Build my entire software project using the Ant, Maven, and Gradle build tools installed on the Vagrant machine.
  2. Run my entire software project on my application servers installed on the Vagrant machine.
  3. Access and interact with the application servers over a forwarded HTTP port.

Here's what I'm sorely missing:

  1. Develop using Eclipse and using the Maven/Gradle classpath which exists inside of the Vagrant VM.
  2. Debug/Run using Eclipse, starting the applications inside of the Vagrant container to make use of that environment and not my host machine's environment.

Are there Eclipse plugins which will allow me to use a remote classpath with m2eclipse? Can I run/debug Java executables remotely on the Vagrant machine?

If "the bottom line™" is that I simply must have Maven and Gradle installed on my local machine in addition to the Vagrant box, then it is what it is; otherwise, I'd really prefer to keep my local machine as lightweight as possible.

The Goal

Run my entire software development cycle inside of a Vagrant machine, making Eclipse the only dependency on my local machine.

like image 470
Naftuli Kay Avatar asked Jul 11 '14 20:07

Naftuli Kay


1 Answers

In your Vagrantfile you can declare a shared folder for you host and guest. /home/vagrant/.m2/repository on the guest you could link to an extension folder, for the jvm or Eclipse if it supports a lib/ext.

like image 83
bbaassssiiee Avatar answered Nov 18 '22 21:11

bbaassssiiee