Publish library which shadow only some dependencies

Hi, I have a project which have dependencies looks like

--X
   |--Y
   |--Z
   |--Lib1
   |--Lib2

When I want to publish X as a library, I want to include Y and Z inside X, but still keep Lib1/Lib2 as external dependency. What is the best way to do so?
Note that Y, Z is local project, while Lib1/Lib2 is external dependencies.
The reason I want to do so is that Y and Z are kind of “common” utilities, and there’re a lot of them, publish all of them is not a nice idea.

I’ve tried to use shadow plugin which is fine to build a fat jar, but when I try to upload using shadowUpload, it removes all dependencies of pom file, so that user can’t resolve Lib1/Lib2 when they add X to pom file.
There’re some other options like manually including artifacts and manually modify pom file, but it will take huge effort to maintain, and is not easy for gradle newbie like me.

So what is the best way to publish X in my case?