Calling Sonar from my java program

♀尐吖头ヾ 提交于 2019-12-04 13:55:55

There are 2 things you can do from a Java program:

  • launch a Sonar analysis: look into the Sonar Ant Task (in method #launchAnalysis) to see how to do that very easily.

  • retrieve results from the Sonar server: check the Web API for that purpose

Mário Gomes

About the " java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpRequestBase" you need this dependencies (Sonar WS uses them)

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.1</version>
</dependency>

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
</dependency>


<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>jcl-over-slf4j</artifactId>
  <version>1.7.7</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.6.2</version>
</dependency>

Also, I'd recommend when using Eclipse IDE, update maven project and check force update of snapshots/releases, because somehow org.apache.httpclient wasn't being able to be recognized by classpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!