Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6716

relative testSourceDirectory on macos throw duplicate class error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.1
    • Fix Version/s: 3.6.2
    • Component/s: core, POM
    • Labels:
      None
    • Environment:
      MacOS Sierra 10.12.6
      mvn 3.6.1

      Description

      With custom folder structure where test source folder is not sharing the same parent folder as source folder, for example (is just a sample structure itself is not the key point):

      ws/bug-macos-tstsrc-relative-path-src/src/main/java
      ws/bug-macos-tstsrc-relative-path-tst/src
      
      

      With following pom.xml customization

      <testSourceDirectory>../bug-macos-tstsrc-relative-path-tst/src</testSourceDirectory> 

      On <= 3.6.0 everything works but until 3.6.1 MacOS (I'm not able to reproduce on Docker container maven:3.6.1), I have the following error:

      AppTest.java:[10,8] duplicate class: dev.thibaud.AppTest

      And if I check with -X I saw 2 paths added instead of 1

      [DEBUG] Source roots:
       [DEBUG]  /private/tmp/mvntest/ws/bug-macos-tstsrc-relative-path-src/../bug-macos-tstsrc-relative-path-tst/src
       [DEBUG]  /private/tmp/mvntest/ws/bug-macos-tstsrc-relative-path-tst/src

      How to reproduce:

      #!/usr/bin/env bash
      
      readonly SRC_FOLDER="bug-macos-tstsrc-relative-path-src"
      readonly TST_FOLDER="bug-macos-tstsrc-relative-path-tst"
      
      mkdir -p ws
      cd ws/
      mvn archetype:generate -DgroupId=dev.thibaud -DartifactId=${SRC_FOLDER} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
      mkdir -p ${TST_FOLDER}/src/
      mv ${SRC_FOLDER}/src/test/java/* ${TST_FOLDER}/src/
      rm -fr ${SRC_FOLDER}/src/test
      cat <<EOT > ${SRC_FOLDER}/pom.xml
      <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/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>dev.thibaud</groupId>
        <artifactId>bug-macos-tstsrcrelative-path</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>bug-macos-tstsrcrelative-path</name>
        <url>http://maven.apache.org</url>
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
          </dependency>
        </dependencies>
        <build>
            <testSourceDirectory>../${TST_FOLDER}/src</testSourceDirectory>
        </build>
      </project>
      EOT

      Then simply run

      mvn -f bug-macos-tstsrc-relative-path-src/pom.xml clean test -X

      Workaround:

      is not using relative path by editing

      <testSourceDirectory>../bug-macos-tstsrc-relative-path-tst/src</testSourceDirectory>

      to

      <testSourceDirectory>${project.basedir}/../bug-macos-tstsrc-relative-path-tst/src</testSourceDirectory>

       

       PS: maybe affect sourceDirectory but no tested

        Attachments

        1. image-2019-07-30-12-27-38-526.png
          136 kB
          Thibaud Lepretre
        2. image-2019-07-30-12-26-50-201.png
          125 kB
          Thibaud Lepretre

          Issue Links

            Activity

              People

              • Assignee:
                eolivelli Enrico Olivelli
                Reporter:
                kakawait Thibaud Lepretre
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m