Let's consider the following projects:
- Project1: uses
Eclipse
P2 Target Definition for dependencies - Project2: uses
Maven
repositories for dependencies
The problem: project1 requires a dependency which is present in project2 which comes from a Maven
repository (and is not available in p2).
My workaround up to now is that I am exporting project2 as a jar with dependencies. Then, I add this jar to project1 and can access the dependency from there.
How could I do this in a better way?
What do you mean with a better way?, What do you think you are doing wrong?
The only way to use libraries or classes from external projects is by importing the package that contains them. In this case, i guess you made this package using (on your second project) mvn install, mvn package or similar, which is perfectly fine...
If you import to your first project the jar that you just created it is ok too!, there is no better way to do this unless you combine both projects and make them a single one.