从gwt-project创建一个.war文件 [英] create a .war file from gwt-project
问题描述
如何在eclipse中从我的gwt-project创建一个.war文件? 我总是使用Ant构建文件,因此只需点击一次即可将项目编译并打包成战争。
使用以下内容将xml文件添加到项目中:
< project name =testbasedir =。默认= 默认 >
< property name =src.dirvalue =src/>
< property name =build.dirvalue =war/>
<路径id =compile.classpath>
< fileset dir =$ {build.dir} / WEB-INF / lib>
< include name =** / *。jar/>
< include name =** / *。xml/>
< / fileset>
< / path>
< target name =defaultdepends =gwtc,buildwar,deploy>
< / target>
< target name =gwtcdescription =GWT编译成JavaScript>
< java failonerror =truefork =trueclassname =com.google.gwt.dev.Compiler>
< classpath>
< pathelement location =$ {src.dir}/>
<路径refid =compile.classpath/>
< / classpath>
< arg line = - logLevel INFO/>
< jvmarg value = - Xmx1024M/>
< arg value =YourProject.EntryPointClass/>
< / java>
< / target>
< target name =buildwar>
< exclude name =WEB-INF / **/>
< webinf dir =war / WEB-INF />
< include name =** / gwt-servlet.jar/>
< include name =** / classes / **/>
< / webinf>
< / war>
< / target>
< target name =deploy>
< / target>
< / project>
(编辑`YourProject.EntryPointClass到您的EntryPoint-class的路径)
您需要添加 gwt-user.jar
和 gwt-dev.jar
到您的项目构建路径(右键单击您的项目 - >构建路径 - >添加外部存档)。
如果您现在查看问题得到两个文件在服务器的类路径中不可用的警告。您可以使用QuickFix将其复制到 WEB-INF / lib
或隐藏警告。构建文件不会在war文件中包含这两个文件。
编译和创建文件只需右键单击xml文件,选择运行为Ant Build。
How do I create a .war-file from my gwt-project in eclipse?
I always use Ant build file, so the project gets compiled and packaged as a war with one click.
Add an xml-file to your project with the following content:
<project name="test" basedir="." default="default">
<property name="src.dir" value="src" />
<property name="build.dir" value="war" />
<path id="compile.classpath">
<fileset dir="${build.dir}/WEB-INF/lib">
<include name="**/*.jar" />
<include name="**/*.xml" />
</fileset>
</path>
<target name="default" depends="gwtc, buildwar,deploy">
</target>
<target name="gwtc" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="${src.dir}" />
<path refid="compile.classpath" />
</classpath>
<arg line="-logLevel INFO" />
<jvmarg value="-Xmx1024M" />
<arg value="YourProject.EntryPointClass" />
</java>
</target>
<target name="buildwar">
<war basedir="war" destfile="YourProject.war" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="war/WEB-INF/">
<include name="**/gwt-servlet.jar" />
<include name="**/classes/**" />
</webinf>
</war>
</target>
<target name="deploy">
<copy file="YourProject.war" todir="." />
</target>
</project>
(Edit `YourProject.EntryPointClass to the path to your EntryPoint-class)
You would need to add gwt-user.jar
and gwt-dev.jar
to your projects build path(right click on your project -> Build Path -> Add External Achives).
If you now look at your "Problems"-view you get a warning that the two files are not available on the server's class path. You can use the QuickFix to either copy it to WEB-INF/lib
or hide the warning. The build file will not include those two file in the war-file.
All you need to do to compile and create the file is to right click the xml-file and select run as Ant Build.
这篇关于从gwt-project创建一个.war文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!