Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,20 @@ Exception in thread "main" java.util.ServiceConfigurationError: com.google.error
Caused by: java.lang.IllegalAccessError: class ... (in unnamed module @...) cannot access class com.sun.tools.javac.code.Symbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @...
```

In SonarQube 10.5 the new feature to only download required plugins causes a NoClassDefFoundError. The workaround for this issue is to enable the `sonar.plugins.downloadOnlyRequired` option on the server AND on the analyzer: `-Dsonar.plugins.downloadOnlyRequired=false`

## NullAway configuration

NullAway needs to be configured with the `nullaway.annotated.packages` option, for instance:

```
nullaway.annotated.packages=com.foo,org.bar
```

## Developing the ErrorAway plugin

Running unit and integration tests:

```
mvn verify -Dsonar.server.version=10.5.1.90531 -Dsonar-java.version=7.34.0.35958 -Dsonar.web.port=9001
```
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public static void startOrchestrator() {
.useDefaultAdminCredentialsForBuilds(true)
.addPlugin(FileLocation.of("./target/sonar-erroraway-plugin.jar"))
.keepBundledPlugins()
.setServerProperty("sonar.plugins.downloadOnlyRequired", "true")
.setServerProperty("sonar.plugins.downloadOnlyRequired", "false")
.setOrchestratorProperty("orchestrator.artifactory.url", "https://repo1.maven.org/maven2")
.setServerProperty("sonar.web.port", "9000")
.setServerProperty("sonar.web.port", getSonarWebPort())
.setSonarVersion("LATEST_RELEASE[" + sonarVersion + "]");

ORCHESTRATOR = orchestratorBuilder.build();
Expand All @@ -85,6 +85,10 @@ public static void startOrchestrator() {
ISSUES_SERVICES = new IssuesService(connector);
}

private static String getSonarWebPort() {
return System.getProperty("sonar.web.port", "9000");
}

@AfterAll
public static void stopOrchestrator() {
ORCHESTRATOR.stop();
Expand Down Expand Up @@ -115,31 +119,34 @@ void analyzeSimpleMavenProject() {
.setProperty("sonar.host.url", ORCHESTRATOR.getServer().getUrl())
.setProperty("sonar.login", "admin")
.setProperty("sonar.password", "admin")
.setGoals("clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar");
.setProperty("sonar.web.port", getSonarWebPort())
.setGoals("clean package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.plugins.downloadOnlyRequired=false");

ORCHESTRATOR.executeBuild(build);

checkIssues(SIMPLE_MAVEN_PROJECT_KEY);
}

@Test
void analyzeSimpleGradleProject() {
setupProjectAndProfile(SIMPLE_GRADLE_PROJECT_KEY, "Simple - Gradle");

// Can't seem to set property nullaway.annotated.packages here, so it is set in build.gradle
GradleBuild build = GradleBuild.create()
.setProjectDirectory(FileLocation.of(new File("src/test/resources/projects/simple").getAbsoluteFile()))
.setProperty("sonar.host.url", ORCHESTRATOR.getServer().getUrl())
.setProperty("sonar.login", "admin")
.setProperty("sonar.password", "admin")
.setTasks("clean", "build")
.addArgument("--stacktrace")
.addSonarTask();

ORCHESTRATOR.executeBuild(build);

checkIssues(SIMPLE_GRADLE_PROJECT_KEY);
}
@Test
void analyzeSimpleGradleProject() {
setupProjectAndProfile(SIMPLE_GRADLE_PROJECT_KEY, "Simple - Gradle");

// Can't seem to set property nullaway.annotated.packages here, so it is set in build.gradle
GradleBuild build = GradleBuild.create()
.setProjectDirectory(FileLocation.of(new File("src/test/resources/projects/simple").getAbsoluteFile()))
.setProperty("sonar.host.url", ORCHESTRATOR.getServer().getUrl())
.setProperty("sonar.login", "admin")
.setProperty("sonar.password", "admin")
.setProperty("sonar.web.port", getSonarWebPort())
.setTasks("clean", "build")
.addArgument("--stacktrace")
.addArgument("-Dsonar.plugins.downloadOnlyRequired=false")
.addSonarTask();

ORCHESTRATOR.executeBuild(build);

checkIssues(SIMPLE_GRADLE_PROJECT_KEY);
}

private void checkIssues(String projectKey) {
// Check the issues reported in SonarQube
Expand Down