-
Notifications
You must be signed in to change notification settings - Fork 402
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
JavaApplication.setMainClassName(String) removal in Gradle 8.0 #609
Comments
+1, in gradle 6.7, |
This reverts commit ce52622. The Shadow plugin does not support the new `mainClass` property holder yet. See GradleUp/shadow#609 for details.
Because it is not yet compatible with "JavaApplication.setMainClassName removal": GradleUp/shadow#609 Did the fat JAR with the help of the official user guide: https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_packaging
Because it is not yet compatible with "JavaApplication.setMainClassName removal": GradleUp/shadow#609 Did the fat JAR with the help of the official user guide: https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_packaging
#336 suggests this workaround: application {
// Desired way mainClass.set("<main class>") causes an issue during jar packaging
@Suppress("DEPRECATION")
mainClassName ="<your main class here>"
} But as I wrote in that issue, it removes the strikethrough formatting from Intellij, but
And it sounds like suppression of warnings from gradle is not possible by choice... So because if this I don't think it is possible to use shadowJar with gradle 6.7 without warnings. This alone prevents us from using the either shadowJar or the newest version of gradle. ;-( |
@nhumblot The link in your original post "build displaying the warning on Gradle 6.7" is broken. |
Sorry about that, the linked branch has been merged and deleted since then. I updated the link pointing to the same version of the file on another branch. Thank you for notifying me. |
+1 Faced this issue too. |
Will this ever be addressed?.... |
Any news here? |
#609 Support application mainClass property as fallback of mainClassName
Great! when can we expect a new release with this fix included? |
I found workaround for 6.1 version of shadow: application {
mainClass = 'com.my.App'
}
shadow {
mainClassName = application.mainClass.get()
} It works without any warnings. |
Please check the User Guide before submitting "how do I do 'x'?" questions!
Shadow Version
6.1.0
Gradle Version
6.7 - Work but display a warning
8.0 - Expected failure
Expected Behavior
build.gradle
is compatible with future Gradle 8.0 syntax and no error happens in shadowJar taskActual Behavior
build.gradle
is not compatible with future Gradle 8.0 syntax and a warning is displayedbuild.gradle
is compatible with future Gradle 8.0 and an error occursGradle Build Script(s)
build displaying the warning on Gradle 6.7
build not displaying the warning but failing in shadowJar task
Content of Shadow JAR (
jar tf <jar file>
- post link to GIST if too long)N/A
Additional comment
Hi,
Thank you to all the contributors for this very useful plugin !
I recently got a merge request for upgrading to Gradle 6.7. The build job displayed a new warning:
Based on the documentation provided to the link, I performed the following changes (and upgraded shadowJar to the latest version at the same time): https://gitlab.com/nhumblot/java-comments-translator/-/commit/7739108a8e3a2cb7fc67d64b73c5abe1f008bc02
This change to
build.gradle
remove the warning as it make the syntax compliant but Shadow JAR plugin still expect to have amainClassName
, therefore, the build fails in theshadowJar
task with the following error:Here is the stacktrace:
Accordingly to the documentation. The plugin explicitly looks for
mainClassName
. Should we add a fallback mechanism looking formainClass
if the first one is not present ?I will try to continue the investigation for preventing this issue. If a maintainer wants to share any input regarding this, I will gladly take any advice.
Thank you for your help
Kind regards
The text was updated successfully, but these errors were encountered: