https://kotlinlang.org logo
Title
a

almibe

11/20/2020, 3:26 AM
I've been out of the kotlin/gradle loop for a minute but when did
gradle init
start creating a
lib
subdirectory to put
src
in when you create a library instead of just putting
src
in the current project directory? Did they just start doing that in 6.7? That seems really obnoxious to me. Is there a reason for this?
n

no

11/20/2020, 8:40 AM
What is obnoxious about it?
b

Big Chungus

11/20/2020, 9:27 AM
I was doing this way before gradle introduced it. Yoy have root project and then lib and sample modules
Sample depends on lib and sample is a consumer for testing and playing around
☝️ 2
v

Vampire

11/20/2020, 10:12 AM
Yes, they started in 6.7 to do this: https://docs.gradle.org/6.7/release-notes.html#bootstrapping-new-projects-with-gradle-init
In this release, the projects generated by 
gradle init
 have been updated to use the latest recommended build authoring practices.
a

almibe

11/20/2020, 3:32 PM
I don't like it because it just adds yet another layer of nesting, but that justification makes sense for some projects. At least gradle is flexible enough I can keep doing it the old way.
v

Vampire

11/20/2020, 3:35 PM
Yep, it's just demonstrating suggested good practice, but you are of course free to do otherwise 🙂
I'm also not sure I like it, but I might just miss the reason why it is suggested like that 😄
a

almibe

11/20/2020, 3:42 PM
I'm not sure I see the benefit of
lib/src/main/kotlin/domain/blah
and
sample/src/main/kotlin/domain/blah
vs
src/main/kotlin/domain/blah
and
src/sample/kotlin/domain/blah
.
v

Vampire

11/20/2020, 3:58 PM
Well, the second is just an own source set. The first is either an own project or even an own build. Each variant has its pros and cons and as the docs say, there is no one-fits-all solution but it always depends. That's why Gradle provides certain defaults and suggests certain practices but stays flexible enough to follow different strategies.
a

almibe

11/20/2020, 3:59 PM
True, I've never liked subprojects in general so that probably explains my dislike of this.
v

Vampire

11/20/2020, 4:24 PM
That recommendation with single subproject was mainly made so that it is easier to add further subprojects later. Actually it is not really a big problem to convert a single project build to a multi project build later on if you need to, but observations in the wild showed all sorts of mess happening anyway. So as it is not really overhead to start with a subproject right away and it makes it easier to add others, this was made the new recommendation. But you are perfectly fine with not following it.
a

almibe

11/20/2020, 4:45 PM
Okay thanks for the explanation.
v

Vampire

11/20/2020, 4:45 PM
yw