<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../etc/wfrant2html.xsl"?>
<!-- version 2005/08/09 -->
<!-- author Bill Rich, bill@wilandra.com, Wilandra Consulting LLC. Copyright (C) 2004-2005, Wilandra Consulting LLC. All rights reserved. -->
<!-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -->
<!--See http://g11ntoolkit.sourceforge.net/licenseGPL.html for the License Agreement. -->
<!-- =================================================================== -->
<project	name="L10NProcess-filediscovery"
					basedir="."
					default="init"
					xmlns:ac="antlib:net.sf.antcontrib">
	<description>
		Ant tasks used in an L10N project in support of the file discovery tasks. This is intended to be imported by the L10NProcess.xml file.
	</description>

	<!-- ${file.separator} -->
<!-- =================================================================== -->
	<!-- target	name="makelrblist"
					depends="init"
					description="Make a list of the ListResourceBundle files in the project product file area.">
		<echo	message="makelrblist begin"/>
		<property	name="LRBLISTFILE"
							value="lrblist.txt"/>
		<fileset id="lrbset" dir="${SOURCEFILESDIR}/${PRODUCT}" includes="**/*">
			<and>
				<filename name="**/*.java"/>
				<or>
					<containsregexp	expression="\s+class\s+[^\s]+\s+extends\s+ListResourceBundle"/>
					<containsregexp	expression="\s+class\s+[^\s]+\s+extends\s+java\.util\.ListResourceBundle"/>
				</or>
			</and>
		</fileset>
		<pathconvert targetos="unix" property="lrbp" refid="lrbset">
			<map from="${SOURCEFILESDIR}\${PRODUCT}\" to=""/>
		</pathconvert>
		<ac:propertyregex	property="lrbs"
											override="true"
											input="${lrbp}"
											regexp=":"
											replace="${line.separator}"
											global="true"
											casesensitive="true"/>
		<echo	file="${LRBLISTFILE}"
					append="false"
					message="${lrbs}"/>
		<echo	message="makelrblist end"/>
	</target -->
<!-- =================================================================== -->
<!--
Macrodef for searching for unreplaced filterset tokens prior to building a war file
-->
	<macrodef	name="findlrbs"
						description="Search a fileset for tokens that indicate the file may be a ListResourceBundle creating a property set for the selected and rejected files.">
		<attribute	name="files"
								description="The set of files to be considered."/>
		<attribute	name="pattern"
								description="Regex to use to check the filterset. Default matches what would normally be thought of as the way to declare a ListResourceBundle."
								default="\s+class\s*[^\s]+\s*extends\s*[ListResourceBundle|java\.util\.ListResourceBundle]"/>
		<sequential>
			<ac:for	list="@{files}"
							delimiter=";"
							param="afile">
				<sequential>
					<loadfile	srcfile="@{afile}"
										property="file.@{afile}">
						<filterchain>
							<stripjavacomments/>
							<striplinebreaks/>
							<linecontainsregexp>
								<regexp pattern="@{pattern}" />
							</linecontainsregexp>
						</filterchain>
					</loadfile>
					<ac:if>
						<isset property="file.@{afile}"/>
						<ac:then>
							<!-- echo	message="candidate [@{afile}]"/ -->
						  <!-- property	name="raw.selectedFile.@{afile}"
						  					location="@{afile}"/ -->
							<!-- filelist	id="raw.selectedFile.@{afile}"
												dir=""
												files="@{afile}"/ -->
							<fileset	id="raw.selectedFile.@{afile}"
												file="@{afile}"/>
							<!-- echo	message="raw [${raw.selectedFile.@{afile}}]"/ -->
							<!-- pathconvert	targetos="unix"
														property="temp.selectedFile.@{afile}"
														refid="raw.selectedFile.@{afile}">
							</pathconvert>
							<echo	message="temp [${temp.selectedFile.@{afile}}]"/ -->
							<pathconvert	targetos="unix"
														property="temp.selectedFile.@{afile}"
														refid="raw.selectedFile.@{afile}">
								<map	from="${PRODUCT}"
											to=""/>
								<map	from="${SOURCEFILESDIR}"
											to=""/>
								<map	from="${SOURCEDRIVE}"
											to=""/>
								<!-- map	from="${basedir}"
											to=""/ -->
							</pathconvert>
							<!-- echo	message="temp selected [${temp.selectedFile.@{afile}}]"/ -->
							<ac:propertyregex	property="selectedFile.@{afile}"
																override="true"
																input="${temp.selectedFile.@{afile}}"
																regexp=".*/${SOURCEFILESDIR}/${PRODUCT}/(.*)"
																replace="\1"
																global="true"
																casesensitive="true"/>
							<!-- ac:propertyregex	property="selectedFile.@{afile}"
																override="true"
																input="${temp.selectedFile.@{afile}}"
																regexp="(.*)"
																replace="\1"
																global="true"
																casesensitive="true"/ -->
							<echo	message="selected [${selectedFile.@{afile}}]"/>
						</ac:then>
						<ac:else>
							<!-- echo	message="rejected @{afile}"/ -->
							<property name="rejectedFile.@{afile}" value="@{afile}"/>
						</ac:else>
					</ac:if>
				</sequential>
			</ac:for>
		</sequential>
	</macrodef>

<!-- =================================================================== -->
	<target name="makelrblist">
		<property	name="LRBLISTFILE"
							value="lrblist.txt"/>
		<fileset	id="lrbset"
							dir="${SOURCEDRIVE}/${SOURCEFILESDIR}/${PRODUCT}"
							includes="**/*">
			<and>
				<filename	name="**/*.java"/>
				<containsregexp	expression="ListResourceBundle"/>
			</and>
		</fileset>
		<!-- echo	message="lrbset [${lrbset}]"/ -->

		<pathconvert	property="lrbp"
									refid="lrbset">
		</pathconvert>
		<!-- echo	message="lrbp [${lrbp}]"/ -->

		<property	name="results.file"
							location="lrbList.txt" />
		<findlrbs	files="${lrbp}"/>

		<delete file="${LRBLISTFILE}"/>
		<echoproperties	destfile="${LRBLISTFILE}">
			<propertyset id="selectedFiles">
				<propertyref prefix="selectedFile."/>
			</propertyset>
		</echoproperties>
		<echo message="Rejected Files:"/>
		<echoproperties prefix="rejectedFile"/>

	</target>

<!-- =================================================================== -->
    <!-- scriptdef name="split" language="javascript">
         <attribute name="value"/>
         <attribute name="sep"/>
         <attribute name="prefix"/>
         <![CDATA[
             values = attributes.get("value").split(attributes.get("sep"));
             for(i=0; i<values.length; i++) {
                 project.setNewProperty(attributes.get("prefix")+i, values[i]);
             }
         ]]>
    </scriptdef>

    <split value="${configs}" sep="," prefix="sc."/>
    <echoproperties prefix="sc"/ -->

<!-- =================================================================== -->
</project>
