• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to call java method from ant task ?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I want to call a java method from ant task I have to pass three argument to that method, though I am able to call a method with single argument but I don't know how to pass three arguments bewlo is the java file and ant file that I made and able to run method with one argument from ant.

java file:
==========================================================
package com.mydomain;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

public class MyVeryOwnTask extends Task {
private String msg;

// The method executing the task
public void execute() throws BuildException {
System.out.println(msg);

}

// The setter for the "message" attribute
public void setMessage(String msg) {
this.msg = msg;
}

}

=========================================================
and it's ant file

<?xml version="1.0"?>

<project name="Build-example" default="main" basedir=".">
<taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask" classpath="bin" />

<target name="main">
<mytask message="Hello World! MyVeryOwnTask works!" />

</target>
</project>

====================================================================

here I am passing only one argument but I need to pass multiple argument how can I do that please help.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just add another attribute in your class as the example you worked from has:

Ant Dev Manual

Add a another private variable, setter for it and println statement for it then add it to your task call.

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our build tools forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic