rebse / flaka

Automatically exported from code.google.com/p/flaka
Apache License 2.0
0 stars 0 forks source link

Flaka impacts default Ant task local #19

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This issue concerns the use of the Ant local task 
(http://ant.apache.org/manual/Tasks/local.html) together with Flaka.

Consider following ant build file:

===============================
<project name="ant1" default="all" basedir="." 
xmlns:flaka="antlib:it.haefelinger.flaka">
    <target name="all">
        <property name="foo" value="foo" />
        <parallel>
            <echo>global 1: foo is ${foo}</echo>
            <sequential>
                <local name="foo" />
                <property name="foo" value="bar.1" />
                <echo>First sequential: foo is ${foo}</echo>
            </sequential>
            <sequential>
                <sleep seconds="1" />
                <echo>global 2: foo is ${foo}</echo>
            </sequential>
            <sequential>
                <local name="foo" />
                <property name="foo" value="bar.2" />
                <echo>Second sequential: foo is ${foo}</echo>
            </sequential>
            <echo>global 3: foo is ${foo}</echo>
        </parallel>
    </target>
</project>
===============================

The expected output is:

===============================
Buildfile: /home/joost/build.xml

all:
     [echo] global 1: foo is foo
     [echo] First sequential: foo is bar.1
     [echo] Second sequential: foo is bar.2
     [echo] global 3: foo is foo
     [echo] global 2: foo is foo

BUILD SUCCESSFUL
Total time: 1 second
===============================

Now consider this build file:

===============================
<project name="ant1" default="all" basedir="." 
xmlns:flaka="antlib:it.haefelinger.flaka">
    <flaka:install-property-handler />
    <target name="all">
        <property name="foo" value="foo" />
        <parallel>
            <echo>global 1: foo is ${foo}</echo>
            <sequential>
                <local name="foo" />
                <property name="foo" value="bar.1" />
                <echo>First sequential: foo is ${foo}</echo>
            </sequential>
            <sequential>
                <sleep seconds="1" />
                <echo>global 2: foo is ${foo}</echo>
            </sequential>
            <sequential>
                <local name="foo" />
                <property name="foo" value="bar.2" />
                <echo>Second sequential: foo is ${foo}</echo>
            </sequential>
            <echo>global 3: foo is ${foo}</echo>
        </parallel>
    </target>
</project>
===============================

The output now is:

===============================
Buildfile: /home/joost/build.xml

all:
     [echo] global 1: foo is foo
     [echo] First sequential: foo is foo
     [echo] Second sequential: foo is foo
     [echo] global 3: foo is foo
     [echo] global 2: foo is foo

BUILD SUCCESSFUL
Total time: 1 second
===============================

This is not as expected. The output is expected to be the same as without the 
flaka handler installed.

Original issue reported on code.google.com by jrkoi...@nucleon.nl on 8 Aug 2013 at 10:05

GoogleCodeExporter commented 9 years ago
I was able to to reproduce this with the attached Ant build file on both a 
FreeBSD workstation:

Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Detected Java version: 1.7 in: /usr/local/openjdk7/jre
Detected OS: FreeBSD

FreeBSD [hostname redacted] 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 
26 22:50:31 UTC 2013     root@bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC 
 amd64

openjdk version "1.7.0_25"
OpenJDK Runtime Environment (build 1.7.0_25-b15)
OpenJDK 64-Bit Server VM (build 23.21-b01, mixed mode)

And on a Red Hat Enterprise Linux server:

Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Detected Java version: 1.7 in: 
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/jre
Detected OS: Linux

Linux [hostname redacted] 2.6.32-279.19.1.el6.x86_64 #1 SMP Sat Nov 24 14:35:28 
EST 2012 x86_64 x86_64 x86_64 GNU/Linux

java version "1.7.0_25"
OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Sample output from the FreeBSD workstation is attached.

Original comment by tmon...@openlane.com on 8 Feb 2014 at 2:32

Attachments:

GoogleCodeExporter commented 9 years ago
If the handler is installed from within a target, and that target is only 
called by 'ant', 'antcall' or 'antcallback' tasks, you can work around this 
issue. You may need to do some refactoring, but it worked for me. For example:

<project name="ant1" default="all" basedir="." 
xmlns:flaka="antlib:it.haefelinger.flaka">

<taskdef resource="net/sf/antcontrib/antlib.xml" />
    <target name="all">
        <antcall target="some-flaka-target"/>
        <echo message="Do some other stuff without the flaka handler installed."/>
    </target>

    <target name="some-flaka-target">
        <flaka:install-property-handler />
        <echo message="Do some stuff with flaka lib"/>
    </target>
</project>

Original comment by jrkoi...@nucleon.nl on 18 Mar 2014 at 1:57

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
For those, who, like me, cannot wait for the fix: the patch is attached, just
apply it on the current trunk. You can also download a pre-compiled jar here:

https://www.dropbox.com/s/ikses77jnp6ptxl/ant-flaka-1.03.00-SNAPSHOT-patched.jar

This patch also fixes a very nasty bug that causes
all whitespace-only strings to be converted to empty strings,
so that

<pathconvert pathsep=" "...

becomes

<pathconvert pathsep=""...

Enjoy...

Original comment by gmoltcha...@gmail.com on 11 Jun 2014 at 12:29

Attachments:

GoogleCodeExporter commented 9 years ago
Bugfix is available here: https://github.com/greg2001/ant-flaka

Original comment by gmoltcha...@gmail.com on 10 Nov 2014 at 10:41