How can I work in a virtual machine using Eclipse?

I have a project that I built on my virtual machine using sbt. During the build process, it installs several libraries in the ~ / root / directory on my virtual machine. For example, part of the .classpath file looks like this:

<classpathentry kind="lib" path="/root/.ivy2/cache/org.apache.avro/avro/jars/avro-1.7.6.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.codehaus.jackson/jackson-core-asl/jars/jackson-core-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="/root/.ivy2/cache/org.apache.commons/commons-compress/jars/commons-compress-1.4.1.jar"/>

I run Eclipse on my Mac OS on the host machine, and when I import the Eclipse project (via mount samba), I get a bunch of import errors because the class paths are only valid on my guest machine.

What is the typical / standard way to develop Java / Scala projects in a virtual environment when running an Eclipse application from your host machine?

Am I better off doing all the development on my host machine?

+4
source share
1 answer

This is not a typical or standard solution to the above problem. However, he solved my specific problem when using the sbt-eclipse plugin to create project files.

It turns out that you can pass the relative path to the sbt-eclipse plugin and which will be distributed to the .classpath file.

./sbt eclipse -ivy ./ivy

That way, when you import a project into Eclipse, it will use all relative paths based on the root path of the project. It seems to work so far.

<classpathentry kind="lib" path="./ivy/cache/org.apache.avro/avro-compiler/bundles/avro-compiler-1.7.6.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.apache.avro/avro/bundles/avro-1.7.6.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.codehaus.jackson/jackson-core-asl/jars/jackson-core-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.9.13.jar"/>
<classpathentry kind="lib" path="./ivy/cache/org.apache.commons/commons-compress/jars/commons-compress-1.4.1.jar"/>

Note that although this fixes import errors, the application is still running on the host machine instead of the virtual machine.

0
source

Source: https://habr.com/ru/post/1569855/


All Articles