turn \"编译失败!\";
}
}
/**
* @param args
*/
public static void main(String args) {
System.out.println(\"开始编译\");
boolean b = CompileJava.compile(\"D:/easdev/build/userbuild.xml\",
\"D:/easdev/build/userbuild.log\");
if(b)
{
System.out.println(\"编译成功!\");
}
else
{
System.out.println(\"编译失败!\");
}
System.out.println(\"结束编译\");
}
}
下面是Java页面通过dwr调用此类的代码:
<%@ page contentType=\"text/html; charset=GBK\"%> [Page]
<%@ page import=\"org.apache.easframework.common.*\" %>
<%@ taglib prefix=\"ww\" uri=\"webwork\" %>
<%@ include file=\"/common/head.jsp\"%>
<script type=’text/javascript’ src=’<%=request.getContextPath()%>/js/util.js?Math.random();’></script>
<script type=’text/javascript’ src=’<%=request.getContextPath()%>/js/engine.js?Math.random();’></script>
<script type=’text/javascript’ src=’<%=request.getContextPath()%>/dwr/interface/CompileJava.js?Math.random();’></script>
<meta http-equiv=\"epires\" content=0>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<meta http-equiv=\"pragma\" content=\"no-cache\">
<meta http-equiv=\"cache-control\" content=\"no-cache\">
<script language=\"JavaScript\">
<!--
function compileJava()
{
CompileJava.startCompile(\"D:/easdev/build/userbuild.xml\",\"D:/easdev/build/userbuild.log\",callback);
// document.listForm.elements[’pageLoaderInfo.custSort’].value = sortValue;
// document.listForm.operate.value=\"selectPageList\";
// document.listForm.submit();
}
function callback(data)
{
alert(data);
}
-->
</script>
<table><tr><td><input type=\"button\" name=\"compile\" value=\"编译\" class=\"mybutton\" onClick=\"compileJava()\"></td></tr></table>
<%@include file=\"/common/tail.jsp\"%>
上面在编译成功时弹出编译成功的JS提示,否则提示编译失败
另外需要说明的是,要实现在线ANT编译,需要把ant工具相关的一些jar包复制到tomcat的shared\\lib或者WEB-INF\\lib中.