This message was deleted.
# community-support
s
This message was deleted.
n
The Groovy one should work in java. does it not?
a
No, there's an error
Copy code
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create an instance of type bla.bla.GreetingPluginExtension
Ah I figured it out, the constructor needs to be
public
👍 1
Is there a way in Java I can get the string
"message"
from the class GerrintPluginExtension?
Gradle knows to turn method
getMessage()
into a a property named
message
by removing the
get
and turning the first character after to lower case
n
what happens if you call
getMessage()
?
a
It returns a
Property<String>
object
n
there you go!
party gradlephant 1
a
perhaps I did not make myself clear
if I add a new method to the extension caled
getFooBar()
then in the
build.gradle
i'll need to access it by setting
fooBar = "blabla"
so Gradle knows how to turn the method name
getFooBar
into the property name
fooBar
and I want to access that property name, not the property value
n
i believe you would do this in the same way that you would do this with standard java reflection for any property name.
a
Isn't there a way to access
propertyName
without reflection? 🤔
n
what is your use case here?
a
I'm writing a test where I'm adding setting a value to the property
semver_gitRepoPath
via a command line argument
-PsemverGitRepoPath=abcd
instead of hard-coding the string
-PsemverGitRepoPath=abcd
I'd like to to something like
"-P" + getSemver_gitRepoPath().getPropertyName() + "=abcd"
alas,
getPropertyName
does not exist 😔
v
You cannot set arbitrary task or extension properties using Gradle properties anyway, so what's the point?
a
Never mind, I've found a reasonable workaround for what I was trying to do
Thanks for the help