我想在命令行上通过Ant编译一个可编译Eclipse的GWT项目(通过Ant)。为Ant build.xml创建GWT编译规则
Eclipse提供的功能可以导出build.xml
;这对编译类很有效,但由于GWT的特殊功能都是通过插件提供的,因此不包括这些规则。
Google提供a tool用于为新项目创建build.xml
文件。我已将由此生成的规则合并到Eclipse导出的文件中。
编译(由Eclipse提供的部分)是成功的。
以下是编译的东西到JavaScript的任务:
<target name="gwtc" depends="build" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="/Applications/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201201120043-rel-r37/gwt-2.4.0/validation-api-1.0.0.GA.jar" />
<pathelement location="/Applications/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201201120043-rel-r37/gwt-2.4.0/validation-api-1.0.0.GA-sources.jar" />
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<!--<arg line="-style PRETTY"/>-->
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="edu.calpoly.csc.scheduler"/>
</java>
</target>
的.gwt.xml
文件看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='gwtview'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='edu.calpoly.csc.scheduler.view.client.GWTView'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
<source path='view'/>
</module>
当试图运行的任务,我得到这个错误:
gwtc:
[java] Compiling module edu.calpoly.csc.scheduler
[java] Finding entry point classes
[java] [ERROR] Unable to find type 'edu.calpoly.csc.scheduler.view.client.GWTView'
[java] [ERROR] Hint: Previous compiler errors may have made this type unavailable
[java] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
对我来说这似乎很奇怪,因为这个班上有很多:
[$]> ls war/WEB-INF/classes/edu/calpoly/csc/scheduler/view/client
GWTView$1.class GWTView$1MyHandler.class GreetingService.class
GWTView$1MyHandler$1.class GWTView.class GreetingServiceAsync.class
Halp?
是的。 'ls src/edu/calpoly/csc/scheduler/view/client'显示'GWTView.java'。 – 2012-02-13 20:04:34
@XiongChiamiov好吧,这意味着gwt.xml不包含'view'包。文件edu/calpoly/csc/scheduler.gwt.xml是否包含''标签? – jusio 2012-02-13 21:08:50
它没有;我添加了它,但仍然得到相同的错误。我已经更新了问题以包含完整的'scheduler.gwt.xml'文件内容。 – 2012-02-15 20:13:20