Scan all class except for mvn generate:sources

sonarlint

(Fanny Tan) #1

Hi,

I am using SonarLint on eclipse and intelliJ. When I scan my source code, it also scan mvn generate:sources. Is there a way to scan all class except for mvn generate:sources?


(Duarte Meneses) #2

Hi,

I’m not sure what you mean.
What SonarLint analyses are the source code files (.java) but it will give more precise results if class files (bytecode) are present. These class files are found in the IDE’s output folder. Maven usually compiles the classes to a different location so it shouldn’t change anything.
Maybe I didn’t understand your question, in which case could you please reformulate it?


(Fanny Tan) #3

Hello,

Sorry for the delayed response. mvn generate:sources are classes generated automatically by maven. Format of this generated class is [className]_.java


(Fanny Tan) #4

Here is an example I got from my developer,

package org.osiam.storage.entities;

import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;

@Generated(value = “org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor”)
@StaticMetamodel(ActivityLogEntity.class)
public abstract class ActivityLogEntity_ extends org.osiam.storage.entities.ResourceEntity_ {

public static volatile SingularAttribute<ActivityLogEntity, String> request;
public static volatile SingularAttribute<ActivityLogEntity, Boolean> isLatest;
public static volatile SingularAttribute<ActivityLogEntity, String> referenceNumber;
public static volatile SingularAttribute<ActivityLogEntity, String> response;
public static volatile SingularAttribute<ActivityLogEntity, String> action;
public static volatile SingularAttribute<ActivityLogEntity, String> description;
public static volatile SingularAttribute<ActivityLogEntity, String> menuName;
public static volatile SingularAttribute<ActivityLogEntity, String> detail;
public static volatile SingularAttribute<ActivityLogEntity, String> userName;
public static volatile SingularAttribute<ActivityLogEntity, String> status;

}


(Duarte Meneses) #5

Hi,

The SonarQube Scanner for Maven will analyze all the source code that is configured in Maven, during the execution of the goal ‘sonar:sonar’.
Often this set of sources gets dynamically modified during the execution of a certain goal.
Because of this, and also for other reasons such as getting the generated test reports, it is usually recommended to run sonar:sonar after compilation/tests goal (in the same mvn command).
If that doesn’t work, you can manually set the property sonar.sources in your pom file.