Date: 2004-03-09T00:14:18
   Editor: StefanBodewig <[EMAIL PROTECTED]>
   Wiki: Ant Wiki
   Page: NewAntFeaturesInDetail/Import
   URL: http://wiki.apache.org/ant/NewAntFeaturesInDetail/Import

   fix some HTML tags

Change Log:

------------------------------------------------------------------------------
@@ -19,9 +19,9 @@
 ----
 '''How does an imported file load a resource relative to itself?'''
 
-By using the magic <code>ant.file.</code><em>projectname</em> property.
+By using the magic `ant.file.`''projectname'' property.
 
-Assume build.xml loads config/common.xml, the latter making use of a 
collocated properties file config/common.properties. The way 
<code><import></code> is currently implemented (I argumented against it, but 
that's beside the point), common.xml cannot simply do a 
<code><property&nbsp;file="common.properties"/></code> as if it was 
stand-alone, because the project's 'basedir' will correspond to the top-most 
importing build file. Ant does on the other hand store the absolute pathname of 
imported build files in a magic property of the form 
ant.file.<em>projectname</em>, where <em>projectname</em> is an imported 
project's name (as defined by the 'name' attribute of the top-level 
<code><project></code> element, and <em>NOT</em> the imported file name!). You 
can thus <code><dirname></code> that absolute filename, and use the resulting 
directory to locate the resource relatively to the imported build file. Here's 
a full example on Windows:
+Assume build.xml loads config/common.xml, the latter making use of a 
collocated properties file config/common.properties. The way <import> is 
currently implemented (I argumented against it, but that's beside the point), 
common.xml cannot simply do a {{{<property file="common.properties"/>}}} as if 
it was stand-alone, because the project's 'basedir' will correspond to the 
top-most importing build file. Ant does on the other hand store the absolute 
pathname of imported build files in a magic property of the form 
ant.file.''projectname'', where ''projectname'' is an imported project's name 
(as defined by the 'name' attribute of the top-level <project> element, and 
'''''NOT''''' the imported file name!). You can thus <dirname> that absolute 
filename, and use the resulting directory to locate the resource relatively to 
the imported build file. Here's a full example on Windows:
 
 {{{
 C:\oss\org_apache\antx\import16> type build.xml
@@ -81,7 +81,7 @@
 Total time: 0 seconds
 }}}
 
-Since an imported build file <em>projectname</em> is used both in itself (to 
be able to locate resources relative to itself as demonstrated above) but also 
potentially in all the files that will import it (to refer to its overriden 
targets), changing the <em>projectname</em> of an imported build file will 
almost always break its <em>client</em>s, i.e. those build files that import 
it. This is a mistake IMHO, and breaks encapsulation (again, I argued against 
this, but no avail.) One should therefore select those project names carefully, 
lest one wants to expose itself to quite of bit of refactoring.
+Since an imported build file ''projectname'' is used both in itself (to be 
able to locate resources relative to itself as demonstrated above) but also 
potentially in all the files that will import it (to refer to its overriden 
targets), changing the ''projectname'' of an imported build file will almost 
always break its ''client''s, i.e. those build files that import it. This is a 
mistake IMHO, and breaks encapsulation (again, I argued against this, but no 
avail.) One should therefore select those project names carefully, lest one 
wants to expose itself to quite of bit of refactoring.
 
 ----
 
@@ -89,7 +89,7 @@
 
 If a target is present in both your main build file and the one that you 
import, the one from your main file takes precedence.
 
-This means that you can write a generic build file and if you just have to 
tweak it a little, you can do so by overriding a target.  You even have access 
to the imported target via <em>projectname</em>.<em>targetname</em>.
+This means that you can write a generic build file and if you just have to 
tweak it a little, you can do so by overriding a target.  You even have access 
to the imported target via ''projectname''.''targetname''.
 
 For example, let's take the simple build file from Ant's manual.  Suppose it 
is called "example.xml".
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to