Using Apache Ant APIs in Java program to programma

2019-05-04 21:40发布

I am looking for good and practical resources that will help me use the Ant APIs effectively. The project website just gives the documentation of the API which is not useful at all. Very few websites seem to give very brief tutorials on the subject.

Is there some resource I am missing out on? How can I use the Ant APIs for simple tasks, without spending hours browsing through them and looking at source code?

Thanks.

(Answers to previously asked questions not helpful - How can i use Apache ANT Programmatically )

3条回答
做个烂人
2楼-- · 2019-05-04 22:10

..Java program to programmatically build source files

If compiling/Jarring is all you need and you can run it in an SDK (as opposed to a plain JRE), look to the JavaCompiler class for compilation. Then use the Jar related classes to build the Jars.

All J2SE. Ant not included, Ant not required.

查看更多
霸刀☆藐视天下
3楼-- · 2019-05-04 22:17

As it turns out, the lack of good resources on using the Ant API, is known and intended. The bottom paragraph of this article from the Ant says -

The question you are probably asking yourself at this point is: How would I know which classes and methods have to be called in order to set up a dummy Project and Target? The answer is: you don't. Ultimately, you have to be willing to get your feet wet and read the source code. The above example is merely designed to whet your appetite and get you started. Go for it!

So this seems to be the only way to make best use of the API.

查看更多
再贱就再见
4楼-- · 2019-05-04 22:22

There is no better manual to understand ANT than : http://ant.apache.org/manual/index.html

I am not sure if you've gone through this link that explains in detail about creating a task. A word of caution, If you're new to ANT, there is no easy way to jump on this tutorial. Better to learn the basics before you come here. Refer above link for a good starting point.

查看更多
登录 后发表回答