Author: xavier
Date: Thu Jul  5 08:17:26 2007
New Revision: 553537

URL: http://svn.apache.org/viewvc?view=rev&rev=553537
Log:
upgrade xooki version: bug fix + antlib for easy batch generation

Added:
    incubator/ivy/site/xooki/antlib.xml   (with props)
Modified:
    incubator/ivy/site/xooki/xooki.js

Added: incubator/ivy/site/xooki/antlib.xml
URL: 
http://svn.apache.org/viewvc/incubator/ivy/site/xooki/antlib.xml?view=auto&rev=553537
==============================================================================
--- incubator/ivy/site/xooki/antlib.xml (added)
+++ incubator/ivy/site/xooki/antlib.xml Thu Jul  5 08:17:26 2007
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<antlib>
+    <scriptdef name="generate" language="javascript">
+        <element name="fileset" type="fileset"/>
+        <attribute name="destDir"/>
+        <attribute name="checkUpToDate"/>
+        <![CDATA[
+             importClass(java.io.File);
+            
+             fs = elements.get("fileset").get(0);
+              srcDir = elements.get("fileset").get(0).getDir(project);
+       
+             // 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 file = new File(fs.getDir(project), srcFiles[i]);
+               
+                       var basedir = file.getParent();
+                       var filename = file.getName();
+                       var filepath = srcFiles[i].substring(0, 
srcFiles[i].lastIndexOf(project.getProperty("file.separator"))+1);
+                
+                if (attributes.get("checkuptodate")) {
+                    p = "xooki."+srcFiles[i]+".uptodate";
+                    upToDate = project.createTask("uptodate");
+                    upToDate.setProperty(p);
+                    upToDate.setSrcfile(file);
+                    upToDate.setTargetFile(new 
File(attributes.get("destdir")+"/"+filepath));
+                    upToDate.perform();
+                    if (project.getProperty(p) != null) {
+                        self.log(srcFiles[i]+" is up to date", 3);
+                        continue;
+                    }
+                }
+            
+               exec = project.createTask("exec");
+               exec.setDir(new File(basedir));
+               exec.setExecutable("jrunscript");
+               exec.createArg().setValue(srcDir+"/xooki/xooki.js");
+               exec.createArg().setValue(filename);
+               
exec.createArg().setValue(attributes.get("destdir")+"/"+filepath);
+               exec.perform();
+                 }
+        ]]>
+    </scriptdef>
+</antlib>

Propchange: incubator/ivy/site/xooki/antlib.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ivy/site/xooki/xooki.js
URL: 
http://svn.apache.org/viewvc/incubator/ivy/site/xooki/xooki.js?view=diff&rev=553537&r1=553536&r2=553537
==============================================================================
--- incubator/ivy/site/xooki/xooki.js (original)
+++ incubator/ivy/site/xooki/xooki.js Thu Jul  5 08:17:26 2007
@@ -795,8 +795,9 @@
 if (batchMode) {
        importPackage(java.io);
        
-       xooki.io.loadFile = function( url ) {
+       xooki.io.loadFile = function( url, warnOnError ) {
          var str = '';
+         try {
       var r = new BufferedReader(new FileReader(url));
          line = r.readLine();
          while (line != null) {
@@ -804,6 +805,13 @@
                line = r.readLine();
          }
          r.close();
+         } catch (e) {
+               if (warnOnError) {
+                       throw e;
+               } else {
+                       xooki.debug("error occured while loading "+url);
+               }
+         }
          return str;
     };
        
@@ -818,8 +826,8 @@
                return true;
        }
 
-    xooki.url.loadURL = function( url ) {
-               return xooki.io.loadFile(url);
+    xooki.url.loadURL = function( url, warnOnError ) {
+               return xooki.io.loadFile(url, warnOnError );
        };
        
        xooki.html.addHeader = function (head) {


Reply via email to