Is it possible for an Ant script called by Maven to read properties
defined in maven.xml?  For example, I have an ant file that uses a
variable called "test".  I need to call the ant task several times as I
am building my project each time with a different value for "test".

I thought this was possible by looking at maven.xml from Fulcrum.  I
found the following code being used:

    <!-- Now generate the security service. -->
    <j:set var="torque.project" value="security"/>
    <j:set var="torque.schema.om.includes" value="turbine-schema.xml"/>
    <j:set var="torque.targetPackage" value="${security.package}"/>
    <filter token="DATABASE_DEFAULT" value="${security.database.name}"/>
    <filter token="EXTRA_USER_COLUMNS"
value="${security.extra.user.columns}"/>
    <copy
      file="turbine-schema.xml"
      tofile="${torque.schema.dir}/turbine-schema.xml"
      filtering="yes"/>
    <attainGoal name="torque:om"/>

    <!-- Reset the Torque uptodate check flag. -->
    <j:set var="torque.internal.om.uptodate" value="${null}"/>

    <!-- Now generate the scheduler service. -->
    <j:set var="torque.project" value="scheduler"/>
    <j:set var="torque.schema.om.includes"
value="scheduler-schema.xml"/>
    <j:set var="torque.targetPackage" value="${scheduler.package}"/>
    <filter token="DATABASE_DEFAULT"
value="${scheduler.database.name}"/>
    <filter token="EXTRA_USER_COLUMNS"
value="${scheduler.extra.user.columns}"/>
    <copy
      file="scheduler-schema.xml"
      tofile="${torque.schema.dir}/scheduler-schema.xml"
      filtering="yes"/>
    <attainGoal name="torque:om"/>


As you can see, some of the torque.* variables are being defined before
calling torque:om.  These values a never seen by ant ant script that is
called by the torque plugin though.  

Here is a simple set of goals that can be added to a valid maven.xml
file to demonstrate the problem:

  <goal name="test:ant">
      <attainGoal name="test:ant1"/>
      <attainGoal name="test:ant2"/>
  </goal>

  <goal name="test:ant1" description="test of passing variables to ant">
      <j:set var="test" value="It worked!"/>
      <ant antfile="ant-test.xml" target="test"/>
  </goal>

  <goal name="test:ant2" description="test of passing variables to ant">
      <ant antfile="ant-test.xml" target="test">
          <setProperty name="test" value="It worked!"/>
      </ant>
  </goal>

Here is the ant-test.xml file:

<project name="ant-test" default="test" basedir=".">
    <target name="test">
        <echo message="Test variable = ${test}"/>
    </target>
</project>


Here is the result of maven test:ant:

test:ant:
test:ant1:
    [echo] Test variable = ${test}

test:ant2:
    [echo] Test variable = ${test}


I hope that I am missing something...  Is there some other way to make
this work?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to