Difference between Ant and Maven Antrun plugin
----------------------------------------------

                 Key: MANTRUN-121
                 URL: http://jira.codehaus.org/browse/MANTRUN-121
             Project: Maven 2.x Antrun Plugin
          Issue Type: Bug
    Affects Versions: 1.3
         Environment: Redhat Enterprise Linux 5, Windows XP
            Reporter: Harald Entner
         Attachments: bugreport.zip

There is a difference between the _maven antrun plugin_ and _ant_ itself, which 
is a complete show stopper in my case. (actually i invoke ant (via exec) from 
within maven now!)

The problem occurs when providing a property to the _maven-antrun-plugin_. 
There are two build files, build1 and build2. build1 invokes build2, the 
property is known in build1 but not known in build2. This seems somehow 
obvious, as _inheritall_ is false .In my case this part of code is generated by 
netbeans, so i must not change this value, it would work when _inheritall_ is 
set to true - so maybe this is a bug in _ant_ itself. Still a different 
behaviour between _ant_ and _maven-antrun-plugin_.

The code can be seen here [1]
The result (and commands used) can be seen here [2]

[1]
{code:title=build1}
<project name="Bugreport" default="test" basedir=".">
  <target name="test">
    <echo>${property}</echo>
    <ant target="test_property" inheritall="false" antfile="sub/build.xml"/>
  </target>
</project>
{code}

{code:title=build2}
<project name="Sub" default="test" basedir=".">
  <target name="test_property" >
    <echo>${property}</echo>
  </target>
</project>
{code}

{code:title=pom.xml}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>at.test</groupId>
        <artifactId>bugreport</artifactId>
        <packaging>pom</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>Bugreport - difference between ant and maven-ant-run-plugin</name>
        <build>
                <plugins>
                        <plugin>
                                <artifactId>maven-antrun-plugin</artifactId>
                                <executions>
                                        <execution>
                                                <id>ant-magic</id>
                                                <phase>prepare-package</phase>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                                <configuration>
                                                        <tasks>
                                                                <property 
name="property" value="test"/>
                                                                <ant 
antfile="${basedir}/build.xml"/>
                                                        </tasks>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
                </plugins>
        </build>
</project>
{code}

 [2] The result when invoking

{code:title=Result}
C:\dev\test\bugreport>ant -Dproperty=test
Buildfile: build.xml

test:
     [echo] test

test_property:
     [echo] test

BUILD SUCCESSFUL
Total time: 0 seconds
C:\dev\test\bugreport>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Bugreport - difference between ant and maven-ant-run-plugin
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: ant-magic}]
[INFO] Executing tasks

test:
     [echo] test

test_property:
     [echo] ${property}
[INFO] Executed tasks
[INFO] [site:attach-descriptor {execution: default-attach-descriptor}]
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\dev\test\bugreport\pom.xml to C:\Dokumente und 
Einstellungen\HEN\.m2\repository\at\test\b
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Oct 22 18:01:10 CEST 2009
[INFO] Final Memory: 9M/508M
[INFO] ------------------------------------------------------------------------
C:\dev\test\bugreport>

{code}







-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to