Reputation: 981
I have 2 Java projects where project2 depends on project1's jar. Bot are Maven projects. At the moment this is what I do to create a jar from project2:
c:\eclipse\workspace\project1> mvn install
c:\eclipse\workspace\project2> mvn package
Could I somehow "include" the mvn install command inside projects2's pom.xml so that only the last command would be enough to create the jar?
Upvotes: 0
Views: 34
Reputation: 1635
You have described a basic use case of Maven Reactor (i.e. Maven's fancy name for multi-project/module build). In this respect, you'd have your two projects alongside a parent pom (which would be the predecessor of both project1 and project2). Within a Maven multi-module build, modules are allowed to depend one on another; so in your case you'd specify project1 as a dependency of project2's just like you do with any other dependency. Then, when you run package (on the parent pom) Maven will see the dependency, build project1 first and then use the built jar for project2.
Upvotes: 1