SonarQube plugin: how to get property value from command line -D

458 Views Asked by At

I am new to sonar plugin development. I wrote a plugin and add PropertyDefine to context. And then I wanna get my property value passed by

gradle sonarqube -Dmy.proper.name=xxx

I don't know what are the next steps? Plz help. Thanks.

2

There are 2 best solutions below

0
On BEST ANSWER

Hi @agabrys thanks for your answer. But I found out that if you wanna get the property from Scanner side, you need make a PostJob like class to deal with it. I didn't clearly know that so I didn't know why I couldn't get that property. Thanks anyway.

0
On

All -D parameters can be get by using java.lang.System class:

String valueOrNull = System.getProperty("my.proper.name");

or

String valueOrDefault = System.getProperty("my.proper.name", "defaultValue");