简体   繁体   中英

dependencies for a library jar using gradle

I am using gradle 6.7 and creating a library project which is compiled to a jar that is placed in my own s3 artifacts repository.

In my project I have dependencies to other artifacts and I use implementation dependency.

The jar is created (not a fat jar) and uploaded to the s3 repository.

When in another project I am using my library by fetching it as implementation dependency I am getting errors NoClassDef for other dependencies I used in my library, which means that no runtime is found for the dependencies I was using in my library.

My question is, whether it is a good idea to create a fat jar? I don't think that other libraries (eg springboot and others) are using fat jars, right? however when I use them as dependency other dependencies are found on runtime.

Does it mean that using implementation in my project for other dependencies is not the right way? shall I use something else? Could you please contribute a bit more about what is the right way?

Thank you

Check out the Java Library Plugin for gradle. It exists for this exact situation.

If a dependency of your library needs to be exposed to the consumer of your library, then you would use api instead of implementation . There is a nice section within the plugin documentation here that can be used to help you identify when to declare a dependency as api vs implementation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM