eclipse工程的目录结构:
src main java com app ilxlf client server shared resources com app ilxlf client server sharedbuild.gradle
区别在与这里我删除掉了lib目录和war目录。
现在新的目录结构出来了,但是不能直接导入到Eclipse里面。因为当前还没有.classpath, .project文件和settings目录。
【注:如果用SpringSource Tool Suite, 可以使用“按gradle project”来导入的方式直接导入,不需要运行下面的命令。】
在当前目录下在命令行里运行下面的命令:
gradle eclipse
这个时候就会生成Eclipse所需的文件和目录。包括.classpath, .project, settings, war
我们看一下为什么会生成这些文件和目录,主要的工作就是build.gradle这个文件:
defaultTasks "build"apply plugin: 'war'apply plugin: 'eclipse'sourceCompatibility = '1.6'targetCompatibility = '1.6'eclipseProject { projectName= 'app' buildCommand='org.eclipse.jdt.core.javabuilder'}configurations { compile}repositories { mavenCentral()}dependencies { compile 'javax.validation:validation-api:1.0.0.GA:sources' compile 'javax.validation:validation-api:1.0.0.GA' compile 'com.google.gwt:gwt-dev:2.4.0' compile 'com.google.gwt:gwt-user:2.4.0' compile 'com.google.gwt:gwt-servlet:2.4.0' providedCompile 'javax.servlet:servlet-api:2.5'}task gwtc(type: JavaExec) { outputs.dir new File('war') inputs.dir new File('src') main = 'com.google.gwt.dev.Compiler' maxHeapSize = '512M' args '-style OBFUSCATED com.app.ilxlf.App -war war'.split() classpath sourceSets.main.java.srcDirs classpath sourceSets.main.resources.srcDirs classpath configurations.compile.asPath.split(';')}war { dependsOn 'gwtc' from 'war' basename='app'}
里面的内容就不解释了。这辈子估计也忘不了。
下一步就是导入到Eclipse里面, 然后打开项目的Web Toolkit, 下面就可以使用“Run As -----> Web Application"运行这个项目了。
这里有几个前提需要提醒一下:首先需要下载gradle, 其次下载GWT Eclipse Plugin.
如果大家选择SpringSource Tool Suite,它对这两个plugin的支持非常好。推荐使用。