There’s no real “style guide” per-se for writing build scripts, but here are some tips:
Apply all your plugins at the top of your build script.
Group related configuration into blocks if possible.
// instead of this
sourceSets.main.java.srcDirs = ["src"]
sourceSets.test.java.srcDirs = ["tst"]
sourceSets.main.resources.srcDirs = ["resources"]
// do this
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['resources']
}
test {
java.srcDirs = ['tst']
}
}
Group property assignments in one place (source/target compatibility, version, mainClassName, etc).
Put buildscript { } block at the top of the build script (as you have it already).
Declarative elements like repositories, dependencies, etc should come before imperative elements (ad-hoc tasks).
These are not hard and fast rules, just things I try to keep in mind when writing build scripts. In general, it doesn’t matter so much what conventions you use, so long as you do so consistently across your build scripts.
I wouldn’t use an inline class just to declare constants. You should be
able to declare constants like that without the entire class wrapper. Be
sure to put those in a consistent place, probably after your “apply” lines,
at least.
The forum software might not send an email if it thinks you’re ‘active’ on the page. There’s a user setting to turn that off and have it always send an email.