ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Corey Jewett ...@syntheticplayground.com>
Subject Re: build.xml
Date Fri, 14 Nov 2003 21:57:57 GMT
You can import properties from a properties file.

default.properties
src=src
src-java=${src}/java


build.xml:
<project basedir="." default="prep" name="MyProject">
   <property file="default.properties"/>
</project>



Starting with 1.6 you can also import other complete ant files:

build.xml:
<project basedir="." default="prep" name="MyProject2">
   <property file="default.properties"/>
   <import file="build-tasks.xml"/> <!-- 1.6 only -->

   <target name="compile" depends="prep">
     ...
   </target>
</project>


build-tasks.xml:
<project basedir="." default="prep" name="MyProject">
   <target name="prep"
     <mkdir dir="${src-java}"/>
   </target>
</project>

http://nagoya.apache.org/wiki/apachewiki.cgi?NewAntFeaturesInDetail
http://ant.apache.org/manual-1.6beta/CoreTasks/import.html

Corey


On Friday, November 14, 2003, at 01:44 PM, Conelly, Luis (EM, DDEMESIS) 
wrote:

> Hi all
>
> 	This is probably more a XML question than an Ant question; however 
> somebody might know how to do it:
>
> 	I have this huge build.xml file with 800+ script lines. This has 
> become quite a bit annoying to maintain. Then I'd like to modularize 
> the script into several files, to make easier the maintenance 
> (properties in one file, build tasks in other, update tasks located in 
> some other file and so on)
>
> 	However, I am not pretty sure if I am allowed to "include" xml files 
> into one master.xml file. I have done as follows:
>
> common-properties.xml file
> -----------------------------------------
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>     <properties>
> 	<property environment="env"/>
>     	<property name="src" location="src"/>
>     	<property name="dest.home" location="../xxx_yyy"/>
>     	<property name="build" location="${dest.home}/classes"/>
>     	<property name="jsp.home" location="${dest.home}/jsp"/>
>     	<property name="dist" location="${dest.home}/dist"/>
>     	<property name="classpath" location="${env.CLASSPATH}"/>
>     </properties>	
>
>
> master.xml
> -----------------------------------------
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>     <project name="common-props" default="init">
>         <include file="common-properties.xml"/> <!-- prior file-->
> 	<target name="init">
>             <echo message="${env.CLASSPATH}"/>
>         </target>
>     </project>
>
>
> 	However, when I try to execute the 'init' target, I got following 
> error:
>
> C:\Projects\GNF\eDocs>ant -f master.xml init
> Buildfile: master.xml
>
> BUILD FAILED
> file:C:/Projects/master.xml:3: Unexpected element "include"
>
> 	I have seen this kind of 'include' in some other build files, but I 
> am not pretty sure if this is the right way to do it.
>
> 	Any help / observation / indication will be appreciated
>
> 	Regards
> 	Luis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message