Skip to content

Commit

Permalink
[chore] Address deprecation of JavaExecSpec.main property
Browse files Browse the repository at this point in the history
Gradle has deprecated the `JavaExecSpec.getMain()` and `JavaExecSpec.setMain()`
methods in favour of the new `mainClass` property.
The old methods are scheduled to be removed in Gradle 8.0, but Gradle already
warns about their deprecation when used.

This change addresses this issue by using the `mainClass` property if it
exists and fallback to the `setMain` when it doesn't to provide
compatibility with older Gradle versions.
  • Loading branch information
fabianishere authored and aalmiray committed Apr 22, 2022
1 parent bfaec5c commit a87572c
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ class JandexTask extends DefaultTask {
args << destination.asFile.get().absolutePath
args.addAll(resolveSources())

jes.main = JandexMain.class.name
if (jes.hasProperty("mainClass")) {
jes.mainClass = JandexMain.class.name
} else {
jes.main = JandexMain.class.name
}
jes.classpath(resolveClasspath())
jes.args(args)
}
Expand Down

0 comments on commit a87572c

Please sign in to comment.