-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Java Application MainClass is not readable depending on how it is set #14662
Comments
Doing the following is the recommended way:
When you do When you read the value by doing The convention was a commodity for plugin authors to set default values to fields. It should not be used in a build script by build authors. |
@ljacomet thank you for the info. The move to Do you have a link to documentation for plugin authors on how to read out these kind of settings from the underlying model if conventions are not the way? Or could you give me a line of code on how you would do it? I was following the examples here although I realise here they set data, not read it |
Thanks for the pointer to that documentation. It needs an update. You should simply read the value from the model. So in the case we discussed: In short, values set by convention - either through the |
Ah I see. So go through the So
instead of
Thanks for the help. |
Expected Behavior
I think I should be able to read out the Application Plugin's
mainClass
value regardless of how it is specifiedCurrent Behavior
The Application plugin main class can be specified in 2 ways...
or...
I'm using the following code to access the main class via the
ApplicationPluginConvention
...I can print out
com.foo.bar.Main
in the first example but I getnull
for the second exampleAs far as I know this method isn't being deprecated, only the
JavaApplication#getMainClassName
is being deprecated - is that correct?I see the new mainClass property and the convention are linked in
DefaultJavaApplication
as follows...gradle/subprojects/plugins/src/main/java/org/gradle/api/plugins/internal/DefaultJavaApplication.java
Line 35 in 386998a
Does that mean it's only set in one direction? So it doesn't update the convention's value when
mainClass
is set in the Application?Or is it not valid to use the convention to access the main class?
Context
It's for a plugin that exports the Java/Scala build setup - Bloop
Gradle 6.5
Windows 10
The text was updated successfully, but these errors were encountered: