Created
December 19, 2012 12:54
-
-
Save akkerman/4336463 to your computer and use it in GitHub Desktop.
ant build.xml -- shows file operations: loop, make relative and save to file -- also see comments
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
<project name="myProject" default="generate"> | |
<property name="outputFile" location="outputFile.htm"/> | |
<property name="fileName" value=""/> | |
<property name="relativeFileName" value=""/> | |
<property name="target" value="${basedir}"/> | |
<taskdef resource="net/sf/antcontrib/antlib.xml"> | |
<classpath> | |
<pathelement location="ant-contrib.jar"/> | |
</classpath> | |
</taskdef> | |
<target name="generate"> | |
<delete file="${outputFile}"/> | |
<touch file="${outputFile}"/> | |
<foreach target="write.to.file" param="fileName"> | |
<path> | |
<fileset dir=""> | |
<include name="**/*.js"/> | |
</fileset> | |
</path> | |
</foreach> | |
</target> | |
<target name="write.to.file"> | |
<script language="javascript"> | |
var relativeFileName = myProject.getProperty("fileName"); | |
var base = myProject.getProperty("target"); | |
relativeFileName = relativeFileName.replace(base+"\\",""); | |
relativeFileName = relativeFileName.replace("\\","/"); | |
myProject.setProperty("relativeFileName", relativeFileName); | |
</script> | |
<echo file="${outputFile}" append="true"><![CDATA[ | |
<script src="${relativeFileName}"></script>]]></echo> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example shows
For this to be able to run you'll need an additional jar file: ant-contrib.jar