0

So I have a large Java project, which I'll call ProjectA. I have another project, ProjectB, which is a Maven project, and includes ProjectA as a dependency (by compiling ProjectA to a jar file). I also have many other Maven projects: ProjectC1, ProjectC2, etc. Each of these include ProjectB as a Maven dependency.

ProjectB contains code meant to be common/accessible to all of the ProjectC projects, as well as act as an interface to access some functionality from ProjectA. The problem is: in order to do this, I either have to write a method/class in ProjectB that explicitly calls/extends the method/class from ProjectA that I want to call, or I have to explicitly include ProjectA itself as a dependency in the ProjectCx project (which is undesirable due to the size of ProjectA).

Is there a way to access the members of ProjectA indirectly from ProjectC via ProjectB somehow?

Sizik
  • 1,066
  • 5
  • 11
  • Are they all maven projects? Have you [read](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependencies) about the `transitive dependencies` and `dependency scopes`? Still think they don't fit your needs? – mystarrocks Nov 19 '14 at 00:44
  • B and C are Maven projects, but A isn't. – Sizik Nov 19 '14 at 15:59

2 Answers2

0

if you defined B as a dependency in the pom.xml of project C. and A is a dependency in B. than in C you have access to A. thats what you call transitive dependencies in maven. meaning C automatically, even without writing project A in the c pom.xml, you get project A in your classpath. thats how maven works by default.

sagie
  • 1,744
  • 14
  • 15
0

Ok, I found the answer here: Maven and eclipse: a reliable way to add non-Maven or external jars to a project?

I added the Project A jar as a system dependency to Project B, and it picked up the transitive dependency in Project C.

Community
  • 1
  • 1
Sizik
  • 1,066
  • 5
  • 11