Search code examples
javascriptjavaxmljenkinsant

Cannot load ZipFileSet in Ant


i get a typeerror when executing the below in my ant deploy.xml file, any idea what's wrong? This worked about two weeks ago

command:ant -f deploy.xml

ant version: 1.9.4

error:javax.script.ScriptException: TypeError: Cannot load script from Packages.org.apache.tools.ant.types.ZipFileSet

<script language="javascript"><![CDATA[
         var version = java.lang.System.getProperty("java.version");
         if ( version.startsWith("1.8.0")) {
             load(Packages.org.apache.tools.ant.types.ZipFileSet);
             load(Packages.org.apache.tools.ant.taskdefs.Zip);
         } else {
             importClass(Packages.org.apache.tools.ant.types.ZipFileSet);
             importClass(Packages.org.apache.tools.ant.taskdefs.Zip);
         }
         ]]>
</script>

Solution

  • using the suggestion below fixed the error.

    i.e.

    var Zip = org.apache.tools.ant.taskdefs.Zip;
    

    Java 8 Javascript Engine backwards compatibility