2008年2月17日日曜日

GWT-Ext用のEclipse内でのbuild.xmlを考える.

・必要なファイル達についてはこちらの'0'の項を参照してください.
・プロジェクト('MyProject')の作成はこちらの'1-3'を参照してください.


(必要なら)web.xmlを用意.
MyProject/WEB/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

<welcome-file-list>
<welcome-file>MyProject.html</welcome-file>
</welcome-file-list>

</web-app>



MyProject/build.properties
#
src.dir=src
dist.dir=dist

#
gwt.location=GWT_HOME
gwtext.location=GWTExt_HOME
ext.location=ExtJS_HOME

#
project.package=com.mycompany
src.public.dir=${src.dir}/${project.package}/public
gwt.entrypoint.class=${project.package}.MyProject
content.dir=${dist.dir}/${gwt.entrypoint.class}
war.name=MyProjectWeb

#
tomcat.webapps=TOMCAT_HOME/webapps


MyProject/build.xml
<project name="MyProject" default="build" basedir=".">
<property file="build.properties" />

<path id="gwt.compile.classpath" >
<pathelement path="${java.class.path}/" />
<pathelement location="${src.dir}" />
<pathelement location="${gwt.location}/gwt-user.jar" />
<pathelement location="${gwt.location}/gwt-dev-mac.jar" />
<pathelement location="${gwtext.location}/gwtext.jar" />
</path>

<target name="clean" >
<delete dir="${dist.dir}" />
</target>

<target name="build" >
<java classpathref="gwt.compile.classpath"
classname="com.google.gwt.dev.GWTCompiler"
maxmemory="128m"
fork="true">
<arg value="-out" />
<arg value="${dist.dir}" />
<arg value="${gwt.entrypoint.class}" />
</java>
</target>

<target name="dist" depends="build">
<mkdir dir="${content.dir}/js/ext" />
<copy todir="${content.dir}/js/ext">
<fileset dir="${ext.location}">
<exclude name="*-debug.js" />
<include name="*.js" />
<include name="adapter/**/*" />
<include name="resources/**/*" />
</fileset>
</copy>
<copy todir="${content.dir}/WEB-INF">
<fileset dir="WEB-INF">
<include name="web.xml"/>
</fileset>
</copy>
<mkdir dir="${content.dir}/WEB-INF/lib" />
<copy todir="${content.dir}/WEB-INF/lib">
<fileset dir="${gwt.location}">
<include name="gwt-servlet.jar"/>
</fileset>
</copy>
<mkdir dir="${content.dir}/WEB-INF/classes" />
<copy todir="${content.dir}/WEB-INF/classes">
<fileset dir="bin">
<include name="**/*.class"/>
</fileset>
</copy>
<jar jarfile="${dist.dir}/${war.name}.war"
basedir="${dist.dir}/${gwt.entrypoint.class}" />
</target>

<target name="deploy" depends="dist">
<copy todir="${tomcat.webapps}"
file="${dist.dir}/${war.name}.war" />
</target>
</project>

#WEB-INF以下にclasses/**/*.class, lib/servlet.jarをcopyするところはRPC用.


プロジェクトはこんな感じ.



Ant実行終了時にできたファイル等をExplorerに反映するためにRefreshにチェックをいれておくと便利.


MyProject.javaをいじる前にMyProject.gwt.xmlのmodule要素の直下に一行追加するのをお忘れないように…
#私が忘れてハマっただけです…
MyProject/src/sample/MyProject.gwt.xml
<module>
<inherits name='com.gwtext.GwtExt' />

0 件のコメント: