Uploaded image for project: 'Clover'
  1. Clover
  2. CLOV-331

maven-clover2-plugin incorrectly overwrites non-clover test-jar

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Low Low
    • won't fix
    • None
    • None
    • None
    • 4

      This issue was originally reported in http://forums.atlassian.com/thread.jspa?threadID=27490&tstart=0.
      The following result is seen when performing "mvn clean install clover2:instrument clover2:clover":

      [INFO] Installing <Target_Path>\my-artifact-1.0.0-SNAPSHOT-tests.jar to <Repository_Path>\my-artifact\1.0.0-SNAPSHOT\my-artifact-1.0.0-SNAPSHOT-tests.jar
      [INFO] Installing <Target_Path>\clover\my-artifact-1.0.0-SNAPSHOT-clover-tests.jar to <Repository_Path>\my-artifact\1.0.0-SNAPSHOT\my-artifact-1.0.0-SNAPSHOT-tests.jar
      

      The Clover test jar overwrites the non-Clover test jar that is copied to the repository earlier.

            [CLOV-331] maven-clover2-plugin incorrectly overwrites non-clover test-jar

            Update: the repository pollution protection feature introduced in Clover-for-Maven 4.0.4 can partially protect against multiple classifiers (CLOV-1632).

            Marek Parfianowicz added a comment - Update: the repository pollution protection feature introduced in Clover-for-Maven 4.0.4 can partially protect against multiple classifiers ( CLOV-1632 ).

            Switching from clover2:instrument to clover2:setup works for my situation because it avoids installing the artifacts to the local repo. Thanks for your help.

            Thomas Boettcher added a comment - Switching from clover2:instrument to clover2:setup works for my situation because it avoids installing the artifacts to the local repo. Thanks for your help.

            Nick added a comment -

            Hi Thomas,

            Maven doesn't support doubly classified artifacts.

            You can use clover2:setup however, instead of clover2:instrument.
            clover2:setup will not add the clover classifier, so it should work with classified artifacts.

            ie: clover2:setup test clover2:clover.

            Cheers,
            Nick

            Nick added a comment - Hi Thomas, Maven doesn't support doubly classified artifacts. You can use clover2:setup however, instead of clover2:instrument. clover2:setup will not add the clover classifier, so it should work with classified artifacts. ie: clover2:setup test clover2:clover. Cheers, Nick

            So, just to be clear, Clover does not and will not support artifacts that have a classifier?

            Thomas Boettcher added a comment - So, just to be clear, Clover does not and will not support artifacts that have a classifier?

            Nick added a comment - - edited

            Unfortunately, Maven does not support artifacts that have multiple classifiers.
            In this case, there is a -test classifier on the artifact, and then Clover adds its own -clover classifier.

            If the <Target_Path>\my-artifact-1.0.0-SNAPSHOT-tests.jar, were not a classified artifact, then this problem would not exist.

            The work around is to put any tests that need to be shared across projects (ie installed) in a separate module, and not have maven use a -classifier on them.
            Before doing this however, you should consider the need to install a -test.jar into a maven repository at all.

            If you can use the tests that are already compiled in the reactor, this issue should also go away. One way to do this is to use the dependency:unpack-dependencies goal, on the maven-dependency-plugin. It will copy a dependency from the maven reactor to a given location. If it is not in the reactor, then the dependency is looked for in a repository. The same goes for copy-dependencies.

            Another solution is to tell Clover to not instrument your test sources. This will mean however that no test results nor per-test coverage will be available in the Clover HTML reports. This can be set using the includeTestSourceRoots configuration.

            Nick added a comment - - edited Unfortunately, Maven does not support artifacts that have multiple classifiers. In this case, there is a -test classifier on the artifact, and then Clover adds its own -clover classifier. If the <Target_Path>\my-artifact-1.0.0-SNAPSHOT-tests.jar, were not a classified artifact, then this problem would not exist. The work around is to put any tests that need to be shared across projects (ie installed) in a separate module, and not have maven use a -classifier on them. Before doing this however, you should consider the need to install a -test.jar into a maven repository at all. If you can use the tests that are already compiled in the reactor, this issue should also go away. One way to do this is to use the dependency:unpack-dependencies goal, on the maven-dependency-plugin. It will copy a dependency from the maven reactor to a given location. If it is not in the reactor, then the dependency is looked for in a repository. The same goes for copy-dependencies. Another solution is to tell Clover to not instrument your test sources. This will mean however that no test results nor per-test coverage will be available in the Clover HTML reports. This can be set using the includeTestSourceRoots configuration.

            Is a fix in the work for this? I too have been affected by this issue.

            Brian Relph added a comment - Is a fix in the work for this? I too have been affected by this issue.

              mparfianowicz Marek Parfianowicz
              tcheah Tony Cheah Tong Nyee [Atlassian]
              Affected customers:
              4 This affects my team
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: