Using the Apache Ant API in a Java program for programmatically compiling source files

I am looking for good and practical resources that will help me make good use of the Ant API. The project website just provides API documentation, which is generally not useful. Very few websites seem to provide very short training materials on this subject.

Is there some kind of resource that I am missing? How can I use Ant APIs for simple tasks without spending hours looking at them and looking at the source code?

Thanks.

(Answers to previously asked questions did not help - How can I use Apache Ant Programmatically )

+4
source share
3 answers

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

The question you are probably asking yourself now is: How do you know which classes and methods you need to call to create a dummy project and purpose? The answer is: you do not. Ultimately, you should be prepared to get your feet wet and read the source code. The above example is only for raising appetite and getting started. Act!

Thus, this is the only way to make the best use of the API.

+2
source

.. Java program for building source files programmatically

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

All J2SE. Ant not included, Ant not required.

+2
source

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

I'm not sure if you went through this link, which explains the creation of the task in detail. A warning. If you are new to ANT, there is no easy way to delve into this tutorial. Better to learn the basics before coming here. See the link above for a good starting point.

0
source

Source: https://habr.com/ru/post/1347508/


All Articles