SonarQube 9.6 with Java 17 only analyses pom files for multi module project

Hi,
We have just migrated our code to Java 17 and at the same time updated our sonarqube version to 9.6 (developer), however, when we try to run an analysis the only files that get analyzed are the pom files.

We have multi module project which is structured like this:

bundles
- bundle1
- -src/
- -pom.xml
- bundle2
- -src/ 
- -pom.xml
....
pom.xml

We are using sonar scanner version 3.9.1.2184 and jdk 17.03. The only setting we changed was the following, which is now 17 and was 11.

		<sonar.java.source>17</sonar.java.source>
		<sonar.java.target>17</sonar.java.target>

Besides this setting we don’t use any extra inclusions or exclusions (using default values).

Whenever we run an analyses only the pom files are analysed and the src folder is never indexed, hence never a java analysis is performed. I have tested this with SonarQube version 8.9.9 LTS as well and I get similar results there. When I perform a test on a ‘normal’ maven project, so only a single module with src in its root, it works fine.

Before we used to work with java 11 and sonar scanner 3.6.0.1398 and there everything worked fine. Has something been changed a long the way why this is not working anymore?

Thanks

Hey there.

Can you share the analysis logs for this project (or create a sample project that reproduces the issue, and share the reproducer/logs from your local scan?)

Hi, I assume you mean the following:

 --- sonar-maven-plugin:3.9.1.2184:sonar (default-cli) @ testproject ---
[INFO] SonarQube version: 9.6.0.59041
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] Load global settings
[INFO] Load global settings (done) | time=312ms
[INFO] Server id: AFA536CB-AWwkfEPkrwKXWSttTITq
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=85ms
[INFO] Load/download plugins (done) | time=305ms
[INFO] Loaded core extensions: developer-scanner
[INFO] Process project properties
[INFO] Process project properties (done) | time=59ms
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=4ms
[INFO] Project key: testproject:testproject
[INFO] Base dir: C:\Dev\Workspaces\temp\tesproject
[INFO] Working dir: C:\Dev\Workspaces\temp\tesproject\target\sonar
[INFO] Load project settings for component key: 'testproject:testproject'
[INFO] Load project branches
[INFO] Load project branches (done) | time=7ms
[INFO] Load project pull requests
[INFO] Load project pull requests (done) | time=9ms
[INFO] Load branch configuration
[INFO] Load branch configuration (done) | time=2ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=90ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=1550ms
[INFO] Load analysis cache
[INFO] Load analysis cache (404) | time=7ms
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=6ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO] Indexing files of module 'bundle1'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\bundles\bundle1
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'bundle2'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\bundles\bundle2
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'bundles'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\bundles
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'feature1'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\features\feature1
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'features'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\features
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'configuration'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\releng\configuration
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'repository'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\releng\repository
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'targetplatform'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\releng\targetplatform
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'releng'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject\releng
[INFO]   Source paths: pom.xml
[INFO] Indexing files of module 'testproject'
[INFO]   Base dir: C:\Dev\Workspaces\temp\tesproject
[INFO]   Source paths: pom.xml
[INFO] 10 files indexed
[INFO] 0 files ignored because of scm ignore settings
[INFO] Quality profile for xml: Sonar way
[INFO] ------------- Run sensors on module targetplatform
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=45ms
[INFO] Sensor C# Project Type Information [csharp]
[INFO] Sensor C# Project Type Information [csharp] (done) | time=1ms
[INFO] Sensor C# Analysis Log [csharp]
[INFO] Sensor C# Analysis Log [csharp] (done) | time=15ms
[INFO] Sensor C# Properties [csharp]

Also, attached my configuration pom

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>testproject</groupId>
	<artifactId>configuration</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<packaging>pom</packaging>

	<properties>
		<tycho.version>2.7.4</tycho.version>
		<sonar.version>3.9.1.2184</sonar.version>
		<jacoco.version>0.8.7</jacoco.version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.deploy.skip>true</maven.deploy.skip>
		<sonar.java.source>17</sonar.java.source>
		<sonar.java.target>17</sonar.java.target>
		<sonar.gitlab.only_issue_from_commit_file>true</sonar.gitlab.only_issue_from_commit_file>
		<sonar.gitlab.only_issue_from_commit_line>true</sonar.gitlab.only_issue_from_commit_line>		
		<additionalTestArgLine/>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-maven-plugin</artifactId>
				<version>${tycho.version}</version>
				<extensions>true</extensions>
			</plugin>

			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-surefire-plugin</artifactId>
				<version>${tycho.version}</version>
				<configuration>
					<argLine>-ea ${additionalTestArgLine}</argLine>
					<includes>
						<include>**/Test*.java</include>
					</includes>
				</configuration>
			</plugin>			

			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>target-platform-configuration</artifactId>
				<version>${tycho.version}</version>
				<configuration>
					<target>
						<artifact>
							<groupId>testproject</groupId>
							<artifactId>targetplatform</artifactId>
							<version>${project.version}</version>
						</artifact>
					</target>
					<environments>
						<environment>
							<os>win32</os>
							<ws>win32</ws>
							<arch>x86_64</arch>
						</environment>
					</environments>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-source-plugin</artifactId>
				<version>${tycho.version}</version>
				<executions>
					<execution>
						<id>plugin-source</id>
						<goals>
						    <goal>plugin-source</goal>
						</goals>
					</execution>
				     <execution>
						<id>feature-source</id>
						<goals>
					    	<goal>feature-source</goal>
						</goals>
						<configuration>
							<excludes>
								<!-- provide plug-ins not containing any source code -->
							</excludes>
						</configuration>
					</execution>
				</executions>
			</plugin>			
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-p2-plugin</artifactId>
				<version>${tycho.version}</version>
				<executions>
					<execution>
						<id>attached-p2-metadata</id>
						<phase>package</phase>
						<goals>
							<goal>p2-metadata</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.sonarsource.scanner.maven</groupId>
				<artifactId>sonar-maven-plugin</artifactId>
				<version>${sonar.version}</version>
			</plugin>			
		</plugins>
	</build>


</project>

A quick closing note on this thread.
The sonar:sonar goal has no dependency on tycho build goals, the maven sonar:sonar command did not trigger the needed full build.
maven clean install sonar:sonar was needed to run this project analysis correctly.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.