加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

How to setup and configure Sonar for Groovy projects

发布时间:2020-12-14 16:55:03 所属栏目:大数据 来源:网络整理
导读:Sonar is an open platform to manage code quality. Sonar can gather data from your Groovy projects and display them on a web interface or straight in SpringSource Toolkit via an eclipse plugin. 1. How to enable analysis of your Groovy proje

Sonar is an open platform to manage code quality. Sonar can gather data from your Groovy projects and display them on a web interface or straight in SpringSource Toolkit via an eclipse plugin.

1. How to enable analysis of your Groovy projects

  1. If your project is not mavenised,you will need to create a pom.xml.
    cd into your project folder and run:

    mvn org.grails:grails-maven-plugin:1.3.7:create-pom -DgroupId=YOURGROUPID
    mvn org.grails:grails-maven-plugin:1.3.7:create-pom -DgroupId=YOURGROUPID
  2. Edit your pom xml. Add:
     <sourceDirectory>src/main/groovy</sourceDirectory>
     <properties>
        <sonar.language>grvy</sonar.language>
        <sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
     </properties>
     <sourceDirectory>src/main/groovy</sourceDirectory>
     <properties>
        <sonar.language>grvy</sonar.language>
        <sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
     </properties>

2. How to add your project to the sonar console

  1. You need to install the Flex plugin to enable analysis of AS3 and flex projects:
    Go to System>Update Center:

  2. Under Available plugins find Groovy and click install:

  3. Restart sonar:
    macosx-universal-64/sonar.sh stop
    macosx-universal-64/sonar.sh console
    ..or the linux/windows equivalent...
    macosx-universal-64/sonar.sh stop
    macosx-universal-64/sonar.sh console
    ..or the linux/windows equivalent...
  4. Go to the sonar profiles page.
    If you installed sonar locally,the default url is:

    http://localhost:9000/profiles/projects/
    http://localhost:9000/profiles/projects/

    If the installation was successful,you should see a ‘Sonar Groovy Way ‘ section:

3. How to gather data from your Groovy project and analyse it in Sonar

  1. cd into your project folder. Clean and Install your project into your local maven repo:
    mvn clean install
    mvn clean install
  2. run the sonar analysis:
    mvn sonar:sonar
    mvn sonar:sonar
  3. Go to your Sonar profile page. For local installs the default url is: http://localhost:9000/profiles
  4. Click on +Create or ‘Sonar Groovy Way‘ and? add your project to the associated projects:

  5. Go back to your sonar web interface (http://localhost:9000) –? the reports on all gathered data should be displayed.

4. How to install and configure the Sonar Eclipse Plugin in STS

  1. Go to Help>Install New software
    Enter the Sonar Update Site:

    http://dist.sonar-ide.codehaus.org/eclipse/
    http://dist.sonar-ide.codehaus.org/eclipse/

  2. Click Next,Accept T&C,Reboot STS when prompted
  3. go to preferences,type in sonar to the filter:

    If you are running sonar on http://localhost:9000/,then you don’t need to do anything.
    If your are running on a different host:port,click on add and and add a new Sonar Server URL.
  4. To verify the connection you can click on edit and click on Test Connection. In the console you should get:
    [INFO] Connected to Sonar 2.8
    [INFO] Connected to Sonar 2.8
  5. Right click on your project in the Project explorer,go to Configure > Associate with Sonar:

  6. 1. Select your Sonar server from the dropdown list
    2. Copy the GroupID and ArtifactID from your pom.xml
    3. Click on Find on Server

  7. Switch over to Sonar View:

  8. If the sonar analysis was successful,your Measures,Web,Hotspots and Violations panel will be populated with the gathered data.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读