Gradle的标准模板和Maven的是一样的:
引用
APP_PROJECT_ROOT
|-- build.gradle
|-- build/
`-- src
|-- main
| |-- groovy/
| |-- java/
| `-- resources/
`-- test
|-- groovy/
|-- java/
`-- resources/
但是目前Gradle不像Maven那样通过命令行就能生成模板工程。可以自己写脚本(Task)生成模板工程,也可以使用Plugin。
按照以下步骤安装插件:
(1)从https://launchpad.net/gradle-templates 下载templates-1.2.jar 后放入一个新建的文件夹$GRADLE_HOME\customPlugins中。
(2)编写一个build.gradle
引用
buildscript{
repositories {
flatDir dirs: "${gradle.gradleHomeDir}/customPlugins"
}
dependencies {
classpath ':templates:1.2'
}
}
apply plugin: 'templates'
(3)执行脚本
引用
D:\>gradle --stacktrace
:help
Welcome to Gradle 1.0.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 5.188 secs
(4)查看Task
引用
D:\>gradle task
:tasks
------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------
Help tasks
----------
dependencies - Displays the dependencies of root project ''.
help - Displays a help message
projects - Displays the sub-projects of root project ''.
properties - Displays the properties of root project ''.
tasks - Displays the tasks runnable from root project '' (some of the displayed tasks may belong to
subprojects).
Template tasks
--------------
createGradlePlugin - Creates a new Gradle Plugin project in a new directory named after your projec
.
createGroovyClass - Creates a new Groovy class in the current project.
createGroovyProject - Creates a new Gradle Groovy project in a new directory named after your proje
t.
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 proje
t.
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.
To see all tasks and more detail, run with --all.
BUILD SUCCESSFUL
Total time: 3.766 secs
(5)创建Java模板工程
引用
D:\>gradle createJavaProject
> Building > :createJavaProject
??> Project Name: TestRen
??> Group: [testren] testgroup
??> Version: [1.0] 1.0
:createJavaProject
BUILD SUCCESSFUL
Total time: 30.578 secs
(6)生成的工程
引用
TestRen
│ build.gradle
│ gradle.properties
│ LICENSE.txt
│
└─src
├─main
│ ├─java
│ └─resources
└─test
├─java
└─resources
(7)使用STS(SpringSource Tool Suite)导入工程,以后的构建就很方便了。
- 大小: 10.5 KB
- 大小: 15.2 KB
- 大小: 18.3 KB
分享到:
相关推荐
Android Studio Gradle离线包下载,其中包含:gradle-1.10-all.zip; gradle-1.11-all.zip; gradle-2.0-all.zip; gradle-2.2.1-all.zip; gradle-2.2-all.zip; gradle-2.3-all.zip;gradle-2.10-all.zip; gradle-...
gradle-6.7.1-bin.zip gradle-6.7.1-bin.zip gradle-6.7.1-bin.zipgradle-6.7.1-bin.zip gradle-6.7.1-bin.zip gradle-6.7.1-bin.zip gradle-6.7.1-bin.zipgradle-6.7.1-bin.zipgradle-6.7.1-bin.zip gradle-6.7.1-...
gradle-6.7-all.zip https://code.aliyun.com/kar/gradle-all-zip/raw/master/gradle-6.7-all.zip gradle-6.6.1-all.zip https://code.aliyun.com/kar/gradle-all-zip/raw/master/gradle-6.6.1-all.zip gradle-6.6-...
Android gradle 资源下载 gradle-6.7.1-all.zip gradle-4.10.1-all.zip
gradle-8.0-all和gradle-8.0-bin最新版本,因国内下载极其慢,我就上传上来了,希望大家可以用到。请尽快深刻通过!
gradle-4.4-all.zip Gradle是一个基于JVM的构建工具,是一款通用灵活的构建工具,支持maven, Ivy仓库,支持传递性依赖管理,而不需要远程仓库或者是pom.xml和ivy.xml配置文件,基于Groovy,build脚本使用Groovy...
文件包含gradle-6.0.1-all.zip和gradle-6.0.1-bin.zip 下载后放到本地目录,设置distributionUrl即可进行编译 如需其他资源可以留言
gradle-6.7-bin.zip 分享了,官网站下载的下载地址: https://dl-download.csdn.net/down11/20190419/11e97afb8a4c05a6f253270eecc9f3a7.zip?response-content-disposition=attachment%3Bfilename%3D%22gradle...
gradle-5.6.4-all.zip gradle-5.4.1-all.zip gradle-5.1.1-all.zip gradle-4.10.1-all.zip gradle-4.4-all.zip
然后将这个zip文件包复制到C:\Users\nin的用户名\.gradle\wrapper\dists\gradle-4.10.1-all\455itskqi2qtf0v2sja68alqd ,不同电脑可能路径有不同。具体说,就是在c盘,你的用户名的文件夹内有一个 .gradle文件夹,...
gradle的如下版本gradle-6.7.1-bin.rar gradle的如下版本gradle-6.7.1-bin.rar gradle的如下版本gradle-6.7.1-bin.rar gradle的如下版本gradle-6.7.1-bin.rar
gradle-7.2-all,gradle-7.0.2-bin
gradle-4.7-all.zip 离线包下载.zip。官网下载不成功的,嫌官网下载速度慢的,可以直接在这里下载
gradle-6.7.1-bin离线包
解决官网下载慢的问题 gradle-6.8.3-all.zip gradle-6.8.3-bin.zip
gradle-4.4-rc-2-src.zip和gradle-4.4-rc-2-src.zip.sha256,看准是不是需要这个,再下载。
gradle-8.2-bin.zip
gradle-7.3.3-bin
gradle-7.4-bin
gradle-7.2-bin.rar