Maven 2.x Ant Tasks

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

Hide
Herve Boutemy added a comment -

fixed in r646946

Show
Herve Boutemy added a comment - fixed in r646946
Hide
Thomas Tardy added a comment -

When is the planed release date for the maven ant tasks version 2.0.9?

Show
Thomas Tardy added a comment - When is the planed release date for the maven ant tasks version 2.0.9?
Hide
Benjamin Bentmann added a comment -

When is the planed release date for the maven ant tasks version 2.0.9?

Hervé already started the release vote.

Show
Benjamin Bentmann added a comment -
When is the planed release date for the maven ant tasks version 2.0.9?
Hervé already started the release vote.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: