ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Calling Ant from Java: An example please ?
Date Thu, 14 Feb 2002 00:48:20 GMT
How about just digging into Ant's source code and reverse engineering it?
It tells all!  :)

You can use the Project.createTask - which will set up more than just
creating a task yourself.  Is that the kind of thing that you are looking
for?

    Erik


----- Original Message -----
From: "Jay Riddell" <jay@theriddells.org>
To: "Ant Users List" <ant-user@jakarta.apache.org>; "Conor MacNeill"
<conor@cortexebusiness.com.au>
Sent: Wednesday, February 13, 2002 7:16 PM
Subject: Re: Calling Ant from Java: An example please ?


> Thank you all that have responded. . . but I still need help ;-)
>
> Of all the response so far, the most relevant of which has been
> "Conor MacNeill" <conor@cortexebusiness.com.au> who quoted some
> of Ant's testcases.  However, I'd rather not implement it where
> it requires the use of an build.xml file.  Reasons?
>     - speed
>     - need for inclusion of an XML parser in my final distribution.
>
> Rather, I would like an ALL JAVA, ALL SOURCE CODE, NO EXTRA JAR solution.
>
> What this means is that I *REALLY* want to figure out how to use the ANT
> API to run the Javac task.
>
> Any help in THAT direction would be much appreciated.
>
>
> On 2/13/02 2:11 PM, "Conor MacNeill" <conor@cortexebusiness.com.au> wrote:
>
> > Jay Riddell wrote:
> >
> >> Yes, I am TRYING to do that.
> >> But I am failing miserably.
> >> There are NO EXAMPLES on how to do this; there is only Javadoc
> >> on the API itself (with very little extra explanatory text).
> >>
> >> OK, maybe I am not being specific enough here.
> >>
> >> Here is the java code that I have written that attempts
> >> to compile a "Hello, world" java file:
> >> http://home.attbi.com/~theriddells/CompileIt.java
> >>
> >> And here are the results that I get:
> >> http://home.attbi.com/~theriddells/results.txt
> >>
> >
> > You could look at Ant's testcases which contain the following code
> >
> >    protected void configureProject(String filename) {
> >        logBuffer = new StringBuffer();
> >        fullLogBuffer = new StringBuffer();
> >        project = new Project();
> >        project.init();
> >        project.setUserProperty( "ant.file" , new
> > File(filename).getAbsolutePath() );
> >        project.addBuildListener(new AntTestListener());
> >        ProjectHelper.configureProject(project, new File(filename));
> >    }
> >
> > What you would need to do then would be to replace the ProjectHelper
> > call with one that creates your targets and tasks, etc.
> >
> > Conor
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message