Hello, dear.

Literally the 3rd day I began to learn a bunch of IDEA + Maven + SonarCube. From here there are a few questions. Help to understand, please!

  1. How in IDEA (more precisely in the Maven Project tab) add sonar: sonar with the necessary parameters? Parameters - to connect to the sonar of the remote machine (lokalka). The person who has deployed a sonar, NetBeans generally uses, does not know about the idea, but needs to be mastered. Now I am doing Execute Maven Goal:

    sonar: sonar -Psonar -Dsonar.host.url = http://192.168.54.233:9000 -Dsonar.jdbc.url = jdbc: postgresql: //192.168.54.233/sonar

  2. There is a module in the project, which (module) is flooded from GIT. On the Sonar this module is already there (in the form of a project). When trying to connect the sonar gives an error:

Failed to execute goal org.codehaus.mojo: sonar-maven-plugin: 2.6: sonar (default-cli) on project new_elk: The project 'com.xxx.xxx.lk:lk_protocol' module of project 'com.xxx:new_elk'. Analysing project 'com.xxx.xxx.lk:lk_protocol', if you really want to stop, please first delete it from SonarQube and then relaunch the analysis of the project 'com.xxx:new_elk'. -> [Help 1]

What can be done to fix this without removing the project from the sonar? I will make a reservation that this project (lk_protokol) is used in my form of a module for the main project, and you cannot make it a separate project.

I would be very grateful for any answers!

  • So. He answered the second question - it is enough to indicate the path to the module in the Execute Maven Goal working directory, not to the project. - Evgeny Karpov
  • I also found how to make launching a sonar easier: (sonar: sonar -Psonar) - just open settings.xml in the mavena, and create a sonar profile there that has properties listed in the sonar settings, they are on the Internet. Later add as an answer. - Evgeny Karpov

1 answer 1

Continuing the beloved tradition "I asked myself, answer it myself," I answer.

In order not to torture Execute Maven Goal, it is enough in pom.xml (For the required module / project! It is important!), Specify the sonar plugin and update the maven:

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>sonar-maven-plugin</artifactId> <version>2.3</version> </plugin> 

After this, the following option will appear:

sonar: sonar

Just run it. If the sonar is deployed on a remote machine, you need to edit the settings.xml of the maven:

settings.xml

And add the configuration profile of the remote machine and the base there:

 <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <sonar.host.url>http://192.168.54.233:9000</sonar.host.url> <!-- sonar:sonar -Psonar -Dsonar.host.url=http://192.168.54.233:9000 -Dsonar.jdbc.url=jdbc:postgresql://192.168.54.233/sonar --> <sonar.jdbc.url>jdbc:postgresql://192.168.54.233/sonar</sonar.jdbc.url> <!--<sonar.jdbc.username>sonar</sonar.jdbc.username>--> <!--<sonar.jdbc.password></sonar.jdbc.password>--> </properties> <!-- Указать репозитории и плагины как у основного профиля, если надо. --> </profile> 

Well, the second question was resolved by itself - we are launching a sonar on behalf of the desired module or project, and not from the carrier project. If you need to do exactly Execute Maven Goal, then it is enough to specify the path to the module in the upper field of this window, and not for the default project.

Hope this helps you. Cool tools, highly recommended!