anromer
anromer

Reputation: 626

java.lang.ClassNotFoundException: org.sonar.java.model.JavaTree "dependency issue creating a sonar plugin"

I'm creating a plugin to add some custom rules. To start, my work is based on: /sonar-examples/plugins/java-custom-rules. This sample works very well and some rules I have created too.

I have a problem trying to create a rule based on UnusedPrivateFieldCheck.java version 2.1. sonarRunner fails with the following message:

java.lang.ClassNotFoundException: org.sonar.java.model.JavaTree

The line that fails is:

AstNode identifierAstNode = ((JavaTree) tree).getAstNode().getFirstChild(JavaTokenType.IDENTIFIER);

In rule version 2.3 JavaTree is not used, but unfortunately the sonar version 4.3.2 works with version 2.1

Is the JavaTree class accessible from plugin classpath sharing? Is there a special configuration? Is something missing at my pom.xml? Must I wait until version 2.3?

Upvotes: 1

Views: 449

Answers (1)

benzonico
benzonico

Reputation: 10833

JavaTree is not part of the org.sonar.plugins.java.api and is therefore not accessible from plugin classpath sharing to implement your own rules.

This class is intended for internal uses only.

Upvotes: 1

Related Questions