I want to factorize two ant targets (deploy/undeploy). The only
difference is that they call a java class with a different parameter
(a wsdd file). Here is a snippet of the working ant build.xml file:
<project name="MyProject" default="compile" basedir=".">
...
<path id="project.adminclient.classpath">
...
</path>
<target name="deploy">
<java classname="org.apache.axis.client.AdminClient">
<arg value="A"/>
<arg value="B"/>
<arg value="deploy.wsdd"/>
<classpath refid="project.adminclient.classpath" />
</java>
</target>
<target name="undeploy">
<java classname="org.apache.axis.client.AdminClient">
<arg value="A"/>
<arg value="B"/>
<arg value="undeploy.wsdd"/>
<classpath refid="project.adminclient.classpath" />
</java>
</target>
</project>
I thought I could facorize the <java> tag to something like:
<project name="MyProject" default="compile" basedir=".">
...
<path id="project.adminclient.classpath">
...
</path>
<java id="project.adminclient.execute"
classname="org.apache.axis.client.AdminClient">
<arg value="A"/>
<arg value="B"/>
<classpath refid="project.adminclient.classpath" />
</java>
<target name="deploy">
<java refid="project.adminclient.execute">
<arg value="deploy.wsdd"/>
</java>
</target>
<target name="undeploy">
<java refid="project.adminclient.execute">
<arg value="undeploy.wsdd"/>
</java>
</target>
</project>
The call of the <java> tag works but the problem is that the parameter
(wsdd-file) isn't passed to the <java> tag.
Can you say me how one would do this?
Thank you very much!
> I want to factorize two ant targets (deploy/undeploy). The only
> difference is that they call a java class with a different parameter
> (a wsdd file). Here is a snippet of the working ant build.xml file:
Here's what I would do to combine common parts of two targets (sorry, I didn't
test this, but you'll get the idea):
<!-- a sub-target for deploy and undeploy -->
<target name="_callAdminClient">
<fail message="No parameter, you probably called this target directly!"
unless="adminclient.third.parameter"/>
<java classname="org.apache.axis.client.AdminClient">
<arg value="A"/>
<arg value="B"/>
<arg value="${adminclient.third.parameter}"/>
<classpath refid="project.adminclient.classpath"/>
</target>
<target name="deploy">
<antcall target="_callAdminClient">
<param name="adminclient.third.parameter" value="deploy.wsdd"/>
</antcall>
</target>
<target name="undeploy">
<antcall target="_callAdminClient">
<param name="adminclient.third.parameter" value="undeploy.wsdd"/>
</antcall>
</target>
Ville Oikarinen
contrex - 23 Feb 2004 15:54 GMT
That's exactly what I was looking for!
Thank you very much, it works perfectly :)