ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick L├╝bbecke" <>
Subject Running a script twice after changing a property fails
Date Mon, 13 Oct 2008 07:26:58 GMT
I'm currently facing a problem while trying to write an ant task that looks
up for some xml elements and adds a prefix in front of that specific

I have to run this script twice since I have two files to change which have
pretty much the same structure. What it basically does is:

1. unzip the 1st .ear file to /temp/ear
2. unzip the included .war file to /temp/ear/war
3. change the nodes
4. zip the war file
5. zip the ear file
6. run the same procedure for the 2nd .ear file

All that tasks are controlled by the "Task" target.

Here's some of my code:

<?xml version="1.0"?>

<project name="Evaluation" default="Tasks" basedir=".">

<record name="log.txt" action="start" append="false"/>

<property name="src" value="."/>
<property name="build" value="build"/>
<property name="earWorking" value="temp/ear"/>
<property name="warWorking" value="${earWorking}/war"/>
<property name="akteEarFile" value="eAkteEAR-20081001-0720.ear"/>
<property name="pkEarFile" value="ePKEAR-20081001-1140.ear"/>
<property name="pkWarFile" value="ePKPortlets.war"/>
<property name="akteWarFile" value="eAktePortlets.war"/>
<property name="registerEAR" value="temp/ear/registerEPKEAR.xml"/>

<taskdef name="xmltask"
<taskdef resource="net/sf/antcontrib/"/>

    <!--EAR-File unpacking-->
     <target name="PKearUnzip" description="Unzips the EAR archive">
          <unzip src="${pkEarFile}" dest="${earWorking}"/>

     <!--WAR-File unpacking-->
     <target name="PKwarUnzip" depends="PKearUnzip" description="Unzips the
WAR archive">
        <unzip src="${earWorking}/${pkWarFile}" dest="${warWorking}"/>


    <!-- Changing the Nodes-->
<target name="registerEPKEAR.xml" depends="ApplicationXML"

    <xmltask source="${registerEAR}">

        <copy path="/request/portal/web-app/display-name/text()"
        <copy path="/request/portal/web-app/portlet-app/@name"
attrvalue="true" property="prop2"/>
        <copy path="/request/portal/web-app/portlet-app/portlet[1]/@name"
attrvalue="true" property="prop3"/>
        <copy path="/request/portal/web-app/portlet-app/portlet[2]/@name"
attrvalue="true" property="prop4"/>
        <copy path="/request/portal/web-app/portlet-app/portlet[3]/@name"
attrvalue="true" property="prop5"/>
        <copy path="/request/portal/web-app/portlet-app/portlet[4]/@name"
attrvalue="true" property="prop6"/>
                <uncomment path="/request/portal/web-app/url[3]"/>


    <replace file="${registerEAR}" token="&lt;context-root&gt;/"
value="&lt;context-root&gt;/Schulung_" summary="true"/>
    <echo message="display-name: ${prop1}"/>
    <echo message="ID: ${prop2}"/>
    <echo message="ID: ${prop3}"/>
    <echo message="ID: ${prop4}"/>
    <echo message="ID: ${prop5}"/>
    <echo message="ID: ${prop6}"/>

    <xmltask dest="${registerEPKEAR}">
        <replace path="/request/portal/web-app/display-name/text()"
        <attr path="/request/portal/web-app/portlet-app" attr="name"
        <replace path="/request/portal/web-app/portlet-app/portlet[1]/@name"
        <replace path="/request/portal/web-app/portlet-app/portlet[2]/@name"
        <replace path="/request/portal/web-app/portlet-app/portlet[3]/@name"
        <replace path="/request/portal/web-app/portlet-app/portlet[4]/@name"


        <var name="prop1" value="" unset="true" />
        <var name="prop2" value="" unset="true" />
        <var name="prop3" value="" unset="true" />
        <var name="prop4" value="" unset="true" />
        <var name="prop5" value="" unset="true" />
        <var name="prop6" value="" unset="true" />
        <var name="registerEAR" value="temp/ear/registerEAkteEAR.xml"
unset="false" />


    <target name="Tasks">
        <antcall target="PKwarUnzip"/>
        <antcall target="PKZip"/>

        <antcall target="EAwarEntpacken" inheritAll="true" />
        <antcall target="EAPacken" inheritAll="true"/>


After the 1st run the property registerXML has to change to another filename
since the name in the 2nd EAR file I am working with is a different one. I
tried something but without any success, ant always looks up for the "old"
filename without changing the property to the new filename and I'm getting:

  [xmltask] C:\Documents and
Settings\Administrator\workspace\ANT\temp\ear\registerEPKEAR.xml (The system
cannot find the file specified)

C:\Documents and Settings\Administrator\workspace\ANT\build.xml:340: The
following error occurred while executing this line:
C:\Documents and Settings\Administrator\workspace\ANT\build.xml:67:
C:\Documents and
Settings\Administrator\workspace\ANT\temp\ear\registerEPKEAR.xml (The system
cannot find the file specified)

Line 67 is the term "<xmltask source="${registerEAR}">"

I'm out of ideas now. Any help is appreciated.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message