0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SonarQubeを実行したときに出会ったエラー

Last updated at Posted at 2023-03-07

https://docs.sonarsource.com/sonarqube/9.9/try-out-sonarqube/
を参照して、ローカルにソナーキューブを構築・実行した。

C:\Program Files\sonarqube-9.9.7.96285\bin\windows-x86-64>StartSonar.bat
Starting SonarQube...
Unrecognized option: --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Java17はインストール済みのはずと思っていたが、Pathの環境変数の順番でJava8が優先されていて、起動できていなかった。
Java17が通るように修正して、解決。


https://docs.sonarqube.org/9.6/try-out-sonarqube/
を参照して、ローカルにソナーキューブを構築・実行した。

Execute the Scanner
Running a SonarQube analiysis is straighforward. You just need to execute the following commands in your project's folder.
sonar-scanner.bat -D"sonar.projectKey=My_Trial" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000" -D"sonar.login=xxxxx"

とのことだったので、表示されているコマンドをプロジェクトのディレクトリ配下から実行したところ下記のエラーが発生。

ERROR: Error during SonarScanner execution
org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.

classファイルよこせや。ということの様なので、classファイルが出力されているディレクトリ直下に移動してから再実行。
コマンド自体は成功したものの、結果を確認すると何も出力されていなかった。

The main branch has no lines of code.

classファイルが出力されているディレクトリに移動して実行ではなく、
classファイルが出力されているディレクトリ「sonar.java.binaries」で指定し実行して解決。

以下の様な感じで、引数に追加

sonar-scanner.bat -D"sonar.projectKey=My_Trial" -D"sonar.sources=." -D"sonar.host.url=http://localhost:9000" -D"sonar.login=xxxxx" -D"sonar.java.binaries=bin" 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?