Uploaded image for project: 'Maven Ant Tasks (RETIRED)'
  1. Maven Ant Tasks (RETIRED)
  2. MANTTASKS-197

Dependency with packaging=pom shows up in the classpath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 2.1.1
    • None
    • dependencies task
    • None
    • Mac OSX, Ant 1.8.1

    Description

      My use case is that I have a set of common dependencies that I use across many projects.
      In order to save me some typing I created a pom whose sole purpose is to depend on all
      the common dependencies, so that each of my projects can depend on only this one pom.

      The problem is that the pom file gets included in the classpath, an the junit task shows
      an annoying error because it can't make sense of it as a directory or jar file.

      A relatively simple testcase to show the issue is this pom.xml:

      <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
               xmlns="http://maven.apache.org/POM/4.0.0"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      
          <modelVersion>4.0.0</modelVersion> 
          <groupId>foo</groupId>
          <artifactId>bar</artifactId>
          <version>1.0</version>
      
          <dependencies>
              <dependency>
                  <groupId>asm</groupId>
                  <artifactId>asm-parent</artifactId>
                  <version>3.1</version>
                  <type>pom</type>
              </dependency>
          </dependencies>
      
      </project>
      

      An the following build.xml in the same directory:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <project name="foo" default="test" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
      
      
          <target name="test">
      
              <artifact:pom file="${basedir}/pom.xml" id="maven.project"/>
              <artifact:dependencies pathId="maven2.test.classpath" filesetId="test.fileset">
                  <pom refid="maven.project"/>
              </artifact:dependencies>
              <echo>${toString:maven2.test.classpath}</echo>
          </target>
      
      </project>
      

      When I run this I expect the output from <echo> to list the classpath consisting of the jars dependencies from asm-parent. That pom happens to have no jar dependencies, so I expect the output to be empty. Instead I get the path of the pom file.

      In a more realistic example I will use this as a classpath argument to <junit> and get an error like:

      Unable to obtain resource from /Users/knut/.m2/repository/asm/asm-parent/3.1/asm-parent-3.1.pom: java.util.zip.ZipException: error in opening zip file
          [junit] Unable to obtain resource from /Users/knut/.m2/repository/asm/asm-parent/3.1/asm-parent-3.1.pom: 
          [junit] java.util.zip.ZipException: error in opening zip file
          [junit] 	at java.util.zip.ZipFile.open(Native Method)
          [junit] 	at java.util.zip.ZipFile.<init>(ZipFile.java:114)
          [junit] 	at java.util.jar.JarFile.<init>(JarFile.java:135)
          [junit] 	at java.util.jar.JarFile.<init>(JarFile.java:99)
          [junit] 	at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1002)
          [junit] 	at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:145)
          [junit] 	at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.<init>(AntClassLoader.java:109)
          [junit] 	at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:949)
          [junit] 	at org.apache.tools.ant.AntClassLoader.getNamedResources(AntClassLoader.java:918)
          [junit] 	at org.apache.tools.ant.loader.AntClassLoader5.getResources(AntClassLoader5.java:54)
          [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.checkForkedPath(JUnitTask.java:1135)
          [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:1011)
          [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:811)
          [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1808)
          [junit] 	at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:760)
          [junit] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
          [junit] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
          [junit] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          [junit] 	at java.lang.reflect.Method.invoke(Method.java:597)
          [junit] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
          [junit] 	at org.apache.tools.ant.Task.perform(Task.java:348)
          [junit] 	at org.apache.tools.ant.Target.execute(Target.java:390)
          [junit] 	at org.apache.tools.ant.Target.performTasks(Target.java:411)
          [junit] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
          [junit] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
          [junit] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
          [junit] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1249)
          [junit] 	at org.apache.tools.ant.Main.runBuild(Main.java:801)
          [junit] 	at org.apache.tools.ant.Main.startAnt(Main.java:218)
          [junit] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
          [junit] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
      

      When I read MANTTASKS-41 I can't help but think it revolves around the same culprit, but I'm not expert enough to pinpoint the issue.

      Attachments

        1. MANTTASKS-197.zip
          6 kB
          Knut Forkalsrud

        Activity

          People

            Unassigned Unassigned
            knut-codehaus@forkalsrud.org Knut Forkalsrud
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: