Has anyone here managed to get Gradle DSL multi pr...
# gradle
j
Has anyone here managed to get Gradle DSL multi projects to work where you have your sub projects in e.g. a subprojects folder at the root as they do in the gradle project itself, see line 181 here? I also want the IntelliJ IDEA integration to work.
I found this smaller project also, and now I can manage to build my Gradle DSL project with "gradle build" but I get "Unable to get Gradle home directory" in IDEA.
g
Could you provide some example where it doesn’t work
j
I just now managed it to almost get it to work now. I can push the code and I will post it here in a minute.
My project is here. The problem now is that when I execute "gradle build" it doesn't generate any class files.
n
the source directories you specify are relative paths. these paths are relative the build.gradle.kts file. in this case these paths do not exist https://github.com/tengstrand/polylith-kotlin/blob/master/kotlin/environments/core/build.gradle.kts#L18
j
But I pushed, update and have a look again.
I added "../../" but no improvement.
I just pushed my changes.
I removed "/kotlin" from the path (a mistake by me) and pushed. Still no classes as output though.
It builds classes now! But I can still not execute the 'main' function (kotlin/bases/cli/src/polylith/kotlin/cli/api.kt) from inside IDEA. Thanks for the help so far by the way!
n
it might be easier to use a normal project structure? is there any reason you need to have the directories set up like this?
j
Yes, I'm the author of the Polylith architecture and we already support Clojure but now we are looking into supporting Kotlin also. It wants these root directories: bases components environments The idea is to combine components and bases into environments that can be e.g. services, stand alone tools or development environments, like this:
The green bricks are components and the blue 'cli' one is a base. This is an example of a Polylith workspace.
n
seems like you might want some separation of the code in each of those? bases is separated from components which is separated from environments? in that case you likely want one
build.gradle
file in each of the bases, components and environments folders
j
I was actually started to think the same. But the thing is that a component or a base only makes sense together with other e.g. component, so the best solution would be if I could specify the src-folders for the components and bases per environment, because the list of dependencies are unique per environment, not per component/brick. Maybe custom compilations would do the trick?
g
I think idea just doesn’t support it. You can report it to idea tracker, but it really not conventional
j
The other thing is that we don't want to compile each component and base separately because it takes too long when you have a lot of them and it's not necessary either. We only want to build each environment. When I manually created a classes folder in kotlin/bases/cli and manually copied the environments/core/build/classes/kotlin/main/polylith folder into it, then the IDEA integration worked! But that was just a test, nothing that could work in practice 🙂
j
this works with projects in the root directory (i've put mine in sub directories, applications, modules, integrations) https://github.com/JVAAS/kotlin-multiplatform-multi-module-setup (it needs some cleanup and a README so that it can be used as a reference for people getting stuck on this exact same thing)
j
I finally managed to get it to work also, but good to have more examples, so thank you very much!
K 1
j
i think we need an example like this on the official Kotlin git repo, would have saved me a good few days of digging i'll cleanup this repo tonight, then anyone getting stuck, can just be referred to this very simple working example
j
That’s a really good idea.