gradle eclipse web模板项目构建

来源:互联网 发布:电脑usb001端口是哪个 编辑:程序博客网 时间:2024/04/27 05:01

1.gradle 自带插件不支持web项目骨架创建,必须要用到第三方gradle模板插件.

在gradle 安装目录下的init.d目录下新建文件init.gradle,添加脚本:

gradle.beforeProject { prj ->
    prj.apply from: 'http://www.tellurianring.com/projects/gradle-plugins/gradle-templates/apply.groovy'
}

保存后,用gradle tasks在命令行窗口查看gradle初始化任务就会在原来的基础上新增如下任务:

Template tasks
--------------
createGradlePlugin - Creates a new Gradle Plugin project in a new directory named after your project.
createGroovyClass - Creates a new Groovy class in the current project.
createGroovyProject - Creates a new Gradle Groovy project in a new directory named after your project.
createJavaClass - Creates a new Java class in the current project.
createJavaProject - Creates a new Gradle Java project in a new directory named after your project.
createScalaClass - Creates a new Scala class in the current project.
createScalaObject - Creates a new Scala object in the current project.
createScalaProject - Creates a new Gradle Scala project in a new directory named after your project.
createWebappProject - Creates a new Gradle Webapp project in a new directory named after your project.
exportAllTemplates - Exports all the default template files into the current directory.
exportGroovyTemplates - Exports the default groovy template files into the current directory.
exportJavaTemplates - Exports the default java template files into the current directory.
exportPluginTemplates - Exports the default plugin template files into the current directory.
exportScalaTemplates - Exports the default scala template files into the current directory.
exportWebappTemplates - Exports the default webapp template files into the current directory.
initGradlePlugin - Initializes a new Gradle Plugin project in the current directory.
initGroovyProject - Initializes a new Gradle Groovy project in the current directory.
initJavaProject - Initializes a new Gradle Java project in the current directory.
initScalaProject - Initializes a new Gradle Scala project in the current directory.
initWebappProject - Initializes a new Gradle Webapp project in the current directory.


新建一个空目录,然后在下面直接输入gradle initWebappProject后就会生成web项目骨架,如果是要构建java web项目,只要在生成的build.gradle下应用java插件即可

2.将生成的web项目模板导入eclipse.模板生成命令生成的原始骨架是不支持eclipse导入的,要想项目能够导入到eclipse中,我们还要在build.gradle中应用eclipse或eclipse-wtp插件.eclipse 插件成功应用后,运行任务gradle eclipse就会生成一些eclipse的配置文件,项目就变成了eclipse项目.

3.每次编辑build.gradle 脚本添加以来后,执行gradle eclipse即可下载依赖,并添加到classpath中来

0 0
原创粉丝点击