Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-2444

DuplicatedSourceException when using package-info.java file in source package and test package of same name

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 3.3
    • Component/s: Batch Analysis, Unit Test
    • Labels:
      None
    • Environment:
      Linux, Java 6, Maven 2

      Description

      In our Java project, we have in src/main/java a package x.y.z that contains a file 'package-info.java' for Java doc purposes.
      There's also a package x.y.z (i.e. of same name) in src/test/java which contains the related tests. There's also a file 'package-info.java' there.

      After doing a 'mvn clean install', running 'mvn sonar:sonar' with version 2.4.1 of the Sonar Maven Plugin worked fine for this project.
      However, we have upgraded to version 2.7, and now we get

      org.sonar.api.resources.DuplicatedSourceException: x.y.z.package-info
      at org.sonar.batch.index.SourcePersister.saveSource(SourcePersister.java:45)

      (see attachment for full stacktrace) on 'mvn sonar:sonar' when the 'Sensor JavaSourceImporter' runs.

      Where's the problem here?

        Issue Links

          Activity

          Hide
          prassu21 Prasanna R added a comment -

          I agree that there isn't any good reason to have some fully duplicated java source files in a project. But considering multi-module projects there is a possibility of having duplicate file names. Defining a property should definitely help multi module project configurations..

          Show
          prassu21 Prasanna R added a comment - I agree that there isn't any good reason to have some fully duplicated java source files in a project. But considering multi-module projects there is a possibility of having duplicate file names. Defining a property should definitely help multi module project configurations..
          Hide
          flefevre Francois Le Fevre added a comment -

          Dear all,
          I am also facing exactly the same problem of with the generation of code with jaxb2 from xml schema.
          I hope this bug will be solved.
          I didn't understand everything but it seems you have well restricted the bug area.

          Show
          flefevre Francois Le Fevre added a comment - Dear all, I am also facing exactly the same problem of with the generation of code with jaxb2 from xml schema. I hope this bug will be solved. I didn't understand everything but it seems you have well restricted the bug area.
          Hide
          freddy.mallet Freddy Mallet added a comment -

          With help of SONAR-3758, we'll be able to define an exclusion filter in order to not import package-info.java files located in the test source directory.

          Show
          freddy.mallet Freddy Mallet added a comment - With help of SONAR-3758 , we'll be able to define an exclusion filter in order to not import package-info.java files located in the test source directory.
          Hide
          freddy.mallet Freddy Mallet added a comment -

          Manually tested !

          Show
          freddy.mallet Freddy Mallet added a comment - Manually tested !
          Hide
          dgageot David Gageot added a comment -

          IT added

          Show
          dgageot David Gageot added a comment - IT added

            People

            • Assignee:
              dgageot David Gageot
              Reporter:
              mpscholz Matthias Paul Scholz
            • Votes:
              7 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: