-
Notifications
You must be signed in to change notification settings - Fork 363
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
Support environment variables and system properties in configuration files #716
Support environment variables and system properties in configuration files #716
Conversation
Try to to support also vars that are passed as arguments. For example -DRoot=c:\src Usually those are more useful than environment variables. Both should be coded. Suppose the you can use get clear property to retrieve the the props that are ${} before looking into the environment |
@jmecosta good idea will try. Do you know how sonar runner is handling this defines? |
I dont think it matters, we they reached the plugin I think they are already parsed properly |
I think you can use the settings class to get those. |
This PR is always crashing on server side.
@ALL someone experience with this? Is it possible to extend Settings? Is there something I have to register on server side? |
import java.util.Properties; | ||
import org.sonar.api.config.Settings; | ||
|
||
public class CxxSettings extends Settings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if the internals of Settings will be in proper state when it arrives to the plugin. i would assume core to create its own instance of Settings class, likely when CxxSettings gets into the plugin it comes without any information about the settings.
perhaps this class cannot be used like this, and might explain the issue in server side. Could this be done in a helper class that receives Settings and then returns the value as per you implementation below?
This version is working. Maybe someone more familiar with Java can have a look to it. |
Looks good to me, I don't know what are the java patterns that should be used in this case but for me it looks functional |
The point with this solution is, that the Other approach could be to use inside CxxSettings a reference and the pimpl pattern. But this means all methodes must be duplicated. |
Ready to merge 👍 Support environment variables and system properties in configuration files: use ${xxx} as placeholder |
Let me test it first. Try to do it before end of year. On Thu, Dec 24, 2015, 10:56 Günter Wirth [email protected] wrote:
|
Ok. Happy xmas. Von meinem iPhone gesendet
|
Merry Xmas also.. On Thu, Dec 24, 2015, 15:45 Günter Wirth [email protected] wrote:
|
@jmecosta did you have some time for testing? Can I merge this? |
i will do it today. On Tue, 29 Dec 2015 at 12:28 Günter Wirth [email protected] wrote:
|
@guwirth few things i spotted: if passing -DAnalysisReportsDir=D:\SonarVersions\MultLanguageProject.cxxresults i dont get the parser to replace the AnalysisReportsDir environment variables work, however if using what i get in the plugin is: so it does not support the windows separators. |
😕 thx for testing. Will try to improve it.
|
There are three types to replace:
Currently I replace only 2 & 3. Will add also 1.
In case of 2 & 3 I have to replace \ with \ or / to behave like defined in config file. |
Ok so its possible to support the windows paths, I know that using the On Tue, Dec 29, 2015, 20:15 Günter Wirth [email protected] wrote:
|
- CxxSettings clones Settings in ctor - format for placeholder is ${xxx} - supported are environment variables, Java system properties and SonarQube properties - backslashes in values from environment variables and Java system properties are replaced with slashes to support Windows paths
For this case you have to define it like in config file. Can't replace \ with / because I don't know which properties are from config file and which are from command line. works now:
It's working now. |
CxxSettings supports variables in configuration files …
|
Ok I will test again in a bit. Thanks On Wed, Dec 30, 2015, 09:27 Günter Wirth [email protected] wrote:
|
works fine now, thanks. for me it can be merged On Wed, 30 Dec 2015 at 09:29 Jorge Costa [email protected] wrote:
|
Support environment variables and system properties in configuration files
todo: unit test
@ALL: any feedback to this approach?