Skip to content

Add support for Sonarqube 26.1#1189

Merged
mc1arke merged 1 commit intomasterfrom
sq-26_1-compatibility
Feb 1, 2026
Merged

Add support for Sonarqube 26.1#1189
mc1arke merged 1 commit intomasterfrom
sq-26_1-compatibility

Conversation

@mc1arke
Copy link
Copy Markdown
Owner

@mc1arke mc1arke commented Jan 25, 2026

Upgrades the plugin to use Sonarqube 26.1 components. As this version of
Sonarqube requires Java 21, the build image has been upgraded to use
Java 21, and the plugin updated to fix deprecation warnings from the
upgrade and to use Java 21 features.

@mc1arke mc1arke requested a review from Copilot January 25, 2026 12:47
@mc1arke mc1arke force-pushed the sq-26_1-compatibility branch from 4b04d75 to 2afe830 Compare January 25, 2026 12:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the plugin to support Sonarqube 26.1, which requires Java 21. The changes include updating the Java version from 17 to 21 across build configurations, migrating from deprecated org.apache.commons.lang to org.apache.commons.lang3, replacing URL with URI in test code, and modernizing code to use Java 21 features like pattern matching in switch expressions.

Changes:

  • Updated Java version from 17 to 21 in build configurations and CI workflows
  • Migrated from org.apache.commons.lang to org.apache.commons.lang3
  • Modernized Java code to use switch expressions with pattern matching
  • Updated copyright years to 2026 across multiple files

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
build.gradle Updated Sonarqube version to 26.1.0.118079 and Java version to 21
Dockerfile Changed base image from jdk17 to jdk21 and fixed plugin path references
.github/workflows/build.yml Updated Java version matrix and conditions from 17 to 21
.github/workflows/codeql-analysis.yml Updated Java version from 17 to 21
.env Updated Sonarqube and plugin versions
gradle.properties Updated plugin version to 26.1.0-SNAPSHOT
src/main/java/.../BaseFormatterFactory.java Refactored if-else chain to switch expression with pattern matching
src/main/java/.../CommunityBranchLoaderDelegate.java Converted if-else to switch expression for branch type handling
Multiple Java source files Updated imports from org.apache.commons.lang to lang3 and copyright years
src/test/java/.../GithubPullRequestDecoratorTest.java Changed from URL to URI.create().toURL()
sonarqube-webapp-addons/src/branches/ Updated component imports and refactored to use consolidated components
sonarqube-webapp Updated subproject commit reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile
Comment on lines +34 to +35
ENV SONAR_WEB_JAVAADDITIONALOPTS="-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar=web"
ENV SONAR_CE_JAVAADDITIONALOPTS="-javaagent:/opt/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-${PLUGIN_VERSION}.jar=ce"
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The paths have been changed to absolute paths starting with /opt/sonarqube/ instead of relative paths starting with ./. Verify that the working directory during execution is not /opt/sonarqube, as this would make the absolute paths incorrect. If the container runs from a different directory, these absolute paths may fail to locate the plugin JAR.

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +187
<NewCodeDefinitionSpecificGroup
analysis={analysis}
ariaLabelledBy="specific-definition-label"
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ariaLabelledBy prop references an element with id 'specific-definition-label', but no such element is visible in the provided diff. Verify that this id exists in the rendered DOM to ensure proper accessibility.

Copilot uses AI. Check for mistakes.
@hostalp
Copy link
Copy Markdown

hostalp commented Jan 25, 2026

When using this plugin compiled with Java 21, scans executed from Maven at Java 17 fail with:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:4.0.0.4121:sonar (default-cli) on project xyz:
Error creating bean with name 'org.sonarsource.scanner.api.internal.IsolatedClassloader@30ef7b94-org.sonar.scanner.bootstrap.ScannerPluginRepository':
The plugin [communityBranchPlugin] does not support Java 17.0.17: com/github/mc1arke/sonarqube/plugin/CommunityBranchPluginBootstrap has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

E.g. the plugin code directly plays some role in the scanner run and when compiled with Java 21, scanner also needs to run at Java 21. Can this plugin be improved in this regard?

As per SonarSource, Java 17 can be still used at the client side (scanners), it's only deprecated. Only server side requires Java 21 now.
https://community.sonarsource.com/t/sonarqube-community-build-26-1-0-118079-released/172488
https://docs.sonarsource.com/sonarqube-community-build/analyzing-source-code/scanners/scanner-environment/general-requirements#java-runtime-environment-jre

For now I've recompiled the plugin with Java 17 using Sonar server 25.12 libraries as compilation fails with Java 17 & 26.1 server libraries. It works well so far.

@mc1arke
Copy link
Copy Markdown
Owner Author

mc1arke commented Jan 25, 2026

