Question

I'm working on a project with many modules. I would like to have a single command to build each module and generate Eclipse configuration files, but when I run mvn eclipse:eclipse on the parent pom, Eclipse does not see the dependencies and gives me this error: 'module2' is missing required Java project: 'module1'. When I run the same command in the folder for the module instead of the parent folder it works fine.

The project is set up like this, where module2 depends on module 1.

.
 |-- module1
 |   `-- pom.xml
 |-- module2
 |   `-- pom.xml
 `-- pom.xml

Here's a comparison of the .project and .classpath for when I run mvn eclipse:eclipse in the parent folder vs the module folder:

$ diff module_project parent_project
5c5,10
<   <projects/>
---
>   <projects>
>     <project>module1</project>
>   </projects>

$ diff module_classpath parent_classpath
15c15
<   <classpathentry kind="var" path="M2_REPO/path/to/module1/module1-0.1.jar"/>
---
>   <classpathentry kind="src" path="/module1"/>

How do I get this working without running the command on each folder individually?

By the way, here's the version numbers that I am using. Eclipse and maven were both installed using apt-get on Ubuntu 13.10.

Eclipse:
Version: 3.8.1
Build id: debbuild

Maven:
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-15-generic", arch: "amd64", family: "unix"
Était-ce utile?

La solution

If you run the command eclipse:eclipse from the parent folder, you need to open both of your projects 'module1' & 'module2' in the same workspace in order for it to work.

In the first case :

<classpathentry kind="var" path="M2_REPO/path/to/module1/module1-0.1.jar"/>

if you want to run your project 'module2' from eclipse it will look for its dependency 'module1' in the repository, that's mean any change you made in 'module1' won't be available for project module2 until you install it in the repository.

In the second case :

<classpathentry kind="src" path="/module1"/>

any change you made to project module1 will be immediately available for project module2, because the two projects are linked directly in the same workspace.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top