Dimitar G.
12/24/2024, 2:46 PMlibrary-base
• library-data which "tries to" embed library-base via api(projects.libraryBase)
• librart-multi which adds library-data via api(projects.libraryData)
My problem is library-multi does not add library-data .
And library-data does not have library-base .
Calling
./gradlew :library-multi:publishAndroidReleasePublicationToMavenLocal
creates the needed AAR files, but I don't have these dependencies embed.
Here is a simple repo which provides the problem - https://github.com/dimitar71/multi-kmp.
Added a brief explanation of the issue.
You can run refapp, since it is an Android app module.
The issue which I am struggling is, that api(projects.libraryData) is not adding the source code when creating the AAR builds.
Can someone provide details what I am doing wrong?
Reading the docs around, using ChatGPT, Copilot, everything points that I am doing things right.
However, no luck.CLOVIS
12/24/2024, 4:17 PM./gradlew library multipublishAndroidReleasePublicationToMavenLocalThis only publishes
library-multi . If you want to use the other libraries, you have to publish them too!CLOVIS
12/24/2024, 4:18 PM./gradlew publishAndroidReleasePublicationToMavenLocal
then everything should workDimitar G.
12/24/2024, 4:28 PMapi() (not implementation()).
So technically, library-data source code should be part of library-multi AAR.
But it is not, exactly the same error even when calling
./gradlew publishAndroidReleasePublicationToMavenLocalCLOVIS
12/24/2024, 4:29 PMSo technically,No, that's not whatsource code should be part oflibrary-dataAAR.library-multi
api() does. api() is the same as implementation() except it makes symbols available at compile-time. It doesn't touch the contents of the archive in any way.CLOVIS
12/24/2024, 4:30 PMBut it is not, exactly the same error even when calling
Are you sure? I've run your first command and the libraries were not in./gradlew publishAndroidReleasePublicationToMavenLocal
~/.m2 , then after executing that one they were in ~/.m2 .CLOVIS
12/24/2024, 4:30 PMDimitar G.
12/24/2024, 4:30 PMDimitar G.
12/24/2024, 4:33 PMDimitar G.
12/24/2024, 4:33 PMCLOVIS
12/24/2024, 4:35 PMJavier
12/24/2024, 4:35 PM./gradlew publishToMavenLocal, is the issue fixed?CLOVIS
12/24/2024, 4:36 PMlibrary-data-android , but what your build wants is library-data … Did you rename the artifacts somewhere?Dimitar G.
12/24/2024, 4:37 PM-android
The MAJOR problem I am having 🙂Javier
12/24/2024, 4:37 PM-android suffixCLOVIS
12/24/2024, 4:37 PMJavier
12/24/2024, 4:38 PMJavier
12/24/2024, 4:38 PM./gradlew publishToMavenLocalCLOVIS
12/24/2024, 4:38 PM./gradlew publishToMavenLocal
• ./gradlew :refapp:checkDebugAarMetadata
it should workDimitar G.
12/24/2024, 4:39 PMCLOVIS
12/24/2024, 4:40 PM:library-multi:publishAndroidReleasePublicationToMavenLocal
but that:
• only publishes :library-multi
• only publishes the AndroidReleasePublication
So you're not publishing :library-base nor :library-multi , and you're not publishing :library-multi 's common , only its androidDimitar G.
12/24/2024, 4:41 PMapi() ?
Or should api() still be needed?Javier
12/24/2024, 4:41 PMJavier
12/24/2024, 4:41 PMCLOVIS
12/24/2024, 4:43 PMapi() and implementation() are different
If you're writing a module X, and you depend on a module Y
If X has a type from Y in any of its public declarations, you should use api() ("it's part of my API!")
If X only uses Y inside code but it never appears in public signatures, you should use implementation() ("it's part of my implementation!")Javier
12/24/2024, 4:43 PMDimitar G.
12/24/2024, 4:43 PMcore lib module.
A bit messy, but seems the only approach of what we are trying to achieveCLOVIS
12/24/2024, 4:43 PMapi() and implementation() are transitive. compileOnly and runtimeOnly are not transitive.Javier
12/24/2024, 4:44 PMJavier
12/24/2024, 4:44 PMDimitar G.
12/24/2024, 4:45 PMapi() embeds code.
TIL is every day.
This library is a bit of everything - for some cases all 5, for others just core , hard to explain.
Is there a gradle ability to include (not just use, but include) a dependency into our own dependency?CLOVIS
12/24/2024, 4:46 PMJavier
12/24/2024, 4:46 PMJavier
12/24/2024, 4:46 PM> Dependencies appearing in the api configurations will be transitively exposed to consumers of the library, and as such will appear on the compile classpath of consumers. Dependencies found in the implementation configuration will, on the other hand, not be exposed to consumers, and therefore not leak into the consumers' compile classpath. This comes with several benefits:
Javier
12/24/2024, 4:48 PMCLOVIS
12/24/2024, 4:48 PMapi() :
• transitively available to consumers (runtimeClasspath)
• transitively exposed to consumers (compileClasspath)
implementation() :
• transitively available to consumers (runtimeClasspath)
• not exposed to consumers (compileClasspath)
sadly this is always explained in ambiguous ways so many people are confused 😕Javier
12/24/2024, 4:50 PMCLOVIS
12/24/2024, 4:51 PMJavier
12/24/2024, 4:53 PMDimitar G.
12/24/2024, 4:53 PMCLOVIS
12/24/2024, 4:55 PM