When using this plugin compiled with Java 21, scans executed from Maven at Java 17 fail

Thanks for the feedback. There's nothing in the plugin that requires Java 21, so I'll rollback the Java 21 part of the changes to retain Java 17 for now.

@mc1arke mc1arke force-pushed the sq-26_1-compatibility branch from 2afe830 to 486f253 Compare January 25, 2026 20:19
@feliperodrigorech
Copy link
Copy Markdown

feliperodrigorech commented Jan 29, 2026

I built this repo locally using JDK 21 and copy .jar generated. I updated my compose.yaml, but when I running my pipeline generate this error:

##[error]13:49:12.515  ERROR: Error during SonarScanner Engine execution
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@79d8407f-org.sonar.scanner.scan.ModuleIndexer': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@79d8407f-org.sonar.scanner.scan.filesystem.InputComponentStore': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'BranchConfiguration' defined in org.sonar.scanner.scan.branch.BranchConfigurationProvider: Failed to instantiate [org.sonar.scanner.scan.branch.BranchConfiguration]: Factory method 'provide' threw exception with message: org/apache/commons/lang/StringUtils
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1228)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1130)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:990)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:206)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:143)
	at org.sonar.core.platform.
13:49:12.515  ERROR: Error during SonarScanner Engine execution
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@79d8407f-org.sonar.scanner.scan.ModuleIndexer': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@79d8407f-org.sonar.scanner.scan.filesystem.InputComponentStore': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'BranchConfiguration' defined in org.sonar.scanner.scan.branch.BranchConfigurationProvider: Failed to instantiate [org.sonar.scanner.scan.branch.BranchConfiguration]: Factory method 'provide' threw exception with message: org/apache/commons/lang/StringUtils
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1228)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1130)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:990)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
	at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:206)
	at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:143)
##[error]SpringComponentContainer.startComponents(SpringComponentContainer.java:227)
	at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:206)
	at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:157)
	at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:72)
	at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:56)

	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1770)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1653)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:913)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
	... 36 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonar.scanner.scan.branch.BranchConfiguration]: Factory method 'provide' threw exception with message: org/apache/commons/lang/StringUtils
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:200)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:89)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:169)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 50 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
	at com.github.mc1arke.sonarqube.plugin.scanner.CommunityBranchConfigurationLoader.lambda$load$0(CommunityBranchConfigurationLoader.java:69)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet.lambda$entryConsumer$0(Unknown Source)
	at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntrySetSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.toArray(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.toArray(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.toList(Unknown Source)
	at com.github.mc1arke.sonarqube.plugin.scanner.CommunityBranchConfigurationLoader.load(CommunityBranchConfigurationLoader.java:71)
	at org.sonar.scanner.scan.branch.BranchConfigurationProvider.provide(BranchConfigurationProvider.java:40)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:172)
	... 53 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.net.FactoryURLClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 70 common frames omitted

There are some recommendation?

@mc1arke
Copy link
Copy Markdown
Owner Author

mc1arke commented Jan 29, 2026

The class that's mentioned in the stacktrace has been updated to the lang3 StringUtils, so I wouldn't expect it to be looking for the lang version. Can you check you've cleaned the project fully before your build?
image

@feliperodrigorech
Copy link
Copy Markdown

feliperodrigorech commented Jan 29, 2026

It's working now.

@mc1arke mc1arke force-pushed the sq-26_1-compatibility branch from 486f253 to 1678eba Compare January 29, 2026 18:57
@feliperodrigorech
Copy link
Copy Markdown

I have another question.

I have the same problem this link when running my pipeline.
https://community.sonarsource.com/t/sonarqube-quality-gate-stuck-on-waiting-status/112453

It's limitation by SonarQube or problem with configuration in my devops or limitation this pluging?

Thank you for your attention!

@mc1arke
Copy link
Copy Markdown
Owner Author

mc1arke commented Jan 31, 2026

It's limitation by SonarQube or problem with configuration in my devops or limitation this plugin?

I think this is a problem with your configuration, but without some replication steps I can't confirm that.

@mc1arke mc1arke force-pushed the sq-26_1-compatibility branch 2 times, most recently from 49b4ceb to f4549c0 Compare February 1, 2026 18:39
Upgrades the plugin to use Sonarqube 26.1 back-end and front-end. Whilst
server-side is built using Java 21 for this version of Sonarqube,
scanner-side still support Java 17, so the project is being kept on Java
17 compilation target for now.
@mc1arke mc1arke force-pushed the sq-26_1-compatibility branch from f4549c0 to bc066c4 Compare February 1, 2026 19:41
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Feb 1, 2026

@mc1arke mc1arke merged commit 8692624 into master Feb 1, 2026
15 checks passed
@mc1arke mc1arke deleted the sq-26_1-compatibility branch February 1, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants