Groovy   发布时间:2022-04-12  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了How to setup and configure Sonar for Groovy projects大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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:

    @H_925_23@mvn org.grails:grails-@H_933_8@maven-plugin:1.3.7:create-pom -DgroupId=YOURGROUPID
    @H_450_48@mvn org.grails:grails-maven-plugin:1.3.7:create-pom -DgroupId=YOURGROUPID
  2. Edit your pom xml. Add:
     <sourceDirectory>src/@H_933_8@main/groovy</sourceDirectory>
     <properties>
        <sonar.language>grvy</sonar.language>
        <sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
     </properties>
    @H_450_48@ <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:

    How to setup and configure Sonar for Groovy projects

  2. Under Available plugins find Groovy and click install:

    How to setup and configure Sonar for Groovy projects

  3. Restart sonar:
    @H_925_23@macosx-universal-64/sonar.sh stop macosx-universal-64/sonar.sh console ..or the linux/windows equivalent...
    @H_450_48@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/
    @H_450_48@http://localhost:9000/profiles/projects/

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

    How to setup and configure Sonar for Groovy projects

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:
    @H_925_23@mvn clean install
    @H_450_48@mvn clean install
  2. run the sonar analysis:
    @H_925_23@mvn sonar:sonar
    @H_450_48@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:

    How to setup and configure Sonar for Groovy 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/
    @H_450_48@http://dist.sonar-ide.codehaus.org/eclipse/

    How to setup and configure Sonar for Groovy projects

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

    How to setup and configure Sonar for Groovy projects

    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
    @H_450_48@[INFO] Connected to Sonar 2.8
  5. Right click on your project in the Project explorer,go to Configure > Associate with Sonar:

    How to setup and configure Sonar for Groovy projects

  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

    How to setup and configure Sonar for Groovy projects

  7. Switch over to Sonar View:

    How to setup and configure Sonar for Groovy projects

    How to setup and configure Sonar for Groovy projects

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

大佬总结

以上是大佬教程为你收集整理的How to setup and configure Sonar for Groovy projects全部内容,希望文章能够帮你解决How to setup and configure Sonar for Groovy projects所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。