We cannot load our custom built sonar plugins for java

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

Hi,

We have upgraded to SonarQube CE 9.9 LTS. ( We used 8.9 before).
We try to deploy a new version of our custom plugin in /opt/sonarqube/extensions/plugins but sonarqube fails to start and if I check the web.log I can see the below.

2023.05.17 13:26:22 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 8080
2023.05.17 13:26:22 INFO  web[][o.s.p.ProcessEntryPoint] Hard stopping process
2023.05.17 16:57:29 INFO  web[][o.s.p.ProcessEntryPoint] Starting Web Server
2023.05.17 16:57:30 INFO  web[][o.s.s.p.LogServerVersion] SonarQube Server / 9.9.0.65466 / ce743843018827cb30c05735e7971523de34bb48
2023.05.17 16:57:30 INFO  web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://localhost/sonarqubedb
2023.05.17 16:57:30 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Starting...
2023.05.17 16:57:30 INFO  web[][c.z.h.p.HikariPool] HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@1d96d872
2023.05.17 16:57:30 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Start completed.
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
2023.05.17 16:57:32 INFO  web[][o.s.s.u.SystemPasscodeImpl] System authentication by passcode is disabled
2023.05.17 16:57:32 INFO  web[][o.s.c.e.CoreExtensionsLoader] Loaded core extensions: Community Branch Plugin
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy C# Code Quality and Security / 8.51.0.59060 / e14c642f118958f22fd08841dc42f9aae480366a
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Community Branch Plugin / 1.14.0 / null
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Configuration detection fot Code Quality and Security / 1.2.0.267 / 4f37ba9ffb37a96d5883e52ad392ed32c5c6eaab
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Findbugs / 4.0.5 /
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Flex Code Quality and Security / 2.8.0.3166 / 01f66bdddc678966c81a9064ed139156a6a89c97
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Go Code Quality and Security / 1.11.0.3905 / e1f28bc000e04ca01881e84218d01d464a17a36f
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy HTML Code Quality and Security / 3.7.1.3306 / d720acc6860c6d8b69ec4d17570a398a1e216da1
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy IaC Code Quality and Security / 1.11.0.2847 / 6892bd3a7320b3c110717acfdb18c4c7451069fd
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy JaCoCo / 1.3.0.1538 / 74a7798c7cea687c72ed9df40c93eb7ea2a58c49
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Java Code Quality and Security / 7.16.0.30901 / 4b1436558dfd5fc00c8d9aae8bb0364ba122c73e
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Java MJE Custom Rules / 0.0.145-20230517145602447-GERRIT-SNAPSHOT / null
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy JavaScript/TypeScript/CSS Code Quality and Security / 9.13.0.20537 / 68ff7657415044b86033814795ed95fc1f1558f1
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Kotlin Code Quality and Security / 2.12.0.1956 / a6df1ae252bd62d63f8673c28f87ad14258a7904
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy PHP Code Quality and Security / 3.27.1.9352 / 3ddc5a03e1a7e3729d41e7c1a30a37d5715958c7
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy PMD / 3.3.1 / 4ec086ca65e1b0d5581c93da8844c250eda3f44f
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Python Code Quality and Security / 3.24.0.10784 / 30aa413d983f6c37b4298eba00555c3050009b52
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy RCS EE Custom JAVA Rules / 1.0.1-SNAPSHOT / null
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Ruby Code Quality and Security / 1.11.0.3905 / e1f28bc000e04ca01881e84218d01d464a17a36f
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Scala Code Quality and Security / 1.11.0.3905 / e1f28bc000e04ca01881e84218d01d464a17a36f
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy Text Code Quality and Security / 2.0.1.611 / 53bfe3a68ae3886520d6a5c1c21dfdb564821ea1
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy VB.NET Code Quality and Security / 8.51.0.59060 / e14c642f118958f22fd08841dc42f9aae480366a
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy XML Code Quality and Security / 2.7.0.3820 / 656bccc1910d50c8984536bd2dfd917066b858e6
2023.05.17 16:57:32 INFO  web[][o.s.s.p.ServerPluginManager] Deploy YAML Analyzer / 1.7.0 / null
2023.05.17 16:57:33 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7-org.sonar.server.plugins.ServerPluginManager': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to instantiate class [com.company.rcsee.sonar.java.JavaRulesPlugin] of plugin [rcseecustomjavarules]
2023.05.17 16:57:33 ERROR web[][o.s.s.p.PlatformImpl] Web server startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7-org.sonar.server.plugins.ServerPluginManager': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to instantiate class [com.company.rcsee.sonar.java.JavaRulesPlugin] of plugin [rcseecustomjavarules]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)

In the project where we build the custom plugin we have the following in our pom.xml

 <java.plugin.version>7.17.0.31219</java.plugin.version>
        <junit.version>4.11</junit.version>
        <logback.classic.version>0.9.30</logback.classic.version>
        <slf4j.api.version>1.7.30</slf4j.api.version>
        <sonar.version>9.14.0.375</sonar.version>
        <sonar.packaging.maven.plugin.version>1.21.0.505</sonar.packaging.maven.plugin.version>
        <sslr.version>1.21</sslr.version>
        <sslr.squid.bridge.version>2.6.1</sslr.squid.bridge.version>

and this:

