tags:

views:

101

answers:

2

In my Ant skript, i'm executing a program, passing some arguments, of which one is a very long argument:

<exec executable="${conf.GLASSFISH}/bin/asadmin" failonerror="true" vmlauncher="false">
  <arg line="create-auth-realm" />
  <arg line="--classname com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm" />
  <arg line="--property jaas-context=${conf.auth.jaas-context}:datasource-jndi=${conf.auth.datasource-jndi}:user-table=${conf.auth.usertable}:user-name-column=${conf.auth.usernamecolumn}:password-column=${conf.auth.passwordcolumn}:group-table=${conf.auth.grouptable}:group-name-column=${conf.auth.groupnamecolumn}:assign-groups=${conf.auth.assigngroups}:digest-algorithm=${conf.auth.digest}" />
  <arg line="jdbcRealm" />
</exec>

How can i split the 3rd argument into multiple lines, so the ant-skript is more readable (lower line width)? Something like this (\ is just a placeholder to demonstrate what i need):

<exec executable="command">
  <arg line="--property PROP1:\\"/>
  <arg line="PROP2:\\"/>
  <arg line="PROP3\\"/>
</exec>

So when Ant executes this it should result in the following command:

command --property PROP1:PROP2:PROP3

How can i realize that?

+1  A: 

You can try this:

  <path id="exec.parms" >
    <pathelement  path="PROP1:" />
    <pathelement  path="PROP2:" />
  </path> 

And then use it in the exec:

<arg pathref="exec.parms" />

You can use the prefix attribute with value "--property " in arg to create the following:

--property PROP1:
--property PROP2:
Eduardo Mauro
+2  A: 

'arg line' is deprecated in Ant. Use 'arg value' instead. See this example from the docs. If you do this, the world will be a happier and safer place.

<target name="help">
  <exec executable="cmd">
    <arg value="/c"/>
    <arg value="ant.bat"/>
    <arg value="-p"/>
  </exec>
</target>  
Julian Simpson