I am trying to execute a sonar task from java. Below is my code that I am executing..
@Override
public void execute() {
Properties allProps = new Properties();
InputStream in;
try {
in = new FileInputStream(new File(getProjectBaseDir()+"\\"+SONAR_PROPERTY_FILE_NAME));
allProps.load(in);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
performAnalysis(allProps);
}
void performAnalysis(Properties properties) {
EmbeddedRunner.create()
.addProperties(properties)
.unmask("org.apache.tools.ant")
.unmask("org.sonar.ant")
.execute();
}
When it executes, it throws an Exception:
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at com.ihc.sonarApp.SonarTask.launchAnalysis(SonarTask.java:86)
at com.ihc.sonarApp.SonarTask.execute(SonarTask.java:76)
at com.ihc.sonar.util.Task.run(Task.java:81)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: You must install a plugin that supports the language 'Java'
I have added these jar's in the buildpath: apache-ant-1.8.2.jar, sonar-ant-task-2.3.jar, sonar-java-plugin-3.0.jar and sonar-scm-svn-plugin-1.0.jar.
I can access the sonar at localhost:9000.
What am I doing wrong? Is there anthing a setup or jar that I am missing.