-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sonar-scanner: Allow overriding JDK #192588
base: master
Are you sure you want to change the base?
Conversation
f8b970d
to
d60b6ef
Compare
Use openjdk@17 instead of latest openjdk for sonar-scanner. JDK 17 is the only officially supported version for the scanner
d60b6ef
to
c67ba56
Compare
Fixed commit style |
Does it not work with a newer version? Homebrew generally does not use the latest version upstream documented, but the latest version that works. |
Hi I have my sonar-scanner break until find this PR. I see a $HOME/.sonar directory that has one JRE. .sonar/cache/003d3e0a65a2f0633b8bfed42be133724b490acb323c174c708d3a446d5fc660/OpenJDK17U-jre_aarch64_mac_hotspot_17.0.11_9.tar.gz_extracted/jdk-17.0.11+9-jre/Contents/Home/bin/java -version /opt/homebrew/opt/openjdk@17/bin/java -version Or, howto use my own external JRE/JDK 17? |
I didn't faced any particular issue. For me it just looked weird to run a non-LTS version of Java for the sonnar-scanner. Related to @cesarjorgemartinez I cannot say. But looking at the bin on I don't know enough homebrew how to manage such dependency. Can java be optional ? I saw also other Formula ussing |
My case for this issue, I have: Yes, I see the same variable inside the script sonar-scanner. I was using this file (/opt/homebrew/bin/sonar-scanner) to locate the JDK used and then, go to the cacerts, copy to one directory, and add my own certificate and use the properties (fastlane):
But now no... Inside the sonar-scanner, download one JRE (maven https://github.com/SonarSource/sonar-scanner-cli/blob/master/pom.xml), put inside $HOME/.sonar and use this JRE. Example in my case:
In short, when launching the Java process, an external version of Java is used, but then for some obscure reason, internally, it uses one downloaded in $HOME/.sonar/cache. The repository is https://github.com/SonarSource/sonar-scanner-cli. I'm also looking at https://github.com/SonarSource/sonar-scanner-cli-docker. Or that it does not use any dependency and that it is the same jar that uses its own JRE... Or, howto do a brew install sonar-scanner as a one concrete version and prevent to build one weird workaround for this issue? |
Hi @jonesbusy, Can you try this?: Doing a: In file https://github.com/SonarSource/sonar-scanner-cli/blob/master/src/main/assembly/bin/sonar-scanner Appear this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can update the test
so that it shows sonar-scanner
erroring out with a Java version that's too new, then we can make this change.
Otherwise, I've provided a suggestion below that will let you use this with your preferred Java runtime.
Formula/s/sonar-scanner.rb
Outdated
@@ -20,7 +20,7 @@ def install | |||
ln_s etc/"sonar-scanner.properties", libexec/"conf/sonar-scanner.properties" | |||
bin.env_script_all_files libexec/"bin/", | |||
SONAR_SCANNER_HOME: libexec, | |||
JAVA_HOME: Formula["openjdk"].opt_prefix | |||
JAVA_HOME: Formula["openjdk@17"].opt_prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should let you use whichever Java version you like by setting JAVA_HOME
:
JAVA_HOME: Formula["openjdk@17"].opt_prefix | |
JAVA_HOME: Language::Java.overridable_java_home_env |
But this requires dropping the change to depends_on
.
Is now
Tested with JAVA_HOME $ sonar-scanner --version
...
16:12:18.176 INFO Java 21.0.4 Eclipse Adoptium (64-bit)
...
$ unset JAVA_HOME
$ sonar-scanner --version
...
16:15:04.380 INFO Java 23 Homebrew (64-bit)
... |
Allow overrding sonar-scanner JDK if JAVA_HOME is set
8d12781
to
b13775f
Compare
Use JDK17 for sonar-scanner which is the only supported version according to https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/scanner-environment/general-requirements/
HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingHOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>
)? If this is a new formula, does it passbrew audit --new <formula>
?Tested all the abose and ensuring correct JDK is used