diff options
Diffstat (limited to 'dev-java/ant-apache-bsf/build.xml')
-rw-r--r-- | dev-java/ant-apache-bsf/build.xml | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/dev-java/ant-apache-bsf/build.xml b/dev-java/ant-apache-bsf/build.xml new file mode 100644 index 0000000..c2a6e09 --- /dev/null +++ b/dev-java/ant-apache-bsf/build.xml @@ -0,0 +1,65 @@ +<project name="bsftest" default="all" basedir="."> + + <target name="squares"> + + <script language="javascript"> <![CDATA[ + + for (i=1; i<=10; i++) { + echo = bsftest.createTask("echo"); + echo.setMessage(i*i); + echo.perform(); + } + + ]]> </script> + + </target> + + <target name="fileset_echo"> + + <property name="fs.dir" value="src"/> + <property name="fs.includes" value="**/*.txt"/> + <property name="fs.excludes" value="**/*.tmp"/> + + <script language="javascript"> <![CDATA[ + + // import statements + // importPackage(java.io); + importClass(java.io.File); + + // Access to Ant-Properties by their names + dir = project.getProperty("fs.dir"); + includes = bsftest.getProperty("fs.includes"); + excludes = self.getProject() .getProperty("fs.excludes"); + + // Create a <fileset dir="" includes=""/> + fs = project.createDataType("fileset"); + fs.setDir( new File(dir) ); + fs.setIncludes(includes); + fs.setExcludes(excludes); + + // Get the files (array) of that fileset + ds = fs.getDirectoryScanner(project); + srcFiles = ds.getIncludedFiles(); + + // iterate over that array + for (i=0; i<srcFiles.length; i++) { + + // get the values via Java API + var basedir = fs.getDir(project); + var filename = srcFiles[i]; + var file = new File(basedir, filename); + var size = file.length(); + + // create and use a Task via Ant API + echo = bsftest.createTask("echo"); + echo.setMessage(filename + ": " + size + " byte"); + echo.perform(); + } + ]]></script> + </target> + + <target name="all" depends="squares,fileset_echo"> + <echo message="tests passed"/> + </target> + +</project>
\ No newline at end of file |