How can i “provision” the SonarLint-Eclipse Plugin for an existing workspace?

eclipse
java
sonarlint

(Daniel) #1

dear all, please consider

  • an eclipse IDE-installation including the sonarlint-plugin
  • an eclipse-workspace with some (30+)already existing projects
  • a current Sonarqube server instance which matching projects for each Workspace-Project
  • a wish to bind each Workspace-Projects sonarlint-setup to the Sonarqube-Project
  • a security-token existing in Sonarqube setup for the user that wants to work with this setup

How can i automate the necessary workspace-setup-actions that bind the workspace-projects to sonarqube-server-projects?

For example: how to setup/manipulate the files create/manipulate the files

  • [ECLIPSE_INSTALL_DIR].metadata.plugins\org.eclipse.core.runtime.settings\org.sonarlint.eclipse.ui.prefs
  • [EACH_ECLIPSE_WORKSPACEPROJECT_DIR].settings\org.sonarlint.eclipse.core.prefs

so that noone needs to manually configure 30+ Projects to bind to the right sonar-project-names etc.

Please do not suggest something like autobinding, that is still a manual process which needs not only be done for every project once but also you need to find the right project name if you have multiple project_key-candidates to select from

//edit: I also would like to add the sonarqube-server configuration by editing the Eclipse-Installation and not as a manual process … if that is possible it would be very nice to be able to do that

If that is not possible currently … i would very humbly like to ask for guidance concerning any other possibly existing way how to ease this setup procedure for the developer.

cheers daniel


(Philippe Cadé) #2

Hi Daniel,

You should be looking at Eclipse Oomph which can help you automate the installation and setup of your workspace. You can add the SonarLint plug-in as a requirement, list all your projects in a project set to be automatically checked out from source control, and adapt the configuration files as required, etc.

We have added org.sonarlint.eclipse.core.prefs to source control with the reference to the project and module on Sonar. The Sonar server is also pre-defined.

The only manual process left is for our end users to generate their token on the Sonar server and enter it once in Eclipse.

Philippe


(Daniel) #3

Thank you for your reply, @Philippe_Cade !

I am sorry to be so late to answer your answer, but it definitely looks like something i might be able to accomplish.

I will gladly mark your reply as an answer … but, if i may humbly ask, would/could you be of help in creating the content which i will need to feed to oomph?

I am still getting my feet wet (and am currently lacking the time to further experiment) with oomph … so i would be glad to be able to ask you here in this thread as a Reply. This would probably also make this thread more whole.

(just to point it out: i ment, i would like to - in the future - use this thread to ask you about uncertainties i probably will be having when further experimenting with oomph and sonarlint)


(Philippe Cadé) #4

You should try one of the many tutorials on Oomph available out there. These will get you going quickly.


(Jérémie Bresson) #5

As discussed in this thread this manual process is even too much for some members of our team. It would be great if something could be improved.

As for the suggestion with Oomph, I do not see any possibility to automate the connection to the SonarQube Server right now.

  1. The server management is in a separated view (and not in the general workspace preferences), I can not use the Oomph pref recorder to record and replay this configuration across the team workspace.
  2. It would be great to have a specific Oomph setup task to configure the SonarQube server (in a similar way that you can define that you would like to query your issue-tracker as part of the Oomph setup script).
  3. As alternative, could you provide an hint where the server-setup is stored? Is that a file in the .metadata folder of the workspace?
    => I am ready to investigate even nonofficial API to perform the setup.

(Julien Henry) #6

The server connection metadata are stored in the Eclipse instance scope. It means that if you have multiple workspaces, you don’t have to configure the server again and again.

I’m sorry I don’t know OOMPH in details, but I remember it was possible to record server preferences with the old workspace mechanics plugin.

Also, if you are packaging a custom Eclipse bundle in your company, you can provide a plugin_customization.ini to automatically provision the server.

The only thing missing is the ability to provide a token. Since it is stored in the secure storage, I’m not sure it is possible to automate that. So users will need to edit the server connection to set a token.


Automate SonarLint setup in Eclipse IDE
(Philippe Cadé) #7

The preferences for Oomph are:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:setup="http://www.eclipse.org/oomph/setup/1.0">
  <setup:PreferenceTask
      key="/instance/org.sonarlint.eclipse.core/servers/initialized"
      value="true"/>
  <setup:PreferenceTask
      key="/instance/org.sonarlint.eclipse.core/servers/sonar/auth"
      value="true"/>
  <setup:PreferenceTask
      key="/instance/org.sonarlint.eclipse.core/servers/sonar/url"
      value="https://sonar.domain.com/"/>
</xmi:XMI>