Home > Blockchain >  Maven how to include a Java project as a dependency
Maven how to include a Java project as a dependency

Time:06-30

I have the following structure

-->Project1 (Java SE Project)
---->src (My Java Code)

-->Project2 (Maven Project)
---->pom.xml
---->src
------->main
------->test

In Eclipse, I can configure the build path of the maven project to include Project1 and it runs fine in the IDE. However, I realized that it seems when I want to run it as a command

mvn test-compile

the Project2 can't find the project. I am thinking I need to somehow reference it in my pom.xml (which then, I can ignore the step in Eclipse to configure it on the build path).

The error is

[ERROR] package foo does not exist

The Project1 is not really being compiled into a .jar so that isn't the solution. I want the actual entire project as a reference somehow.

CodePudding user response:

Instead what I did was just convert the project1 to a maven project and in project2, added the dependency without needing to generate the jar. Seems like maven is smart enough to find the project and not look into the .m2 version (like if I did a mvn install).

  • Related