Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Kotlin DSL build script #281

Open
tmohme opened this issue Dec 30, 2021 · 4 comments
Open

Gradle Kotlin DSL build script #281

tmohme opened this issue Dec 30, 2021 · 4 comments
Labels

Comments

@tmohme
Copy link
Contributor

tmohme commented Dec 30, 2021

Testing Problem

It does not solve any particular testing problem ;)

Suggested Solution

If you are interested in having type-safe Kotlin DSL build scripts, I would try to convert the existing ones (plus changing the structure to avoid cross-project configuration) in a PR.

Discussion

Structurally, the result would look similar to what is described at https://docs.gradle.org/current/samples/sample_building_kotlin_applications_multi_project.html (especially the buildSrc).

@jlink
Copy link
Collaborator

jlink commented Dec 30, 2021

@tmohme Thanks for the suggestion. I prefer the Groovy syntax of Gradle, but that's just a personal preference given my Groovy history. I have the feeling that it gives me a bit more leeway and is less verbose in some cases.

But what do you mean by "plus changing the structure to avoid cross-project configuration"? That sounds interesting.

@tmohme
Copy link
Contributor Author

tmohme commented Dec 30, 2021

In the "early days" of Gradle, using "subprojects {}" and "allprojects {}" were the only means to share build logic between Subprojects.
Since a few major releases there is another, now recommended approach: Using convention plugins.
See https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html#sec:convention_plugins_vs_cross_configuration
From my experience, I can confirm the described problems with cross project configuration and I had no issues with the convention plugin approach (yet).

@jlink
Copy link
Collaborator

jlink commented Dec 30, 2021

This make sense - even if the Gradle documentation requires quite some hopping to understand how it works.

@tmohme If you’re willing to start with convention plugins and keep the Groovy DSL (at least in the beginning) I’d be more than happy.

@vlsi
Copy link
Contributor

vlsi commented Jan 6, 2022

I recently migrated https://github.com/allure-framework/allure-gradle to the idiomatic structure, and I incline to like that structure (it is literally the same as the one used by Gradle itself)

The only bit I would like to do slightly different is to name build-logic as allure-gradle-build-logic since currently Gradle does not support composite builds where multiple builds have their own build-logic module (see gradle/gradle#17228).
The workable workaround is to use ${project_name}-build-logic or build-logic-${project_name} naming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants