<https://github.com/bjonnh/gradle-kotlin-spring-de...
# spring
I have issues in :scripts when importing something from the namespace present in :services
If I remove the springboot dependencies it find it perfectly
Except that adding the dependencyManagement part doesn't seem to solve anything. Also intelliJ finds the import properly, it is really gradle that complains
ok moving the models to a library that is not in a spring boot application solve the issue
if anybody as an explanation of why, I would be happy to know
s
Since you are using spring boot 2, I would instead recommend using gradle's
platform
configuration, which allows you to import boms like maven.
you didn't commit your gradle directory, so i'm not sure what gradle version you are using.
you can use it in gradle 4.6, but you need a special setting.
b
I'm using 5.2.1
s
then I would suggest using
implementation(platform(..))
b
ok that seem to work
s
👍🏽
b
well it was working before too
but at least it didn't seem to break anything 😛
s
yes, well they work the same way. but now you don't need that
dependencyManagement
plugin or block
😉
b
oh neat
hmm if I remove it it fails to find the packages
should I put something special in the library?
s
what's the error?
b
unable to resolve <name of the spring package>
that's in :scripts that is importing models from :api-library
s
does it include the version? can you provide the project? or build.gradle.kts.
image.png
oh wait
let me update the repo
s
yeah ha.
I was wondering 😂
b
ok
now that's the repo I used and made that error
(you will realize that I have no idea what I'm doing…)
b
oh
s
b
\o/
beautiful
s
b
I like that… the less lines I have in those files the better I feel
s
I don't see where you are using
platform
b
in scripts
s
sorry, it seems you misunderstood.
b
likely
s
platform
is a replacement for
dependencyManagement
. Do you know what a BOM is?
b
nope
so I should remove that dependencyManagement also from api-library?
s
BOM stands for Bill Of Materials. It is essentially a parent pom that declares what versions of libraries should be used. Are you familiar with maven?
b
a tiny bit
enough to break things
should I remove that dependency management completely
s
haha. ok, so if you have a parent pom, you can declare a bunch of dependencies in a
<dependencyManagement>
block in the parent pom. and then anywhere you use that parent pom (other microservices or libraries or whatever), you will be able to declare a dependency without declaring a version.
I will send a pr.
give me a sec.
b
yes that's exactly what I'm trying to do
so I don't have to give the spring versions in each submodule
s
what version of gradle are you using?
oh sorry 5.2.1
b
now that I removed the dependencymanagement everywhere, no submodule finds the versions for spring modules
at least they all agree on that
s
yep, give me just a minute.
b
sure
s
hmm. this is kinda a mess 😅
it's taking much longer than normal for me to fix it.
b
yes that's the feeling I have everytime I touch gradle. And looking at other people repositories, they all have completely different ways of handling things
so it is hard to find a reference implementation for anything
s
do you want me to make the pr the way I would do it?
or follow your style and try and fix it your way?
b
absolutely
I have no style
you can burn anything you want
s
😂
b
I'm really lego-ing things until they work
so, if you look at the root build.gradle.kts file you'll now see the BOM implementation in the
allprojects
block.
this applies the BOM to all projects, allowing the versions to resolve.
I completely removed the spring dependency management plugin.
b
Thanks
never seen that nebula.kotlin
s
it just adds a BOM for kotlin essentially. makes it so you don't have to track versions through the rest of the project.
b
cool
ok I'm done integrating the changes in my real app
lets see if it blows up 😄
s
😂
b
hey
it also removed all the duplicate tasks I had in gradle
🎆 Thanks @snowe
s
awesome! you're welcome! some of those things just come with time. I've only been using gradle for a few months, but it's been getting much easier.
b
yep I'm learning a lot of stuff at the same time, and programming is not my main job so…
s
oh!
wow. well good job then! haha
b

https://www.youtube.com/watch?v=fhwPt_dTObw&amp;feature=youtu.be

that's the kind of stuff I do with kotlin ^
s
oh nice!