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

Plugin Ignoring Dependency Exclusions building surefire.test.class.path

    • Icon: Bug Bug
    • Resolution: Unsolved Mysteries
    • Icon: Medium Medium
    • won't fix
    • 2.3.2
    • Maven plugin
    • None
    • jdk 1.5, Maven 2.0.9

      My tests were working fine when not using Clover. As soon as I added the clover goals to Maven (clover2:instrument clover2:aggregate clover2:clover) my tests started to fail. I looked at the surefire.test.class.path property and it had all of the jars I had excluded. All of the dependencies and transitive dependencies of org.apache.cxf cxf-bundle showed up in the surefire classpath. When NOT using Clover the surefire classpath did NOT have these jars included in it.

      <dependency>
      <groupId>mygroup</groupId>
      <artifactId>myartifact</artifactId>
      <version>${project.version}</version>
      <exclusions>
      <exclusion>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-bundle</artifactId>
      </exclusion>
      </exclusions>
      </dependency>

      I might have tracked down the bug...in CloverInstrumentInternalMojo.java.

      It looks like the dependencies are grabbed from the project to build the compile classpath without regard for exclusions...

      Set set = new HashSet( getProject().getDependencyArtifacts() );

      private void addCloverDependencyToCompileClasspath()
      throws MojoExecutionException
      {
      Artifact cloverArtifact = findCloverArtifact( this.pluginArtifacts );
      if ( cloverArtifact == null )

      { throw new MojoExecutionException( "Couldn't find com.cenqua.clover:clover artifact in plugin dependencies" ); }

      cloverArtifact = artifactFactory.createArtifact( cloverArtifact.getGroupId(), cloverArtifact.getArtifactId(),
      cloverArtifact.getVersion(), Artifact.SCOPE_COMPILE, cloverArtifact.getType() );

      // TODO: use addArtifacts when it's implemented, see http://jira.codehaus.org/browse/MNG-2197
      Set set = new HashSet( getProject().getDependencyArtifacts() );
      set.add( cloverArtifact );
      getProject().setDependencyArtifacts( set );
      }

          Form Name

            [CLOV-310] Plugin Ignoring Dependency Exclusions building surefire.test.class.path

            Nick added a comment -

            I have no doubt that this was indeed a problem - however will close for now, until we can get reproduce this consistently.

            Possibly an upgrade from maven 2.0.8 to maven 2.0.9 fixed this problem.

            Nick added a comment - I have no doubt that this was indeed a problem - however will close for now, until we can get reproduce this consistently. Possibly an upgrade from maven 2.0.8 to maven 2.0.9 fixed this problem.

            Well...after trying for about an hour the classpaths (clover/non-clover) match up.

            My environment has changed a lot since I posted this so I don't know how it is miraculously fixed

            Maybe David can provide an example.

            Sorry.

            Franz

            Franz Garsombke added a comment - Well...after trying for about an hour the classpaths (clover/non-clover) match up. My environment has changed a lot since I posted this so I don't know how it is miraculously fixed Maybe David can provide an example. Sorry. Franz

            Well...after trying for about an hour the classpaths (clover/non-clover) match up.

            My environment has changed a lot since I posted this so I don't know how it is miraculously fixed

            Maybe David can provide an example.

            Sorry.

            Franz

            Franz Garsombke added a comment - Well...after trying for about an hour the classpaths (clover/non-clover) match up. My environment has changed a lot since I posted this so I don't know how it is miraculously fixed Maybe David can provide an example. Sorry. Franz

            Nick -

            I will generate this and send it off.

            Thanks for helping.

            Franz

            Franz Garsombke added a comment - Nick - I will generate this and send it off. Thanks for helping. Franz

            Nick added a comment -

            Hi Franz,

            After some further investigation - I can not reproduce the problem you are seeing.
            I set up a sample project, which added org.apache.ant:ant:1.7.1 as a dependency excluding the ant-launcher artifact:

                    <dependency>
                        <groupId>org.apache.ant</groupId>
                        <artifactId>ant</artifactId>
                        <version>1.7.1</version>
                        <exclusions>
                            <exclusion>
                                <groupId>org.apache.ant</groupId>
                                <artifactId>ant-launcher</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
            

            When I then run mvn clover2:instrument, the classPath for the maven-surefire-plugin (I also checked the maven-compiler-plugin) doesn't include ant-launcher.

            [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test' -->
            [DEBUG]   (f) basedir = /work/mvnclvr/src/it/optmized/module-a
            [DEBUG]   (f) childDelegation = false
            [DEBUG]   (f) classesDirectory = /work/mvnclvr/src/it/optmized/module-a/target/clover/classes
            [DEBUG]   (f) classpathElements = [/work/mvnclvr/src/it/optmized/module-a/target/clover/test-classes, /work/mvnclvr/src/it/optmized/module-a/target/clover/classes, /.m2/repository/com/cenqua/clover/clover/2.3.3-SNAPSHOT/clover-2.3.3-SNAPSHOT.jar, /.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar, /.m2/repository/org/apache/ant/ant/1.7.1/ant-1.7.1.jar]
            

            Could you please provide the output when you run maven with the -X command and/or supply a small example pom.xml which will reproduce the problem you are having.

            Best Regards,
            Nick Pellow

            Nick added a comment - Hi Franz, After some further investigation - I can not reproduce the problem you are seeing. I set up a sample project, which added org.apache.ant:ant:1.7.1 as a dependency excluding the ant-launcher artifact: <dependency> <groupId> org.apache.ant </groupId> <artifactId> ant </artifactId> <version> 1.7.1 </version> <exclusions> <exclusion> <groupId> org.apache.ant </groupId> <artifactId> ant-launcher </artifactId> </exclusion> </exclusions> </dependency> When I then run mvn clover2:instrument , the classPath for the maven-surefire-plugin (I also checked the maven-compiler-plugin) doesn't include ant-launcher. [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test' --> [DEBUG] (f) basedir = /work/mvnclvr/src/it/optmized/module-a [DEBUG] (f) childDelegation = false [DEBUG] (f) classesDirectory = /work/mvnclvr/src/it/optmized/module-a/target/clover/classes [DEBUG] (f) classpathElements = [/work/mvnclvr/src/it/optmized/module-a/target/clover/test-classes, /work/mvnclvr/src/it/optmized/module-a/target/clover/classes, /.m2/repository/com/cenqua/clover/clover/2.3.3-SNAPSHOT/clover-2.3.3-SNAPSHOT.jar, /.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar, /.m2/repository/org/apache/ant/ant/1.7.1/ant-1.7.1.jar] Could you please provide the output when you run maven with the -X command and/or supply a small example pom.xml which will reproduce the problem you are having. Best Regards, Nick Pellow

            Nick added a comment -

            fyi - I've asked the maven list about work arounds or fixes for this issue. The thread is here: http://www.nabble.com/getDependencyArtifacts-not-respecting-%3Cexclusions%3E-p20063925.html .

            Nick added a comment - fyi - I've asked the maven list about work arounds or fixes for this issue. The thread is here: http://www.nabble.com/getDependencyArtifacts-not-respecting-%3Cexclusions%3E-p20063925.html .

            Nick added a comment -

            Hi David, Franz.

            I would like to get started on this issue - however need some more information to try and reproduce the problem you are seeing.

            Could you please provide your pom.xml, or the relevant snippets of your pom.xml . Specifically, I would like to see

            • the dependency you have defined which has <exclusions/>
            • your maven-surefire-plugin definition, if any
            • your maven-compiler-plugin definition, if any.

            As I understand this problem:

            • your project has a dependency on artifact-A
            • you have excluded one of artifact-A's dependencies (as you require a different version than is defined by artifact-A?)
            • clover adds getProject().getDependencyArtifacts() (which does NOT respect artifact exclusions) to the compile time classpath
            • your build fails, due to a version clash of the dependency you excluded.

            Are these assumptions correct?

            Cheers,
            Nick

            Nick added a comment - Hi David, Franz. I would like to get started on this issue - however need some more information to try and reproduce the problem you are seeing. Could you please provide your pom.xml, or the relevant snippets of your pom.xml . Specifically, I would like to see the dependency you have defined which has <exclusions/> your maven-surefire-plugin definition, if any your maven-compiler-plugin definition, if any. As I understand this problem: your project has a dependency on artifact-A you have excluded one of artifact-A's dependencies (as you require a different version than is defined by artifact-A?) clover adds getProject().getDependencyArtifacts() (which does NOT respect artifact exclusions) to the compile time classpath your build fails, due to a version clash of the dependency you excluded. Are these assumptions correct? Cheers, Nick

            Hi,

            I see that this has Priority: Minor.
            Can we change it to blocker please? I already have a commercial Clover licence but I can't use it because Clover fails on my build now. I can't seem to be able to use it at all because of this bug.

            Thanks,
            David

            David Barri added a comment - Hi, I see that this has Priority: Minor. Can we change it to blocker please? I already have a commercial Clover licence but I can't use it because Clover fails on my build now. I can't seem to be able to use it at all because of this bug. Thanks, David

              npellow Nick
              f18625d9893d Franz Garsombke
              Affected customers:
              1 This affects my team
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: