Running Developer Edition Version 9.9.2 (build 77730)
SonarQube is deployed using the zip file. The scan attempted is using SonarScanner 4.7 also unzipped on the build machine.
Trying to scan C code using the sonar scanner. I get an error to set up build wrapper.
I have downloaded the wrapper for Windows but have not run it against our build yet. We have many different native projects in our code base. We use a batch file to call the maven command to build our code base including the native code. The folders I am scanning are all compiled prior to the scan. We are also still using VS 2012.
Is the build wrapper the best choice for this situation? Does it need to be run against each native project individually or can it be ran against all projects at once?
Hey there.
Why not? The best way to know if you can use the build wrapper without any additional modification would be to run the build wrapper around your maven
command and see if the analysis is successful.
Thanks for getting back to me.
I was wary of the executable and didn’t know if I needed to run it against the native projects individually. I was hoping to get more information before spending hours with trial and error.
I added the command to the maven command in the batch file and ran a full build. This takes hours to run. The first and second runs did complete and it gave me a folder with a log but no json file. Below is all the log said. I searched the file system for build-wrapper-dump.json but it did not find one. My build log only mentioned the build wrapper when it echoes my build command.
Mon Oct 02 11:37:15 2023: build-wrapper, version 6.41.1 (win-x86-64)
Mon Oct 02 11:37:15 2023: isWow64: 0
Mon Oct 02 11:37:15 2023: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 3
Mon Oct 02 11:37:15 2023: current directory: C:\bit9prog\dev\Workspace\JEM_Incr_2
Mon Oct 02 11:37:15 2023: cwd: <C:\bit9prog\dev\Workspace\JEM_Incr_2>
Mon Oct 02 11:37:15 2023: out-dir absolute path: <C:\bit9prog\dev\Workspace\JEM_Incr_2\build_wrapper_output_directory>
Mon Oct 02 11:37:15 2023: command line received: <MSBuild.exe /t:Rebuild /nodeReuse:False>
Running the command after mvn clean install on an individual project I get:
Unable to parse command line options: Unrecognized option: --out-dir
Removing the output dir complains about the /t parameter and more errors down to just adding the executable and then that isn’t a valid lifecycle phase.
Hey there.
It would probably be helpful for you to zip up your entire build wrapper output directory fromt his run:
Including the log file.
I can open a private message channel to share it if you don’t feel comfortable redacting/sharing it here.
Yes, a private channel would be good. Thank you.
Thanks for sharing. In fact it looks like there was no more info than what was in the log snippet you already shared!
What exact command do you use to run the build wrapper and the build? You mentioned maven before, but here I see MSBuild.exe
.
What happens if you run
build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory mvn clean install
Sorry! I didn’t see your response last week.
Running your suggested command gives the following information.
I get output from the wrapper in my command prompt:
[SONARSOURCE BUILD-WRAPPER] failed to execute mvn clean install : The system cannot find the file specified.
The folder contains the same log file as before but I now get the below output in it. mvn is in my path, I don’t know what file it can’t find.
Tue Oct 10 11:50:38 2023: build-wrapper, version 6.41.1 (win-x86-64)
Tue Oct 10 11:50:38 2023: isWow64: 0
Tue Oct 10 11:50:38 2023: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 3
Tue Oct 10 11:50:38 2023: current directory: C:\bit9prog\dev\Workspace\JEM_Incr_2\build
Tue Oct 10 11:50:38 2023: cwd: <C:\bit9prog\dev\Workspace\JEM_Incr_2\build>
Tue Oct 10 11:50:38 2023: out-dir absolute path: <C:\bit9prog\dev\Workspace\JEM_Incr_2\build\build_wrapper_output_directory>
Tue Oct 10 11:50:38 2023: command line received: mvn clean install
I was able to get that command to run. It is in progress now but will take a few hours before I can run the scanner against the json file that is now located in the output dir.
The file it could not find appears to have been the the mvn command even though the bin was in my path. I wrote a script to set all of the environment variables prior to running the command but I ended up having to specify mvn.cmd file when running the command anyway so my working command looks like the one below.
build-wrapper-win-x86-64.exe --out-dir build_wrapper_output C:\apache-maven-3.6.3\bin\mvn.cmd clean install -Pnative
Update: That command works until it gets to the native code compilers. Then it doesn’t pick up the location of the compilers executable location from the path again. It looks like maybe each native project might need to be run separately using the msbuild commands. Is there a way to run the wrapper with a combined set of compilers like we use in our enviroment?