Eclipse Maven: How to build the added dependency first from the project itself?

I am using Eclipse with m2e plugin.

The steps I followed are as follows:
1. Created a sample Maven project
2. Imported an another Maven project in same workspace
3. Used imported project as dependency in my sample project

Now the problem is that since the imported project is not built and does not have target jar file, the sample project is showing error(jar not found).

So the question is it possible to run the build from sample project, which will build the dependency first, which in turn will be used in sample project build?

Run sample project build -> Build dependency -> Create dependency jar -> Dependency jar used in sample project build further

If this is possible, then how to do the same?
Thank you for any suggestion/feedback. :-)

1 answer

  • answered 2018-07-12 07:23 JF Meier

    m2e has a feature named Workspace Resolution that can be enabled/disabled for every project (right click on the project in the project explorer, then Maven). This allows you to directly use the classes of another project that you declared as dependency.

    Note that is only works if your dependency (in your POM) and the other project have the same coordinates, including version number.