Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

implementation passthrough from library in kotlin dsl

I can’t figure out how to let my library pass another library to a main app. I know that sounds a little weird, so I’ll try to explain the best I can. For a simple example, I have an annotation processor that I built that makes code generation much easier. I also have a library to hold UI elements and common functionality. In order to kind of package them together I went into my library gradle dsl file and added an implementation on the annotation processor…

library gradle file…

//... gradle file
dependencies {
  //... dependencies
  implementation(libs.annotations)
  kapt(libs.annotations)
  //... dependencies
}
//.. rest of gradle file

Then in my sample app that I am using to test all of this I am adding a dependency on the library

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

dependencies {
  implementation(libs.library)
}

However in my code when I try to annotate a class with my annotation I am getting an error
unresolved reference 'annotations'

Is there a way to allow my library to also provide my annotations?

If it matters I compile the library to an aar and then upload it to a private artifactory repo, which is then added to my sample app.

>Solution :

Replace:

implementation(libs.annotations)

with:

api(libs.annotations)

api() says "expose this library’s public API as part of my library’s public API". implementation() says "use this library, but do not make it available my library’s consumers".

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading