Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / February 2004

Tip: Looking for answers? Try searching our database.

[Ant] How to factorize tasks? (Newbie-question)

Thread view: 
contrex - 17 Feb 2004 16:47 GMT
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!
Ville Oikarinen - 20 Feb 2004 07:20 GMT
> 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 :)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.