This message was deleted.
# community-support
s
This message was deleted.
j
Same as a normal dependency, but you need to consume it with
platform
It should be great there is a
[bom]
table so you can consume them without the
platform
function
j
hmm, how would you specify the platform in the version catalog, though?
Like, imagine that I’m trying to propagate kotest or spring’s boms as part of our “master bom” - I can specify the dependencies manually, of course, and replicate the effect. But I’d prefer to just include references.
e
as Javi said.
same as a normal dependency
Copy code
[libs]
spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot-dependencies" }
but you need to consume it with
platform
Copy code
dependencies {
    api(platform(libs.spring.boot.dependencies))
}
(I don't use Spring so I don't know if this is actually the right dep)
j
hmm, how would I specify that in the version catalog? Would I have to go straight to toml? (I’m doing it with io.kotestkotest bom5.3.1 for now as a test)
e
I don't understand your issue. do the same thing to move your BOM dependency into your version catalog as you would any other dependency, regardless of whether the version catalog is defined via TOML or programmatically. the only difference between it and a normal dependency is at the consumer, which should be exactly the same difference as you have now.
j
If I have:
Copy code
library("testbom", "io.kotest:kotest-bom:5.3.1")
in the
catalog { versionCatalog { … } }
block, and I publish it, the downstream consumer can have:
Copy code
dependencies {
    testImplementation(platform(libs.testbom))
… but the dependencies don’t show up in the project. There is no
.dependencies
completion (
libs.testbom.dependencies
doesn’t work, nor does it work on
platform()
).
testbom
does complete, the
toml
has the library; if I set up a bundle that includes that library, it resolves, too, but the build fails because it can’t convert
platform(libs.bundles.testbundle)
to an object of type
Dependency
, nor do I see a completion that leads there from the bundle or from the call to
platform()
.
It could be that I’m misusing
catalog
- I do not know. I’m trying to figure this out, and for whatever reason the docs are not enough; I have a feeling that once I know how it works, the docs will be so obvious and only a moron wouldn’t understand, but that’s… pretty common for a lot of documentation, as it turns out.
But I feel like this should be a common enough use case that it should be clear, or made more clear. I don’t think I’m an idiot, although the possibility remains.
I don’t think what I’m wanting is a platform - the catalog seems pretty appropriate, especially with
bundle
being part of the mix, but I don’t know how to make a bundle from another platform.
e
I'm not quite sure what you're trying to accomplish but... you can't "unbundle" a BOM/platform
j
if you add a
bom
to a configuration, any dependency in that configuration added by you, even with a different version, would be overridden with the version from the
bom
so you have to add the bom to the catalog, and all dependencies you need too, as you are going to get the version from the catalog automatically, you don't need to add the version to each one, so you can
Copy code
[libraries]
foo-bom = { module = "org.example:foo:bom", version = "1.0.0" }
foo-dep = { module = "org.example:foo:dep" }
Copy code
dependencies {
    implementation(platform(libs.foo.bom)
    implementation(libs.foo.dep)
}
j
@Javi is that not doable from the DSL?
j
it is the same with the Kotlin DSL
j
Okay. That’s what I think I’m missing, because I don’t see how.
j
move those two lines from toml to the dsl, that’s it
you need to manually add to the toml or the dsl all kotest dependencies you are going to use plus the bom one
j
.. but if I’m doing that (that’s what I was doing in the first place) what’s the point of using the bom? Wouldn’t I be just as well off using a bundle?
j
bom ensure the dependencies are using specific versions for each dependency that are compatible among them
j
right, so… why shouldn’t there be a mechanism by which I say “Hey, there’s a bom for kotest, as an example: I would like to include the dependency X from that bom, thanks” without doing the manual inclusion?
j
I don’t know, you can create an issue for that
j
Worth noting: this does work: I include the bom, I included a module FROM the bom with
.withoutVersion()
, include the bom with platform, and include the library by name, and I get the dependency. But that means I am redeclaring the dependencies from the bom, just without version. If the bom version changes, I get to go through and add whatever the new version of the bom includes
j
you only need to change the bom version
the rest of dependencies doesn’t need to have any version
j
so I could theoretically include the bom, include the libs, create a bundle MATCHING the bom’s dependency list (from “the libs”) and it gets the versions from the bom
it’s those two intermediate steps that seem excessive
j
you don’t need to apply a lib with any version, all without versions except the bom
j
@Javi Yeah, I know
e
a BOM was not intended to represent a bundle of libraries to import all at once
j
But I still get to recreate the structure of the external bom
@ephemient I know. But they’re not even available for import.
e
correct. that's not available regardless of whether you are using version catalogs or not.
👆 1
j
if a bom
external-bom:1.0
has libs
a:1.0
,
b:1.0
,
c:1.0
,
d:1.0
I get to declare all of a,b,c,d manually (and get the versions from the bom); if external-bom:1.1 comes out and adds
e
, I get to manually redeclare e except without the version
j
there is no codegen of accessors for bom internal dependencies, indeed, when you are applying it it is too late to codegen the accessors
e
only if you need to use
e
j
I can work with this
@ephemient sure. It’s just more housekeeping.
e
it is not the expected use case for a BOM that you import every library it mentions
j
I think he want something like,
libs.kotest.bom.declaredDependencies.assertions
j
sure, or
dependencies
like was referred to earlier, but eh
e
honestly, it might be possible to do a Gradle transform from a subset of POM syntax to a version catalog, although you'd have to register it very early (in
settings
)
j
but that would mean for gradle to detect all bom and codegen those properties even in modules in which the bom is not applied
e
but it doesn't feel like something common enough to be worthwhile
j
My main thing is needing to know what I need to do, which is not obvious to me from docs
I’m feeling my way through the docs more than anything else
Now that I have a better idea of what I have to do, the docs make more sense… but the docs might be helped by cutting down that curve somewhat
e
I think the docs don't necessarily do a good job of delimiting what is part of Gradle's expectations of the Java ecosystem's conventions, what is Gradle's own conventions, and what is non-conventional but possible
but the docs + examples do cover version catalogs and platforms fairly comprehensively, IIRC
it's just in multiple different places
j
Sure. Like I said, now that I understand better, the docs make more sense. The details are there, just not in a form that communicated effectively with me, and this is the first forum where anyone else has been able to provide any insight.
Which - as a writer - makes me think the docs are technically correct - the best kind of correct - but not useful.
(I used to run theserverside.com - I’ve spent a LOT of time looking at how to get people up to speed.)
e
hmm. my personal complaint about the docs is that I often find that Google is more useful as an index than the docs' own table of contents, since the locations of some information is not where you'd expect due to history or other factors
j
Sure. It’s always a work in progress.
I’m going to write up what I’m doing for others to learn from.
Because I’ve spent way too long trying to figure out what the options are and what I actually should have done to achieve what I’m doing, and it should have been a “oh, you’re doing X, here’s a full example that works” instead of “hey, you need to combine these seven snippets in this manner, good luck out there figuring out WHICH seven snippets”
this conversation has been AMAZINGLY helpful
e
in this specific case, there are real full examples of where we ended up in many other projects, but perhaps not in Gradle itself. which is still a failing of the docs, but one I hadn't noticed before
j
AFAIK there is an example of when you need to use a Catalog or when to use a BOM, but I think more than a doubt among them, it is more a question about an expectation to improve the tool itself by providing those accessors
so I think docs can't explain everything, even more every user use case, potentially... infinite use cases
e
I don't think it's generally appropriate to generate accessors for all libraries in a BOM
j
I don’t think it’s necessary but it’d be useful. My biggest problem is that when I was trying to figure out what the path forward was to be, the docs were giving me the IKEA treatment: “here are the things you can use.” What I needed was “here’s how you put them together cohesively” instead of seeing the parts in specific.
And the docs can and should cover the 90% common case. Include the outlier, sure, absolutely… but serve the massive middle.
Because I was asking a lot of people who use gradle about this and mostly what I got was “shrug I dunno, I use what people who know put together” and THAT suggests a knowledge vacuum
not a gradle expert, but a knowledge expert here: this is solvable and relatively easily so
e
to clarify, I do agree this is a fairly common case - this combination of importing versions from a BOM and also providing version-less libs in the catalog - and I'm sure I've seen it in dozens of public projects on GitHub
j
I’m going to write something up, like I said, because it’s not good that I didn’t find it trivially; I’m sure it’s out there, but if you can’t find it, that means that there’s a gap somewhere. I’m unlikely to actually contribute new knowledge, but maybe I’ll help fill an SEO gap.
e
that's not necessarily something that Google can guide you to so it not being in the docs is a gap
j
@ephemient… but it IS. That’s the SEO gap. I’m sure you’re right, I’m sure projects DO fulfill this, but I was searching and not finding.
I think it SHOULD be in the docs, too, but that’s not something I can directly fix right now.
and I’m sure that whatever I write up will not cover that last 10/15% even covered by the subject I will cover, but it will get that massive middle, and the outliers are better addressed by people who know better than I.
e
I think we're mostly in agreement here?
j
Probably.
e
if you write and publish a blog, yes that helps close the Google SEO gap. several members of this community have actively done that in the past
j
Hell, I’ll put it on TheServerSide 🙂
e
beyond that, the best way to improve the docs is to contribute to them, and probably second best is to file issues in the issue tracker
j
most of what I put there is about the industry and not actually programming, this will be a change-up 🙂
I figure I’ll write the post and THEN go to the issues
I’m not willing to pretend I’m a gradle expert in any fashion