Maven Ant Tasks
  1. Maven Ant Tasks
  2. MANTTASKS-108

Maven Ant Tasks are switching the Classloader of the Main Ant Thread

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.8
    • Fix Version/s: 2.0.9
    • Component/s: deploy task
    • Labels:
      None
    • Environment:
      I have testet it on windows as well as linux.
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      There is a thread on the user mailing list which describes the problem.
      http://www.nabble.com/Using-Maven-Ant-Tasks-in-a-CI-Environment-with-IBM-Jazz-tt16556859s177.html#a16574083

      The problem can be reproduced with the following script.

      The ant build script:
      <?xml version="1.0" encoding="UTF-8"?>
      <project name="MavenTest" default="default" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
      <description>
      description
      </description>

      <taskdef name="mavenTestTask"
      classname="maven.test.task.MavenTestTask" />

      <target name="default">
      <echo message="Invoking test class that does nothing but echo the classloader"/>
      <mavenTestTask/>

      <echo message="Invoking maven artifact:pom task"/>
      <artifact:pom id="pom" file="C:/maven-sample/my-app/pom.xml" />

      <echo message="Invoking test class again that does nothing but echo the classloader"/>

      <mavenTestTask/>

      </target>
      </project>

      The simple Ant Task:
      package maven.test.task;

      import org.apache.tools.ant.BuildException;
      import org.apache.tools.ant.Task;

      /**

      • Test task demonstrating Maven switching the class loader.
        */
        public class MavenTestTask extends Task {

      /* (non-Javadoc)

      • Intentionally not documented. See parent.
        */
        @Override
        public void execute() throws BuildException { log("Current Class Loader: " + Thread.currentThread().getContextClassLoader()); }

      The output when run in Ant:
      Buildfile: C:\Maven\Test\build.xml
      default:
      [echo] Invoking test class that does nothing but echo the classloader
      [mavenTestTask] Current Class Loader: sun.misc.Launcher$AppClassLoader@e39a3e
      [echo] Invoking maven artifact:pom task
      [echo] Invoking test class again that does nothing but echo the classloader
      [mavenTestTask] Current Class Loader: org.codehaus.classworlds.RealmClassLoader@c79809
      BUILD SUCCESSFUL
      Total time: 871 milliseconds

      Thanks for your support!

        Activity

        Herve Boutemy made changes -
        Field Original Value New Value
        Fix Version/s 2.0.9 [ 13935 ]
        Assignee Herve Boutemy [ hboutemy ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]

          People

          • Assignee:
            Herve Boutemy
            Reporter:
            Thomas Tardy
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: