-
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
improved multi module support #695
improved multi module support #695
Conversation
Failing: |
@ALL: had a closer look to this yesterday. Currently we are using the root folder as baseDir.(https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Path-and-path-separator-issues)
This is more or less a copy from the C# plugin pattern. Looking to https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxReportSensor.java there is different behaviour for public void analyse(Project project, SensorContext context)
...
List<File> reports = getReports(conf,
reactor.getRoot().getBaseDir().getCanonicalPath(),
fs.baseDir().getPath(),
... private void saveViolation(Project project, SensorContext context, String ruleRepoKey,
String filename, String line, String ruleId, String msg)
...
String root = reactor.getRoot().getBaseDir().getAbsolutePath();
... Think we have to unify this behaviour for both cases. I also think the search order is also wrong:
What are you thinking? |
I was already thinking that it must be some thing different between reports I can apply the module first and root second on that PR, maybe it's worth It would be great someone could prepare a sample project that uses the On Thu, Dec 3, 2015, 11:37 Günter Wirth [email protected] wrote:
|
Think we have two support the following cases:
==> 8 combinations |
@guwirth the reactor needs to be used imo, there is no other way of finding what is the project root without using it. so the case where we look for reports from the root needs to be supported since it was the only supported case so far and the most users that use multi modules are using this approach, to be is loads for setup if you need to generated reports for each modules, its much easier to generate reports for all the project and then just put them in a single location in root of the project |
@jmecosta In case we are supporting absolute paths for defining report file locations what's the difference? # baseDir = x:/root
sonar.cxx.XXX.reportPath=x:/root/reports/xxx-*.xml
sonar.cxx.XXX.reportPath=x:/outside/reports/xxx-*.xml |
@guwirth usually its not a good idea to hard code absolute paths in props files, it will only work in the machine where it was created. for example our ci system uses Base Paths that change according to git revision... so hard coding those in props will not work for us. we would need to pass those via arguments so that they overwrite what exist in props file i mean absolute paths are ok, but it must be a machine passing those to the analysis via -D parameters. imo we are supporting this case to enable such flexibility and not to make it a default padron that everyone uses |
@jmecosta with the flat modell the paths in the report files has to be absolute. Means reports working only if they fit to a specific machine. So have one more absolute path doesn't matter? |
We use relative paths for reports in flat mode, no problems. Perhaps we On Sun, Dec 6, 2015, 13:51 Günter Wirth [email protected] wrote:
|
On #697 you said: flat (relative to root + absolute) In case flat is relative then there is still the question in case of multi module:
|
I'm refering to the patterns we use to search reports, not the content of The path inside report indeed have to be absolute, but those are generated On Sun, Dec 6, 2015, 13:52 Jorge Costa [email protected] wrote:
|
To be honest I would not support cases where reports contain only relative On Sun, Dec 6, 2015, 14:00 Jorge Costa [email protected] wrote:
|
I agree the absolute paths shall be supported for reports but we should also check the performance and maybe introduce a file/path interface for the plug-in. I found this comment and I have low confidence that this will be improved:
We should also consider to support a simple, comma separate list of paths for a report configuration item. The ant style search pattern is not a common way. |
so we agree on the need for absolute paths for reports, #683 should handle it. 24ed1e2 looks to me that it does not support /abc/def/*.xml however the "," can be added later once the main lookup is clarified and merged to master. now for allowing relative paths inside reports to raise issues, the only hard rule that we can apply is disallow it (the performance i think it should not be a big issue because we have been using this so far no one as complained?). if we really want to support it then imo would be, relative to project root and if not found relative to module however this would not use the same algorithim as for looking reports but use only the functions provided by the plaform (so that it does not make it slower) another thing regarding the relative paths is that, we dont know what users are using as base dir to generate reports. file x can be relative to anything, even to a folder outside project. soon they will be asking why my relative path does not work if we support it. |
| test_errors | 0 | | ||
| tests | 3 | | ||
|
||
# Feature: cpp-multimodule-project |
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.
i am ensure about this, with this change we are telling people that they must to have their reports always per module and not once at the root of the repo as it has been supported until now. as far as i know this work is mostly manual and you need to generate reports per module instead of generating the reports once for the all repo.
although this might be ok for some, i think we should also support the lazy people that just put reports on root of the repository and let the plugin deal with it. as far as i know the only way of doing it is with the reactor, so i think we should not remove it
@jmecosta this PR is only to play around and see what is needed to support the SQ default behavior for multi module. What I like on this solution is that the code is very simple, SQ is supported as described on there page and also absolute and relative path support is included in this solution. What is not working is "our" reactor mode having the reports all relativ to the root folder. This could be solved by setting absolute paths in the root BaseDir config (I know you don't like it because path could be different on different servers). Here I would like to come back to a suggestion I made already in the past: why not supporting environment variables in the config file? (I know that there are plans to support this in sonar runner 2.5 anyway). What I don't like on your approach #683 currently: it sounds to much like a msbuild runner solution only. I think there are still many other users like to use this plugin without VS and without msbuild runner. We should not reduce this plugin to a msbuild runner extension. (What I like on your approach: code and structure is better as existing one.) Anyway: as long as your solution is still supporting the "old" use cases we should merge it as soon as the existing unit and integration tests are green (before this one). We can improve/generalize things always later one. I will also try to add some multi module IT tests in a separate PR to see if default SQ modes are supported. |
the reactor is only used for looking up reports from root of the project, its of no use to the msbuild runner. For the msbuild runner the only thing required is to support absolute paths (and those need to be hacked). the msbuild changes this ideas quite a lot, the reports are looked up by default like this. 12:31:04.669 INFO - Base dir: D:\Development\SonarQube\cxx\sonar-cxx\integration-tests\testdata\cpp-multimodule-project-2 At least when i tried the first time, all reports that were under ... just to be sure i really dont use the reactor myself, but i assume that some users do. because its kind of easy to keep those there. (an example, cppcheck works better if you run on root of the directory) but anywhy i like your suggestion to support this special variable, on the file. but this definetly can be done once the absolute report path is done. i will get #683 ready, requires unit tests to be re-factored. and then we can review it and if its ok to merge then we can work on the rector as u suggested |
👍 |
use absolute path instead of reactor pattern align projectBaseDir of modules reports relative to projectBaseDir
This PR is now ready to merge. The reactor is removed but with a modified configuration file the 'reactor multi project' is still working. This solution is now much closer to the SQ default behavior and there is no more 'magic' functionality inside the plugin. The user has to define projectBaseDir explicit - in reactor use case absolute. One thing is a little bit disappointing: It's not possible to set a placeholder for projectBaseDir. The sonar runner is checking the value in the EmbeddedRunner long before the plugin can see it (see https://github.com/SonarSource/sonar-runner/blob/master/sonar-runner-api/src/main/java/org/sonar/runner/api/Dirs.java). Don't know if this is possible to modify? Will create a issue in the SQ newsgroup. |
Ok On Fri, Jan 1, 2016, 16:36 Günter Wirth [email protected] wrote:
|
test 1 for #693