Created
December 15, 2010 20:32
-
-
Save davidtucker/742562 to your computer and use it in GitHub Desktop.
Generate a Flex Library manifest XML file via Ant by utilizing Flex metadata.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
========================================================================== | |
Macro: generateManifestFile | |
Creates a manifest file for components using the [Manifest( "ComponentName" )] | |
metadata. | |
========================================================================== | |
--> | |
<macrodef name="generateManifestFile"> | |
<attribute name="outputFile" default="${basedir}/manifest.xml" /> | |
<attribute name="sourceDirectory" default="src" /> | |
<sequential> | |
<var name="manifest.content" value="${manifest.template.contents}" /> | |
<var name="components" value="" /> | |
<var name="component.xml.declarations" value="" /> | |
<property name="tab" value=" " /> | |
<for param="file"> | |
<path> | |
<fileset dir="${basedir}/@{sourceDirectory}" casesensitive="no"> | |
<include name="**/*.as" /> | |
<include name="**/*.mxml" /> | |
<contains text="[Manifest" caseSensitive="true" /> | |
</fileset> | |
</path> | |
<sequential> | |
<echo message="File: @{file}" /> | |
<loadfile property="currentFileContents.@{file}" srcFile="@{file}"/> | |
<propertyregex property="manifest.name.@{file}" | |
input="${currentFileContents.@{file}}" | |
regexp='\[Manifest\( *\"(.*)\" *\)\]' | |
select="\1" | |
casesensitive="false" /> | |
<echo message="Manifest Name: ${manifest.name.@{file}}" /> | |
<pathconvert property="output.path.@{file}" dirsep="." > | |
<path> | |
<pathelement location="@{file}" /> | |
</path> | |
<map from="${basedir}/@{sourceDirectory}/" to=""/> | |
</pathconvert> | |
<propertyregex property="as.path.@{file}" | |
input="${output.path.@{file}}" | |
regexp="(.*)(\.as|\.mxml)" | |
select="\1" | |
casesensitive="false" /> | |
<var name="components" value="${components},${as.path.@{file}}|${manifest.name.@{file}}" /> | |
</sequential> | |
</for> | |
<sortlist property="components.sorted" | |
value="${components}" | |
delimiter="," /> | |
<echo message="Sorted List: ${components.sorted}" /> | |
<for list="${components.sorted}" delimiter="," param="component.details"> | |
<sequential> | |
<propertyregex property="component.line.@{component.details}" | |
input="@{component.details}" | |
regexp="(.*)\|(.*)" | |
replace='<component id\=\"\2\" class\=\"\1\"\/>' | |
casesensitive="false" /> | |
<var name="component.xml.declarations" value="${component.xml.declarations}${tab}${component.line.@{component.details}}${line.separator}" /> | |
</sequential> | |
</for> | |
<echo file="@{outputFile}" append="false" message='<?xml version="1.0"?>${line.separator}<componentPackage>${line.separator}${component.xml.declarations}</componentPackage>' /> | |
</sequential> | |
</macrodef> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment