I have an Android library that depends on a BOM. W...
# dependency-management
p
I have an Android library that depends on a BOM. When I publish the library, I generate a pom.xml which contains the BOM dependency itself and the different dependencies from that BOM. The dependencies don't specify versions as I haven't figured out a way to extract the versions from the BOM. When I import the library in another project, Gradle complains it cannot find dependency with empty version. But I thought gradle will be smart enough to notice these empty versions belong to a BOM so it should resolve them from the BOM
This is the generated pom.xml file:
v
But I thought gradle will be smart enough to notice these empty versions belong to a BOM so it should resolve them from the BOM
Neither Gradle nor Maven nor any other software supporting POMs would do that, in that POM is not a BOM referenced, but a dependency that happens to be named
sdk-bom
, that is a very big difference.
The dependencies don't specify versions as I haven't figured out a way to extract the versions from the BOM.
https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:resolved_dependencies
p
Thanks for the response. I tried the code in the documentation and other code snippets from the internet with zero success. I can post the code I tried tomorrow but no matter what I put inside the
versionMapping{...}
DSL, the versions keep resolving to null. I also tried adding
Copy code
<type>pom</type> 
<scope>import</scope>
To the BOM dependency in the generated POM.xml file but the project importing the library keeps complaining about the empty versions
v
You manually create that pom, don't you? Because if Gradle created it, the version tags were either there or absent. Maybe it would work if they are not there. 🤷‍♂️ But really, don't mantle with it manually, otherwise that DSL off course has no effect.
p
Oh sorry if I didn't mention that. Yes it is manually built. Is there any API to get that information about the solved versions when building the pom.xml manually?
v
Why should you want to do that?
p
The main reason was(besides being an old project before it probably was supported) the internal
project(":module")
modules dependencies, they came out to the pom.xml file with a different artifact name than the one I wanted. It matches the module name and I wanted a different one. I need to append the flavor at the end of the artifact name. I will try again without the custom pom.xml generation and see what I can get
v
Dunno about Android, Android is always a bit special. But usually it is best to configure Gradle so that it produces the expected / intended POM, also for other situations. But just in case this is not working with Android for some reason, and all you need to change is that name, still let Gradle do it's with age then use the evil
withXml { ... }
to just fix up what needs to be changed.
👍 1
😄 1