Sonar Plugin: Recieving 'package org.sonar.api does not exist'

837 Views Asked by At

I have written a custom plugin to implement some extra checks, but when I restart SonarQube (with the StartSonar.bat file) I get the following error:

java.lang.RuntimeException: Uncompilable source code - package org.sonar.api does not exist

I am using SonarQube version 4.5.5, with the following dependencies and build plugins:

<dependencies>
    <dependency>
        <groupId>org.codehaus.sonar</groupId>
        <artifactId>sonar-plugin-api</artifactId>
        <version>4.5.5</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.codehaus.sonar-plugins.java</groupId>
        <artifactId>sonar-java-plugin</artifactId>
        <type>sonar-plugin</type>
        <version>3.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.codehaus.sonar.sslr</groupId>
        <artifactId>sslr-testing-harness</artifactId>
        <version>1.19.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.sonar</groupId>
            <artifactId>sonar-packaging-maven-plugin</artifactId>
            <version>1.12.1</version>
            <extensions>true</extensions>
            <configuration>
                <pluginClass>
                  (my plugin class)
                </pluginClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <compilerArgs>
                    <arg>-Xlint:all</arg>
                </compilerArgs>
            </configuration>
        </plugin>
    </plugins>
</build>
1

There are 1 best solutions below

0
On BEST ANSWER

The solution was to add the SonarQube parent POM, and change the scope of the sonar plugin API to compile.