我想在命令行上通過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