Maven Golang build is not scanning Go-ThrowExceptions

Exception or error:

We are using maven to build Golang projects, because we are a mixed-language shop and maven is the current standard for builds.

Our first Go application is a set of services serving a Vue project.

The jenkins file calls mvn sonar:sonar like this:

    stage('Sonar') {
        steps {
            echo 'Building Sonar'
            withSonarQubeEnv('Sonar') {
                // requires SonarQube Scanner for Maven 3.2+
                        maven: 'Maven 3.5.3',
                        globalMavenSettingsConfig: 'GlobalSettingsRepo',
                        jdk: 'Java 8 Oracle',
                        options: [
                                artifactsPublisher(disabled: true),
                                jacocoPublisher(disabled: true)]) {
                    sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin: -U'

I have updated both the parent pom and the pom inside the Go folder to include:


I have also hard-coded GOPATH to my Go folder in the environment variables.
However, when I run the build, sonar scanner ONLY scans the xml files in the project. If I run sonar scanner from the command line, it analyzes both the Go code and the Vue code.

Any suggestions?

How to solve:

Apparently, sonar-scanner will analyze your entire project structure by default and requires explicit excludes to skip directories that obviously shouldn’t be analyzed, like node_modules.

Maven sonar plugin expects you to explicitly enumerate your source directories. I placed the following lines in the child pom.xml files and it worked the way I expected.

Golang pom.xml:


Vue pom.xml:


Leave a Reply

Your email address will not be published. Required fields are marked *