为Ant build.xml创建GWT编译规则
我试图使Eclipse可编译的GWT项目也可以在命令行上编译(通过Ant) Eclipse提供了导出为Ant build.xml创建GWT编译规则,gwt,ant,Gwt,Ant,我试图使Eclipse可编译的GWT项目也可以在命令行上编译(通过Ant) Eclipse提供了导出build.xml的功能;这对于编译类来说效果很好,但由于GWT的特殊功能都是通过插件提供的,因此不包括这些规则 谷歌提供了为新项目创建build.xml文件的功能。我已经将由此生成的规则合并到Eclipse导出的文件中 编译(Eclipse提供的部分)成功 下面是编译到javascript的任务: <target name="gwtc" depends="build" descript
build.xml
的功能;这对于编译类来说效果很好,但由于GWT的特殊功能都是通过插件提供的,因此不包括这些规则
谷歌提供了为新项目创建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>
尝试运行任务时,出现以下错误:
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?您确定您的GWT应用程序的源代码位于classpath上吗?GWT正在将java源代码编译为js,而不是*.class文件。确保在传递给GWT编译器的类路径上有该库/jar和任何其他需要的源代码,因为它需要能够在GWT libs中找到java源代码才能编译它们,与Javac编译器不同,than可以仅使用提供的.class文件对库进行编译 这是我的ant gwtc编译宏。(已删除前导<代码> 这可以从任何目标调用,因此: 我的目标是编译一个名为“Admin”的特定模块,其中文件Admin.gwt.xml位于.ta.Admin中。我有一个调试和生产构建类型,每个模块都有一个.gwt.xml,以加快编译以进行调试(更少的用户代理和语言=更少的排列)
targetname=“gwtadmin”dependens=“compile,buildtype”description=“GWT compile Admin”>
但是,如果我使用GWT编译类路径,那么关键的一部分就是它。下面是我设置路径的目标:
target name="gwtPath">
<path id="gwt.classpath">
<pathelement location="${gwt.sdk.dir}/gwt-user.jar" />
<pathelement location="${gwt.sdk.dir}/gwt-servlet.jar" />
</path>
<!-- For GWT compile we need a path with source AND the GWT Compiler classes -->
<path id="gwtCompile.classpath">
<path refid="source.classpath" />
<!-- This is put after source, so GWT Compiler it doesn't pick up out of date versions of old css and uibinder
files in classes generated by Eclipse/GWT Plugin -->
<path refid="classpath" />
<path refid="tool.classpath" />
</path>
</target>
targetname=“gwtPath”>
Yep.ls src/edu/calpoly/csc/scheduler/view/client
显示了GWTView.java
@XiongChiamiov Ok,这意味着gwt.xml不包含视图
包。文件edu/calpoly/csc/scheduler.gwt.xml是否包含
标记?它没有;我添加了它,但仍然得到相同的错误。我已将问题更新到包括完整的scheduler.gwt.xml
文件内容。但是我添加了scheduler/view
,这很有效-至少在构建部分是这样。非常感谢!
macrodef name="gwtCompileApplication" >
<attribute name="app" />
<attribute name="extraArgs" default="" />
<attribute name="gwtcExtras" default="" />
<sequential>
<java classpathref="gwtCompile.classpath" classname="com.google.gwt.dev.Compiler" fork="true" failonerror="true">
<jvmarg value="-Xmx512M" />
<arg value="-strict" />
<!-- Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
<arg value="-logLevel" />
<arg value="DEBUG" />
-->
<!-- request detailed, non-obfuscated JS output
<arg value="-style" />
<arg value="DETAILED" />
-->
<arg value="-localWorkers" />
<arg value="4" />
<arg value="-war" />
<arg value="${war.dir}" />
<arg value="-deploy" />
<arg value="deploy" />
<!-- These two lines have been removed as otherwise it won't work on Mac OS X
<arg value="@{extraArgs}" />
<arg value="@{gwtcExtras}" />
-->
<!-- This can be used to see more details about warnings, but they will be converted to errors and build will fail
<arg value="-strict" />
-->
<arg value="-logLevel" />
<arg value="INFO" />
<arg value="@{app}" />
</java>
</sequential>
</macrodef>
target name="gwtcAdmin" depends="compile, buildtype" description="GWT Compile Admin" >
<gwtCompileApplication app="com.bcntouch.ta.Admin.${build_type}_Admin" extraArgs="${gwtcArgs}" gwtcExtras="${gwtcExtras}"/>
</target>
target name="gwtPath">
<path id="gwt.classpath">
<pathelement location="${gwt.sdk.dir}/gwt-user.jar" />
<pathelement location="${gwt.sdk.dir}/gwt-servlet.jar" />
</path>
<!-- For GWT compile we need a path with source AND the GWT Compiler classes -->
<path id="gwtCompile.classpath">
<path refid="source.classpath" />
<!-- This is put after source, so GWT Compiler it doesn't pick up out of date versions of old css and uibinder
files in classes generated by Eclipse/GWT Plugin -->
<path refid="classpath" />
<path refid="tool.classpath" />
</path>
</target>