gye
gye

Reputation: 1434

Let Maven Directly Reference Compiled Java Classes from Another Project Under Development

I have two separate projects. One (Project B) needs to depend on the other (Project A).

Project A
    |
     - module A1
     - module A2
     - module A3
     - module A4

Project B
    |
     - module B1
     - module B2
     - module A1  <---- from Project A
     - module A2  <---- from Project A

Right now every time I make a change to Project A, I need to

  1. create jars and push them to local maven repo. (Since Project A is a huge project, this takes a while)
  2. let Project B update the dependencies to Project A

This is tedious in a development mode.

I am wondering if there a way to let Maven in Project B directly references the compiled Java classes, so that I can at lease skip Step 1 in a development mode?

PS: I have looked at the answer from here, but that isn't what I want.

EDIT: Project A is a super legacy project, which doesn't have Maven set up properly and still rely on Eclipse to manage all the dependencies, while Project B has Maven set up properly and can build/compile/package completely without any IDE's help.

Due to some business requirements, we don't want to reconfigure Maven for Project A at the moment. Therefore, having a new parent project for both Project A and Project B in order for maven to manage dependencies is a bit difficult.

Thoughts?

Thank you in advance.

Upvotes: 0

Views: 409

Answers (2)

Daniele
Daniele

Reputation: 2837

You may create a parent Maven project (of type pom) and then make both your projects A and B modules of this project. You can have one module to declare the other as a dependency, and when building the parent project, both modules are built in the correct order.

Doing this is is quite straightforward by using Eclipse.

Also, if you import both projects in Eclipse, the class files being used are those the IDE just compiled (thereby bypassing your local maven repo)

Otherwise, you can use this (deprecated!) setting to import a jar from a specific location.

<dependency>
 <groupId>my1</groupId>
 <artifactId>my1</artifactId>
 <version>1.0</version>
 <scope>system</scope>
 <systemPath>C:/Users/myuser/.m2/repository/xx/asd/bnd/bndlib/2.1.0/bndlib-2.1.0.jar</systemPath>
</dependency>

Upvotes: 1

Sangeeth
Sangeeth

Reputation: 71

You can try Dynamic Code Evolution (DCEVM) with hot swap agent. It has some cool features. It can generate class files and will affect instantly.

Upvotes: 1

Related Questions