Best Practice for including external projects?

Greetings!

I’m building a java library for an internal java application in my organization. The application is an ant project and has multiple components (jars), and the lib I’m building depends on one of the components. I’m wondering what is the best practice for me to use gradle to build my lib project?

I found a previous post with similar situation: Adding external projects in the gradle build path - #2 by Peter_Niederwieser that suggests to publish the dependent project to a repository which is probably not an option in my organization.

I was able to compile my lib if I declare the jar files as dependencies locally with something like:

dependencies {
  implementation files('path/to/app/component1.jar')
  implementation files('path/to/app/component2.jar')
}

But the problem is 1) it’s not portable and 2) I cannot do source referencing in IDEs when writing code for my lib. So I’m wondering if there is a better way to do this? I do have access to overhaul the build system of the app to gradle if that’s necessary.

Thanks in advance!

Imho it’s always a good idea to port a build to Gradle. And if you did, you could for example use composite builds. And even if you would not properly migrate the build, Ant is a first-class citizen in Gradle, so you could also have a thin Gradle adapter build that triggers the real Ant build and then configures the built artifacts as results, so that you then can again use a composite build.

Thank you so much! I will explore the ant wrapping approach and gradually migrate to full gradle build.

1 Like