Best method for building API/impl JARs with separate projects?

(andrew.oberstar) #1

I’m trying to build two separate JARs, one being an API (or interface), the other being an implementation. These are currently structured into separate Eclipse projects. I did see a similar question on the forum, but the solution talked about there doesn’t work for separate projects. The structure I have now is a root project that will just collect the artifacts, and two subprojects (one for api, one for impl). Note that I’m not deploying using Maven, I’ll just be staging artifacts in directories per configuration.

My root project is currently using the following code to collect the artifacts for each configuration:

subprojects.each { sub ->
 sub.afterEvaluate { subproject ->
  project.configurations.each {
   it.extendsFrom subproject.configurations[]

This does work, but I ran into an issue when there was a syntax issue with one of the subprojects. However this didn’t bubble up when I ran the build, it merely failed saying that configurationX couldn’t be found in the subproject. Adding some println’s showed that the list of configurations for that project was completely empty. Running the subproject on its own fails with the syntax error that is really causing the issue.

I assume this is a misunderstanding on my part of the project lifecycle, so I’m wondering if there is a better way to code this, or if there’s a way to make the real issue bubble up. Hopefully that made sense.

(Peter Niederwieser) #2

What’s your general goal? Atomic staging? Otherwise the subprojects could just do the staging on their own.

Regarding the syntax issue, I need more information to properly answer that question. A reproducible example would be best.