Why is a period used to separate words into a convention for target names in the Ant build file?

I never understood this, since the name attribute seems to support spaces, but each example uses a harder to read period to indicate goals.

Why is this:

<target name="some.target.name"> <!-- target child nodes --> </target> 

When you can do this:

 <target name="Some Target Name"> <!-- target child nodes --> </target> 

Was there any reason for this, or was it a technical limitation? The same goes for build properties. They always use exact notation.

+4
source share
2 answers

One reason may be that it is easier to specify the purpose of the assembly on the command line if it does not have spaces. With spaces, you will need to put quotation marks around the entire target name.

+9
source

if you have spaces in the target name, you will need to wrap them in quotation marks from the command line or the processor will treat them as multiple targets.

Try the following: build.xml:

 <project name="MyProject" default="some target name" basedir="."> <target name="some target name"> <echo>reached some target name with spaces</echo> </target> <target name="some"> <echo>reached some</echo> </target> <target name="target"> <echo>reached target </echo> </target> <target name="name"> <echo>reached name</echo> </target> </project> 

running ant some target name with spaces, you get the following:

 Buildfile: build.xml some: [echo] reached some target: [echo] reached target name: [echo] reached name BUILD SUCCESSFUL Total time: 0 seconds 

but with quotes, it is handled differently: ant "some target name"

 Buildfile: build.xml some target name: [echo] reached some target name with spaces 
+6
source

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


All Articles