Quantcast

Need clarification on the Inclusion\exclusion pattern

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Need clarification on the Inclusion\exclusion pattern

Lakshmi
This post was updated on .
Hi,

For few projects in SonarQube4.3, I get the following error -

Filename.java cant be indexed twice. Please check that inclusion\exclusion patterns produce disjoint set for main and test files.

Caused by MojoExecutionException.

How should I resolve the error?



Thanks,
Lakshmi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Julien HENRY
Hi,

What are you version of SQ and SQ Maven plugin?

Are you using standard default or are your overriding sonar.sources and sonar.tests?

Please provide logs of the failing analysis.

++

Julien


2014-07-30 11:02 GMT+02:00 Lakshmi <[hidden email]>:
Hi,

For few projects, I get the following error -

Filename.java cant be indexed twice. Please check that inclusion\exclusion
patterns produce disjoint set for main and test files.

Caused by MojoExecutionException.

How should I resolve the error?







-----
Thanks,
Lakshmi
--
View this message in context: http://sonarqube.15.x6.nabble.com/Need-clarification-on-the-Inclusion-exclusion-pattern-tp5026971.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Lakshmi
Hi Julien,

I'm using SQ V4.3 & SQ Maven plugin v2.3.

I'm using maven analysis for the maven project. So I have added only sonar.sources in pom.xml which will point to the root project directory.

Attached failing analysis. Please check.

AnalysisLog.txt
Thanks,
Lakshmi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Julien HENRY
Hi Lakshmi,

By default Maven plugin will set:
  sonar.sources=src/main/java
  sonar.tests=src/test/java

Since you have overriden sonar.sources to be "." then indeed test files are indexed twice (once as "main" code and once as "test").

If you really need to set sonar.sources=. then you need to also exclude test directory:
sonar.exclusions=src/test/java/**

++

Julien


2014-07-31 5:38 GMT+02:00 Lakshmi <[hidden email]>:
Hi Julien,

I'm using SQ V4.3 & SQ Maven plugin v2.3.

I'm using maven analysis for the maven project. So I have added only
sonar.sources in pom.xml which will point to the root project directory.

Attached failing analysis. Please check.

AnalysisLog.txt
<http://sonarqube.15.x6.nabble.com/file/n5027000/AnalysisLog.txt>



-----
Thanks,
Lakshmi
--
View this message in context: http://sonarqube.15.x6.nabble.com/Need-clarification-on-the-Inclusion-exclusion-pattern-tp5026971p5027000.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Lakshmi
This post was updated on .
Hi Julien,

I tried excluding test folder, it worked. But I want test folder also to be scanned & I'm doing a multi language analysis.
Could you please correct my pom.xml?


 <modelVersion>4.0.0</modelVersion>
  <groupId>com.xyz.com</groupId>
  <artifactId>mytest</artifactId>
  <name>mytest</name>
  <version>1.3</version>
  <packaging>jar</packaging>
 
 <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version> 
        <configuration>
        <source>1.7</source>
        <target>1.7</target>
        </configuration>
        </plugin>
        </plugins>
</build>

        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <sonar.sources>C:\workspace\mytest</sonar.sources>
        </properties>
       
        <prerequisites>
                  <maven>3.0.4</maven>
        </prerequisites> 
Thanks,
Lakshmi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Julien HENRY
Just drop:
2014-07-31 11:00 GMT+02:00 Lakshmi <[hidden email]>:
<sonar.sources>C:\workspace_ICOMPLIANCE\mytest</sonar.sources>

and see how it goes. Using absolute path will not make your project very portable...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Lakshmi
This post was updated on .
Hi Julien,

Dropping the entire sonar.sources tag makes the project build success but I want to analyze multi-language project. JS & JSP files under \mytest\src\main\webapp gets ignored in the scan.

I have found out one way to do multi language scan -

                <sonar.sources>src/main</sonar.sources>
                <sonar.tests>src/test</sonar.tests>

This works perfectly :)

Please do let me know if its not the right approach.
Thanks a lot Julien for spending time.


Thanks,
Lakshmi
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Julien HENRY
Hi,

src/main/webapp should already been automatically added to sonar.sources for war projects. You just have to use latest version of the SQ Maven Plugin.

Other option is to define sonar.sources=src/main/java,src/main/webapp, or sonar.sources=src/main


2014-07-31 12:17 GMT+02:00 Lakshmi <[hidden email]>:
Hi Julien,

Dropping the entire sonar.sources tag makes the project build success but I
want to analyze multi-language project. JS & JSP files under
\mytest\src\main\webapp gets ignored in the scan.

Please suggest how to scan for multi language?




-----
Thanks,
Lakshmi
--
View this message in context: http://sonarqube.15.x6.nabble.com/Need-clarification-on-the-Inclusion-exclusion-pattern-tp5026971p5027021.html
Sent from the SonarQube Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Need clarification on the Inclusion\exclusion pattern

Oleg Majewski
This post has NOT been accepted by the mailing list yet.
In reply to this post by Lakshmi
@Lakshmi
It works for me as well in terms of finding issues in src/main
Buf the code in src/test is not analyzed, so i.e. if I add an unused import to some java Tests class, then it's not found by sonar.

@Julien
if not specifying

<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>

and using sonar-maven-plugin 4.5.1

the sonar analysis finds only java issues from src/main/java, but not javascript issues from src/main/webapp
Loading...