chrismarx
chrismarx

Reputation: 12555

m2eclipse and WTP and adding local project source

I have a spring mvc project in eclipse, and its setup to use maven. I can resolve all my external dependencies, but now I want to include another local project in my workspace. Normally, I would do this through the java build path, and add a project reference. But if I do that manually, m2eclipse just removes those references from my classpath file.

I'm assuming this is because maven wants to handle all dependencies. So I enable dependency management on the local project (the source files i want to include), and now when I add dependencies, this project shows up, and it adds it as a jar type (which is correct). I also ran maven-package to create a snapshot of the source project. But the jar is never added in the maven library list, and the project doesn't build because it can't find the classes.

What am I doing wrong? Thanks for the help!

Upvotes: 3

Views: 1703

Answers (3)

chrismarx
chrismarx

Reputation: 12555

can't comment anymore, but after doing some more reading, it seems that the "Resolve Workspace Dependencies" only works if those projects are also managed by Maven. What if you want to add a local project that's not in maven?

Upvotes: 1

Pascal Thivent
Pascal Thivent

Reputation: 570375

The configuration of Maven projects in Eclipse is derived by M2Eclipse from the metadata contained in the POMs so if you have two projects, ProjectA and ProjectB, and you want to have ProjectB as dependency of ProjectA, you need to declare ProjectB as such in the POM of ProjectA i.e. to add a dependency:

<dependency>
  <groupId>group.id.of.b</groupId>
  <artifactId>project-b</artifactId>
  <version>1.2.3-SNAPSHOT</version>
</dependency>

And if you want to depend on the project in the workspace (and not on the artifact through the local repository), right-click on ProjectA then go to Properties > Maven and make sure you selected Resolve Dependencies from Workspace projects as illustrated below:

alt text http://img530.imageshack.us/img530/98/screenshot001do.png

Upvotes: 2

jayshao
jayshao

Reputation: 2167

You probably need to add the local project (with it's pom.xml artifactId) as a dependency in the pom.xml of the WTP project, and turn on Workspace Dependency resolution?

Upvotes: 0

Related Questions