0

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.

gye
  • 1,374
  • 3
  • 16
  • 27
  • It sounds like this parts should be refactored out into a separate project or your correct project belongs into the larger project .... – khmarbaise May 14 '18 at 13:29
  • @khmarbaise For you option 1, do you mean pull out the common piece between two projects into its own project? If so, due to some other business requirements, I am afraid this is not an option for me now. But I agree this is a good way to do it. Right now I am interested in your option 2. – gye May 14 '18 at 13:39
  • Move Project B into the Project A cause it looks like it's using it's dependencies or better it's code? – khmarbaise May 14 '18 at 13:46

2 Answers2

1

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>
Daniele
  • 2,672
  • 1
  • 14
  • 20
  • thank you for the quick response. I have updated the question description. Do you still think your suggestion fit? Sorry for the missing info. – gye May 14 '18 at 14:35
  • hi, now what you need is clearer.. (though I would strongly suggest you fix your build anyway). you can import a jar from a specific location – Daniele May 14 '18 at 14:58
1

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.

Sangeeth
  • 71
  • 4
  • That's a very cool/new idea to me. I will definitely give it a try at another time. Unfortunately, it's a bit out of scope at the moment. – gye May 14 '18 at 14:36