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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.0.8
    • 2.0.9
    • deploy task
    • None
    • I have testet it on windows as well as linux.

    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!

      Attachments

        Activity

          People

            hboutemy Herve Boutemy
            thomas.tardy@gmail.com Thomas Tardy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: