我想在构建项目时使用google-closure-compiler
进行javascript和css缩小。已根据要求准备build.xml
。
请在下面找到build.xml
:
<project name="ITV" default="run">
<property name="webroot" value="webapp/scripts" />
<!--<target name="doMinification" />-->
<tstamp>
<format property="TODAY_MY" pattern="yyyyMMdd-HHmmss" locale="en,UK" />
</tstamp>
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="compiler.jar"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- ================================================================== -->
<target name="run">
<foreach target="doMinification" param="foreach.file">
<path id="jsFileset">
<fileset id="jsFiles" dir="${webroot}/">
<exclude name="**/Libraries/**" />
<include name="**/*.js"/>
</fileset>
</path>
</foreach>
</target>
<!-- Minify JS -->
<target name="doMinification">
<!-- This gets the filename without the directory path. -->
<basename property="jsFileName" file="${foreach.file}"/>
<!-- Using Javascript functions to work out the paths -->
<script language="javascript"> <![CDATA[
// get values
fullPath = project.getProperty("foreach.file");
fileOnly = project.getProperty("jsFileName");
fileName = fileOnly.substr(0,fileOnly.lastIndexOf('.'));
pathOnly = fullPath.substring(0, fullPath.indexOf(fileOnly));
// store the result in a new property
project.setProperty("directory",pathOnly);
project.setProperty("fileName", fileName);
]]> </script>
<!--<echo message="Compressing file ${jsFileName} in ${directory}" />
<echo message="file only ${fileName}" />-->
<jscomp compilationLevel="whitespace" warning="verbose" debug="true" languagein="ECMASCRIPT5" output="${directory}\${fileName}-min.js" forceRecompile="true">
<externs dir="${webroot}/Libraries/Angular/">
<file name="angular.min.js"/>
</externs>
<sources dir="${directory}">
<file name="${jsFileName}"/>
</sources>
</jscomp>
</target>
</project>
现在,当我执行ant
命令时,它会根据脚本启动缩小过程。它适用于少量文件,并突然在此过程中的某个时间点停止。等待一段时间后,将在命令提示符下打印以下消息。
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006d9a4351, pid=36500,
tid=37136
#
# JRE version: 6.0_75-b13
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.75-b01 mixed mode windows-amd64
compressed oops)
# Problematic frame:
# V [jvm.dll+0xd4351]
#
# An error report file with more information is saved as:
# C:\xxx\xxx\xxx\xxx\xxx\hs_err_pid36500.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
我尝试使用ant
多次,但每次出现此类消息并且jvm
都会崩溃。
可能是什么原因以及如何解决?我的构建脚本有任何问题吗?