Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please provide compiled classes of your project with sonar.java.binaries

I am struggling with an error with a multi-modules project, the struture is simple, it looks like this :

 root     module a    module b    module c    pom.xml 

After using the maven command line : clean sonar:sonar deploy

I have this error :

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project X : Please provide compiled classes of your project with sonar.java.binaries property -> [Help 1]

EDIT : Here is the structure of my pom.xml

<?xml version="1.0" encoding="UTF-8"?> <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">     <groupId>groupeId</groupId>     <artifactId>artifactId</artifactId>     <version>version</version>     <packaging>pom</packaging>     <name>${project.artifactId}-parent</name>     <description>description</description>     <build>         <plugins>             <plugin>                 <groupId>org.sonarsource.scanner.maven</groupId>                 <artifactId>sonar-maven-plugin</artifactId>                 <version>3.3.0.603</version>             </plugin>         </plugins>     </build>     <modules>         <module>module a</module>         <module>module b</module>         <module>module c</module>     </modules> </project> 
like image 407
CommonPeople Avatar asked Oct 27 '17 13:10

CommonPeople


People also ask

What is sonar Java binaries property?

sonar.java.binaries (required) Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files. sonar.java.libraries. Comma-separated paths to files with third-party libraries (JAR or Zip files) used by your project.

How do I set sonar project properties?

SonarQube Properties and Parameters Global analysis parameters, defined in the UI, apply to all the projects (From the top bar, go to Settings > General Settings) Project analysis parameters, defined in the UI, override global parameters (At a project level, go to Configuration > Settings)

What is sonar used for in Java?

Sonar static analysis helps you build and maintain high-quality Java code. Covering popular build systems, standards and versions, Sonar elevates your coding game while keeping vulnerabilities at bay.

What is sonar scan in Java?

SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages.


1 Answers

You're running your Maven steps in the wrong order:

  • clean - delete all previous build output
  • sonar:sonar - run analysis (which requires build output)
  • deploy - build &etc...

Try this instead:

mvn clean deploy sonar:sonar 

Now if you're about to object that you don't want to actually "deploy" the jar until/unless the changed code passes the Quality Gate, well... that requires a different workflow:

mvn clean package sonar:sonar // check quality gate status // if (qualityGateOk) { deploy } 

The particulars of those last two steps will depend on your CI infrastructure. But for Jenkins, step #2 is well documented

like image 180
G. Ann - SonarSource Team Avatar answered Sep 28 '22 16:09

G. Ann - SonarSource Team