I have a library project that consists of two different APIs (a
and b
) which should operate on the same core
and base
code. core
is hidden from the user of a
or b
so there is an implementation
dependency to core
. But base
is exposed to the user of a
or b
so there is an api
dependency to base
.
This is all fine as long as you stay in the Gradle world. But it becomes more complicated when you're publishing a
and b
with the maven-publish
Gradle plugin. It creates an artifact of each of the modules separately and (correctly) outlines dependencies between them. But I don't want to expose core
and base
separately. Instead, I'd like to bundle them into one artifact for a
and b
each, where types in core
stay internal and those in base
are exposed.
Is there a way to do this with maven-publish
?
You'll want to create a fat/uber JAR. There are plenty of tutorials out there, but a common approach is to use the Shadow plugin: https://imperceptiblethoughts.com/shadow/
You would configure the Shadow plugin to have core
and base
to be embedded/included in a
and b
without having to publish them.