https://kotlinlang.org logo
#spring
Title
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

snowe

04/26/2019, 7:08 PM
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

bjonnh

04/26/2019, 7:33 PM
I'm using 5.2.1
s

snowe

04/26/2019, 7:33 PM
then I would suggest using
implementation(platform(..))
b

bjonnh

04/26/2019, 7:36 PM
ok that seem to work
s

snowe

04/26/2019, 7:36 PM
👍🏽
b

bjonnh

04/26/2019, 7:36 PM
well it was working before too
but at least it didn't seem to break anything 😛
s

snowe

04/26/2019, 7:37 PM
yes, well they work the same way. but now you don't need that
dependencyManagement
plugin or block
😉
b

bjonnh

04/26/2019, 7:37 PM
oh neat
hmm if I remove it it fails to find the packages
should I put something special in the library?
s

snowe

04/26/2019, 7:40 PM
what's the error?
b

bjonnh

04/26/2019, 7:40 PM
unable to resolve <name of the spring package>
that's in :scripts that is importing models from :api-library
s

snowe

04/26/2019, 7:41 PM
does it include the version? can you provide the project? or build.gradle.kts.
image.png
oh wait
let me update the repo
s

snowe

04/26/2019, 7:43 PM
yeah ha.
I was wondering 😂
b

bjonnh

04/26/2019, 7:43 PM
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

bjonnh

04/26/2019, 7:45 PM
oh
s

snowe

04/26/2019, 7:45 PM
b

bjonnh

04/26/2019, 7:45 PM
\o/
beautiful
s

snowe

04/26/2019, 7:45 PM
b

bjonnh

04/26/2019, 7:45 PM
I like that… the less lines I have in those files the better I feel
s

snowe

04/26/2019, 7:46 PM
I don't see where you are using
platform
b

bjonnh

04/26/2019, 7:46 PM
in scripts
s

snowe

04/26/2019, 7:47 PM
sorry, it seems you misunderstood.
b

bjonnh

04/26/2019, 7:47 PM
likely
s

snowe

04/26/2019, 7:47 PM
platform
is a replacement for
dependencyManagement
. Do you know what a BOM is?
b

bjonnh

04/26/2019, 7:47 PM
nope
so I should remove that dependencyManagement also from api-library?
s

snowe

04/26/2019, 7:48 PM
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

bjonnh

04/26/2019, 7:48 PM
a tiny bit
enough to break things
should I remove that dependency management completely
s

snowe

04/26/2019, 7:49 PM
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

bjonnh

04/26/2019, 7:50 PM
yes that's exactly what I'm trying to do
so I don't have to give the spring versions in each submodule
s

snowe

04/26/2019, 7:50 PM
what version of gradle are you using?
oh sorry 5.2.1
b

bjonnh

04/26/2019, 7:52 PM
now that I removed the dependencymanagement everywhere, no submodule finds the versions for spring modules
at least they all agree on that
s

snowe

04/26/2019, 7:52 PM
yep, give me just a minute.
b

bjonnh

04/26/2019, 7:53 PM
sure
s

snowe

04/26/2019, 8:07 PM
hmm. this is kinda a mess 😅
it's taking much longer than normal for me to fix it.
b

bjonnh

04/26/2019, 8:09 PM
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

snowe

04/26/2019, 8:17 PM
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

bjonnh

04/26/2019, 8:17 PM
absolutely
I have no style
you can burn anything you want
s

snowe

04/26/2019, 8:17 PM
😂
b

bjonnh

04/26/2019, 8:17 PM
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

bjonnh

04/26/2019, 8:32 PM
Thanks
never seen that nebula.kotlin
s

snowe

04/26/2019, 8:33 PM
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

bjonnh

04/26/2019, 8:34 PM
cool
ok I'm done integrating the changes in my real app
lets see if it blows up 😄
s

snowe

04/26/2019, 8:36 PM
😂
b

bjonnh

04/26/2019, 8:43 PM
hey
it also removed all the duplicate tasks I had in gradle
🎆 Thanks @snowe
s

snowe

04/26/2019, 8:52 PM
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

bjonnh

04/26/2019, 8:53 PM
yep I'm learning a lot of stuff at the same time, and programming is not my main job so…
s

snowe

04/26/2019, 8:53 PM
oh!
wow. well good job then! haha
b

bjonnh

04/26/2019, 8:53 PM

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

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

snowe

04/26/2019, 8:55 PM
oh nice!
5 Views