ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Azoulay, Zacky" <zacky.azou...@sapportals.com>
Subject RE: Error passing patternset to another target in another xml fil e
Date Mon, 15 Apr 2002 15:23:31 GMT
Hi,

Thank, the solution for ant 1.4.1 work.

regards zacky

-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com]
Sent: Monday, April 15, 2002 5:59 PM
To: 'Ant Users List'
Subject: RE: Error passing patternset to another target in another xml
fil e


ANT 1.4.1 doesn't pass references to the sub-build. I believe ANT 1.5a now
incorporate this. But the problem you are seeing is that you try to se a
property as a reference id.

The local_file_to_be_removed reference is defined in master build.
The local.file.to.be.removed property is passed to sub-build, probably with
a textual description of the referenced patternset (or the default
toString() from Java).

The sub-build attempts to use the reference local.file.to.be.removed, but as
stated references are not passed to sub-builds. What was passed to sub-build
is just a property, which value can be extracted using
${local.file.to.be.removed}.

So what can you do?
1) Use ANT 1.5a (provided it really can pass references).
2) Use real textual properties.

2.a) define an excludes property

	<property name="local_file_to_be_removed.excludes"
                value="**/*Ie/List/List.vbs" />

2.b) Pass it to sub-build, either explicitly (as below) if using
inheritAll="false", or implicitly by using inheritAll="true"

	<ant antfile="../copy.xml" target="copy.dir" dir=".">
		<property name="sources.dir"
                      value="${compile.directory}/MetaTemplates"/>
		<!-- ... -->
		<property name="local_file_to_be_removed.excludes"
		          value="${local_file_to_be_removed.excludes}"/>
	</ant>

2.c) In the sub-build, use that property to build the patternset:

  	<copy preservelastmodified="YES"
            overwrite="YES"
            todir="${destination.dir}">
		<fileset dir="${sources.dir}">
			<!-- local reference, so OK -->
			<patternset refid="file_not_to_be_copy"/>
			<!-- define new patternset, from the property -->
			<patternset
excludes="${local_file_to_be_removed.excludes}"/>
		</fileset>
  	</copy>

if you have several includes/excludes, define a comma-separated property of
them.

Better ANTers can explain the ANT 1.5a way, or a better ANT 1.4.1 way too
;-)

--DD

-----Original Message-----
From: Azoulay, Zacky [mailto:zacky.azoulay@sapportals.com] 
Sent: Sunday, April 14, 2002 1:29 AM
To: 'ant-user@jakarta.apache.org'
Subject: Error passing patternset to another target in another xml file

Hi,

I have two xml file one with a target copy.dir.targetdir
that contain one patternset local_file_to_be_removed and a target ant
antfile to the second xml file.

targetdir.xml file .

 <target name="copy.dir.targetdir" depends="title" >
	<patternset id="local_file_to_be_removed" >
		<exclude name="**/*Ie/List/List.vbs"/>
	</patternset>

	<!-- Dir Number 1 !!!! MetaTemplates !!!! -->


<ant antfile="../copy.xml" target="copy.dir" dir=".">
	<property name="sources.dir"
value="${compile.directory}/MetaTemplates"/>
	<property name="destination.dir"
value="${global.destination.dir}/MetaTemplates"/>
	<property name="attrib.dir" value="-r"/>
	<property name="local.file.to.be.removed"
refid="local_file_to_be_removed"/>
</ant>
</target>	


in copy.xml I perform a copy target with the property from targetdir.xml.

	<target name="copy.dir.available" >
		
		<available file="${sources.dir}" property="source.exist"/>
		<patternset id="file_not_to_be_copy" >
			<exclude name="**/*.bak"/>
			<exclude name="**/create.dir"/>
			<exclude name="**/*.scc"/>
			<exclude name="**/*.lib"/>
			<exclude name="**/*.ilk"/>
			<exclude name="**/*.bdy"/>
			<exclude name="**/*.hdr"/>
			<exclude name="**/*.exp"/>
		</patternset>


	</target>


  	<target name="copy.dir" depends="copy.dir.echo" if="source.exist">
  		<!-- Sources -->
  		<copy preservelastmodified="YES" overwrite="YES"
todir="${destination.dir}">
    			<fileset dir="${sources.dir}">
				<patternset refid="file_not_to_be_copy"/>
				<patternset
refid="local.file.to.be.removed"/>
			</fileset>
  		</copy>
		<record name="${success.log.file}" action="start" />
		<exec executable="cmd.exe" os="Windows 2000">
			<arg line="/c attrib ${attrib.dir} /S"/>
			<arg value="${destination.dir}/*.*"/>
		</exec>
		<exec executable="cmd.exe" os="Windows 2000">
			<arg line="/c DIR /S /B "/>
			<arg value="${destination.dir}"/>
		</exec>
		<record name="${success.log.file}" action="stop" />

	</target>

after I run ant I got the following error.

C:\BW Unifier\Config\Build\copy.xml:194: Reference local.file.to.be.removed
not found.

is any one now what I do wrong ??

regards zacky




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

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

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


Mime
View raw message