Skip to content
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

Request: Capability to use goal "add-source" from the command line #156

Closed
gjd6640 opened this issue Oct 31, 2022 · 0 comments · Fixed by #157
Closed

Request: Capability to use goal "add-source" from the command line #156

gjd6640 opened this issue Oct 31, 2022 · 0 comments · Fixed by #157

Comments

@gjd6640
Copy link
Contributor

gjd6640 commented Oct 31, 2022

In prior issue #79 the poster wanted to be able to run the "build-helper:add-source" goal from a command line. I have a similar desire and it is one where modifying the POM by adding an execution of the build-helper-maven-plugin's add-source goal doesn't cleanly solve the problem. I think that the code change required would be to simply add a name to the "sources" parameter by adding an argument to the @parameter annotation on that field in file AddSourceMojo.java. I didn't want to start by submitting a merge request though in case the response from the community is "don't do this, it's a bad idea".

Specifically, I'm maintaining automation that runs against a large and varied set of Maven projects. These include some multimodule projects that each produce a handful of shared libraries. I need to be able to add several custom scan report files as source files. These will then be used in last stage of my automation by "sonar-maven-plugin". Today, sonar-maven-plugin obtains the source directories from Maven and only pays attention to files in those locations so fails to include. For single-module projects a simple workaround of "setting -Dsonar.sources=." does the trick. Providing that plugin with the source paths for multimodule projects is tricky and seems to deserve to be done by informing Maven of the additional source path.

I'd like to be able to add source files without manipulating each project's pom file(s) and without using little-known Maven features such as build profiles that are defined in settings.xml or profiles.xml (the latter is deprecated).

Here's a specific example of what I'd like to be able to do from a command line:

<root of project codebase>$ mvn dependency:tree -DoutputFile=target/sonar-scan-reports/maven-dependency-tree.txt build-helper:add-source -DadditionalSourcePath="./src/custom-scan-reports/" org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar

This way file "maven-dependency-tree.txt" would be considered part of the codebase to be analyzed, would get generated for each submodule, and Maven would provide maven-sonar-plugin with a set of source paths that's correct for each submodule and that includes these reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant