使用工具创建GWT Maven Project有两种方式,使用GWT Command-line Tools和Maven GWT Plugin。
1. 使用GWT Command-line Tools创建maven project
要使用webAppCreator命令,
运行
webAppCreator -help
WebAppCreator [-overwrite] [-ignore] [-templates template1,template2,...] [-out dir] [-junit pathToJUnitJar] [-maven] [-noant] moduleName
where
-overwrite Overwrite any existing files
-ignore Ignore any existing files; do not overwrite
-templates Specifies the template(s) to use (comma separeted). Defaults to 'sample,ant,eclipse,readme'
-out The directory to write output files into (defaults to current)
-junit Specifies the path to your junit.jar (optional)
-maven Deprecated. Create a maven2 project structure and pom file (default disabled). Equivalent to specifying 'maven' in the list of templates.
-noant Deprecated. Do not create an ant configuration file. Equivalent to not specifying 'ant' in the list of templates.
and
moduleName The name of the module to create (e.g. com.example.myapp.MyApp)
如果要创建一个纯净的maven project,要用到-maven参数,还要指定GWT module name。
- 先创建你的项目目录,例如gwtmavenproject
- 在目录中运行:webAppCreator -maven com.martian.gwtmavenproject.MainPanel,com.martian.gwtmavenproject.MainPanel是moduleName,com.martian.gwtmavenproject是entry-point module的位置,同时pom文件也以com.martian.gwtmavenproject作为groupId、MainPanle作为artifactId
- 可能你需要修改一下pom文件中的groupId和artifactId
2. 使用Mave GWT Plugin创建maven project
假设我们要创建一个maven project,有以下条件
groupId=com.martian
artifactId=gwtmavenproject
version=1.0
gwtModuleName=MainPanel
运行
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.0 -DgroupId=com.martian -DartifactId=gwtmavenproject -Dversion=1.0-SNAPSHOT -Dmodule=MainPanel -DinteractiveMode=false
注意:
请注意,WebAppCreator -maven 已经被丢弃,不推荐使用!