I really would like to appreciate Gradle 5 especially in combination with the new Kotlin DSL, but I’m having a very hard time to get (in my eyes) a very, very simple and common build running with Gradle.
Task
Build & release a project with several interdependent submodules in Maven default directory layout and release them as high-quality Maven artifacts/repository in a to-the-point, simple Gradle build (i.e. DRY).
My results (after a day)
I can build & test the modules and create some POM release (3h)
I was able to add a generator as dependency and add an additional src-Directory (3-4h)
The POM release contains -sources
and -javadoc
(1h)
Support for -SNAPSHOT
builds, Version embedded in MANIFEST.MF
, …
Add license Information to POM.xml
probably many more “standard” tasks to come
My current struggles
I ported my current “results” to a sample project. See here https://github.com/bentolor/gradle-maven-multimodule-kotlindsl
Currently I’m failing to declare the necessary task to provide standard -sources
and -javadoc
artifacts in my central build (DRY!)
For example these three “solutions” which you’ll find on looking for a Kotlin DSL based solutions all do no (longer) work in a multi-module scenario:
- https://stackoverflow.com/a/48070667
- https://stackoverflow.com/a/52596969/1237653
- and even the Offical “Maven Publish” documentation is aimed for single-module case.
Rant (Sorry)
In some point the UX for Gradle and the Kotlin DSL in special is really a nightmare. The main issues which really cause me much headaches are:
- Many samples based on old Kotlin-DSL version out there in the wild (Okay –not particulary s/o “fault”)
- Reference documentation and Kotlin-DSL examples only describes the “whitepaper scenario” (meaning: single-module cases)
- Confusing conversions necessary from whenever porting a solution to the submodule case.
- I.e.
dependencies { compile("commons-logging:commons-logging:1.2") }
“suddenly” needs to becomedependencies { "compile"("commons-logging:commons-logging:1.2") }
(note the quotes), -
task<Jar>("javadocJar") { … }
obviously needs to be converted in sth. like aregister()
? - Some attributes suddenly no longer availalable in subproject scope. I.e.
from(sourceSets.main.get().allJava)
works great in a single-file use-case, butsourceSets
becomes inaccessible if wrapped into asubprojects { }
block
- I.e.
- It’s hard to browse the Kotlin DSL. The IDEA autocomplete is veeery laggy and incomplete and does not allow in-depth source navigation. I ended up reading i.e. the Source Code of JavaLibraryPlugin.java to understand what has to be done to add additional source roots.
Please prove me wrong! (aka: Help anyone)
I really would love to see Gradle being a good tool and I’m hoping that I’m simply missing a few basic and simple ways to approach such a common taks.
Can a few knowledgeable guys maybe just spare a short look on my (very!) example project above and try to incrementally improve it to a full-fledged, reference build for simple, multi-modules projects?
Thanks a lot & Sorry for the long rant.