<build>
        <plugins>
            <plugin>
                <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
                <artifactId>sonar-packaging-maven-plugin</artifactId>
                <version>${sonar.packaging.maven.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <pluginKey>java-mje-custom-rules</pluginKey>
                    <pluginName>Java MJE Custom Rules</pluginName>
                    <pluginClass>com.ericsson.msran.sonarqube.java.JavaCustomRulesPlugin</pluginClass>
                    <skipDependenciesPackaging>true</skipDependenciesPackaging>
                    <sonarLintSupported>true</sonarLintSupported>
                    <!-- allow to depend on API 6.x but run on LTS -->
                    <sonarQubeMinVersion>8.9</sonarQubeMinVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

What are we missing when we get this exception?`

br,

//mike

Hi,

Is there any more to that stacktrace?

 
Ann

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7-org.sonar.server.plugins.ServerPluginManager': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Unable to read plugin manifest from jar : /opt/sonarqube/extensions/plugins/our-custom-plugin-0.0.145-20230502122925959-GERRIT-SNAPSHOT.jar
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
        at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
        at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:103)
        at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:196)
        at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:169)
        at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:77)
        at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4764)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5222)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486)
        at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)
        at org.sonar.server.app.WebServer.start(WebServer.java:55)
        at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)
       at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)
        at org.sonar.server.app.WebServer.main(WebServer.java:104)
Caused by: java.lang.IllegalStateException: Unable to read plugin manifest from jar : /opt/sonarqube/extensions/plugins/our-custom-plugin-0.0.145-20230502122925959-GERRIT-SNAPSHOT.jar
        at org.sonar.updatecenter.common.PluginManifest.<init>(PluginManifest.java:125)
        at org.sonar.server.plugins.ServerPluginInfo.create(ServerPluginInfo.java:38)
        at org.sonar.server.plugins.PluginJarLoader.lambda$getExternalPluginsMetadata$5(PluginJarLoader.java:151)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
        at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
        at org.sonar.server.plugins.PluginJarLoader.loadPluginsFromDir(PluginJarLoader.java:181)
        at org.sonar.server.plugins.PluginJarLoader.getExternalPluginsMetadata(PluginJarLoader.java:151)
        at org.sonar.server.plugins.PluginJarLoader.loadPlugins(PluginJarLoader.java:89)
        at org.sonar.server.plugins.ServerPluginManager.start(ServerPluginManager.java:63)
        at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
        ... 44 common frames omitted
Caused by: java.util.zip.ZipException: zip END header not found
        at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1469)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1477)
        at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1277)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:347)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:318)
        at java.base/java.util.jar.JarFile.<init>(JarFile.java:284)
        at org.sonar.updatecenter.common.PluginManifest.<init>(PluginManifest.java:120)
        ... 63 common frames omitted
2023.05.17 06:27:03 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...
2023.05.17 06:27:03 INFO  web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.
2023.05.17 06:27:03 INFO  web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 8080

@ganncamp the file was corrupted. Now that I try to load the same plugin we get a different error. I checked web.log file.

2023.05.26 07:36:43 WARN  web[][o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
2023.05.26 07:36:43 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@251a69d7-org.sonar.server.rule.RegisterRules': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
        at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
        at org.sonar.server.platform.platformlevel.PlatformLevelStartup.access$001(PlatformLevelStartup.java:55)
        at org.sonar.server.platform.platformlevel.PlatformLevelStartup$1.doPrivileged(PlatformLevelStartup.java:127)
        at org.sonar.server.user.DoPrivileged.execute(DoPrivileged.java:45)
        at org.sonar.server.platform.platformlevel.PlatformLevelStartup.start(PlatformLevelStartup.java:124)
        at org.sonar.server.platform.PlatformImpl.executeStartupTasks(PlatformImpl.java:183)
        at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.runIfNotAborted(PlatformImpl.java:344)
        at org.sonar.server.platform.PlatformImpl$1.doRun(PlatformImpl.java:107)
        at org.sonar.server.platform.PlatformImpl$AutoStarterRunnable.run(PlatformImpl.java:328)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList
        at com.company.msran.sonarqube.java.JavaCustomRulesList.getJavaChecks(JavaCustomRulesList.java:16)
        at com.company.msran.sonarqube.java.JavaCustomRulesDefinition.define(JavaCustomRulesDefinition.java:28)
        at org.sonar.server.rule.RuleDefinitionsLoader.load(RuleDefinitionsLoader.java:56)
        at org.sonar.server.rule.RegisterRules.start(RegisterRules.java:125)
        at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
        ... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList
        at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
        at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
        at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
        ... 27 common frames omitted

Hello Mikael,

As the error states, a dependency can not be loaded:

Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList

The class loader will not load those dependencies automatically as you would expect. I found that the easiest way to get around this is to simply include the dependencies in the plugin jar itself. You can do that with maven-shade-plugin.

1 Like

@Hendrik_Buchwald so there has been some changes since this has been working in older versions of SQ?

We use the following in out plugin pom.xml

 <build>
        <plugins>
            <plugin>
                <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
                <artifactId>sonar-packaging-maven-plugin</artifactId>
                <version>${sonar.packaging.maven.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <pluginKey>java-mje-custom-rules</pluginKey>
                    <pluginName>Java MJE Custom Rules</pluginName>
                    <pluginClass>com.company.msran.sonarqube.java.JavaCustomRulesPlugin</pluginClass>
                    <sonarLintSupported>true</sonarLintSupported>
                    <!-- allow to depend on API 6.x but run on LTS -->
                    <sonarQubeMinVersion>5.8</sonarQubeMinVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Do we need to change it?

br,

//mikael

I am not aware of any changes in that regard but then again, I am also not involved in that part of development at all. I will ping the responsible team, they will be of better help with this.

If I would have to guess, maybe we just used to include that module by default and don’t do that anymore. But that is really just a guess.

1 Like

Hello Mikael,

As we have not heard from you in the meantime, have you been able to make it work?

As Hendrik already indicated, you will need to package the Guava dependency in your plugin jar file if you want to use it. The Java analyzer previously used Guava, however, we have removed this dependency in the meantime, as newer Java versions provide a more convenient collection API. So you cannot rely on it being in the classpath anymore.

1 Like