Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come there is no Apache Ant xml schema definition or DTD for build scripts?

Tags:

ant

Could please anybody explain to me why is that? I've been always using Maven and absence of xml definition for Ant build script is something that makes me searching through internet and documentation instead of one look at the xsd or DTD.

For instance it is almost impossible to find out whether target definition can have own property declared or not.

like image 390
lisak Avatar asked Dec 11 '10 15:12

lisak


People also ask

How do I build an Ant build xml?

Create Ant build file In the Project tool window, select the directory, where the build file should be created. Right-click the directory and from the context menu, select New | File ( Alt+Insert ). In the New File dialog, specify the name of the new file with the xml extension, for example, build. xml.

How do I run an Ant build script?

To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.

Why XML schema is used instead of DTD?

XML schemas are written in XML while DTD are derived from SGML syntax. XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes. XML schemas allow support for namespaces while DTD does not. XML schemas define number and order of child elements, while DTD does not.

What file type does Apache Ant use for its configuration?

Ant uses an xml file for its configuration. The default file name is build. xml . Ant builds are based on three blocks: tasks, targets and extension points.


1 Answers

There is a FAQ for this:

Is there a DTD that I can use to validate my build files?

An incomplete DTD can be created by the <antstructure> task - but this one has a few problems:

  • It doesn't know about required attributes. Only manual tweaking of this file can help here.
  • It is not complete - if you add new tasks via <taskdef> it won't know about it. See this page by Michel Casabianca for a solution to this problem. Note that the DTD you can download at this page is based on Apache Ant 0.3.1.
  • It may even be an invalid DTD. As Ant allows tasks writers to define arbitrary elements, name collisions will happen quite frequently - if your version of Ant contains the optional <test> and <junit> tasks, there are two XML elements named test (the task and the nested child element of <junit>) with different attribute lists. This problem cannot be solved; DTDs don't give a syntax rich enough to support this.
like image 114
a_horse_with_no_name Avatar answered Oct 15 '22 07:10

a_horse_with_no_name