Does anybody know how to get access to the maven variable (project.properties getProperty('justAbotherProperty')) from within the groovy class? When I'm trying to do this within the plain script(outside of the class) I'm able to do this. According to the gmaven documentation maven project variable is accessable from within the script. If it is so I just want to confirm it and then come back to the scipts instead of classes...
Here is the code I use:
class Connector {
private String sshHost
private String sshUser
private String sshPass
private Integer sshPort
private def parseParametes() {
sshHost = project.properties.getProperty('scp.host')
sshUser = project.properties.getProperty('scp.user')
sshPass = project.properties.getProperty('scp.password')
sshPort = project.properties.getProperty('scp.port').toInteger()
}
}
Execution of parseParameters()
spits out:
groovy.lang.MissingPropertyException: No such property: project for class: Connector
Thanks in advance for any help!
(Untested)
Before you move back to scripts from classes, have a look at Using Groovy Classes. Try to set the scriptpath
and follow the example as mentioned in the page.
I tried to answer a similar question earlier. I hope when you set the Groovy Class in the scriptpath
the default variables which are tied to the script environment should be available in the classes.