10

I recently tried to upgrade my Gradle build to SonarQube plugin 2.2 and encountered the following error:

Caused by: java.lang.IllegalStateException: No files nor directories matching '[/opt/bamboo-home/xml-data/build-dir/SPR-SONAR-JOB1/spring-core/build/libs/spring-cglib-repack-3.2.4.jar' in directory /opt/bamboo-home/xml-data/build-dir/SPR-SONAR-JOB1/spring-aop
 org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:302)
 org.sonar.batch.scan.ProjectReactorBuilder.loadChildProject(ProjectReactorBuilder.java:217)
 org.sonar.batch.scan.ProjectReactorBuilder.defineChildren(ProjectReactorBuilder.java:192)
 org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:116)
 org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:120)
 org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:98)
 org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)
 org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
 org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
 org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
 org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
 org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
 org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
 org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
 org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
 org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
 org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.executeOldVersion(BatchIsolatedLauncher.java:70)
 org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
 com.sun.proxy.$Proxy77.executeOldVersion(Unknown Source)
 org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:238)
 org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
 org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:93)

This spring-cglib-repack-3.2.4.jar does exist in the spring-core/build/libs/ folder, since my build is repackaging the cglib dependency in a custom jarjar task.

It seems the plugin is looking for that resource under the spring-aop folder, hence the exception.

Note that the same configuration works with the 2.1 version.

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
  • Same issue here. Have you got any solutions? – alex Nov 09 '16 at 13:51
  • Why is the file missing? From what I understand you are dynamically generating some additional JAR files and add them to the compile classpath. SonarQube need these JARs to perform analysis. The ticket you meantion do the opposite: it filter files that do not exists. So I'm suprised it works with 2.1 and not with 2.2. – Julien H. - SonarSource Team Nov 10 '16 at 13:21
  • Just tested to checkout master. ./gradlew sonarqube works fine. Then updated to 2.2 and still works fine. Looking at folder 'spring-core/build/libs/' the JAR is present. – Julien H. - SonarSource Team Nov 10 '16 at 15:19
  • Let my try again and track down the changes we applied since on our build. Thanks a lot for trying to reproduce the issue! – Brian Clozel Nov 10 '16 at 15:50
  • Just fixed this question as the jar indeed exists. I tried again with jdk8u102 and jdk8u112 and local instances of sonarqube 4.5.6 and 5.2 - still failing with the same exception. Note that this issue happened as well on our public CI. Any idea on how to narrow down the source of the issue? – Brian Clozel Nov 11 '16 at 16:58
  • I run into the error for an **Android** project because the `android-sdk-linux/extras/android/support/` **folder was empty**. I resolved it by manually copying over the folders and files from an internal Jenkins server which had those missing folders and files. – JJD Jan 07 '19 at 15:21

2 Answers2

6

I had to put path to the class files

sonar.java.binaries=target/

sonar-project.properties

Sonar version 6.2

Igor Vuković
  • 742
  • 12
  • 25
  • 1
    Not only did I have to set sonar.java.binaries, but I had to set it to an absolute path in order for it to work. – pacoverflow Apr 12 '17 at 21:33
4

A pull request was submitted to fix this issue. I have created a ticket and will release a bugfix: https://jira.sonarsource.com/browse/SONARGRADL-30

  • Please [don't post identical answers to multiple questions](https://meta.stackexchange.com/q/104227). Post one good answer, then vote/flag to close the other questions as duplicates. If the question is not a duplicate, *tailor your answers to the question*. – Martijn Pieters Nov 15 '16 at 10:09