gradle使用
来源:互联网 发布:python 卷积 编辑:程序博客网 时间:2024/05/19 15:44
官方指导手册:http://www.gradle.org/docs/2.0/userguide/userguide.html
1、gradle 常用命令:
gradle build
gradle test
gradle compilejava
gradle jar
gradle clean
gradle jar
gradle init
//生成wrapper包
gradle wrapper
gradle compilejava
gradle javadoc
gradle dependencies
gradle help
gradle check
gradle test
gradle -v
gradle --info
gradle --debug
gradle --help
列出可执行的所有任务(即查看可以执行的命令)
gradle tasks
gradle -q tasks
依赖:
compile
The dependencies required to compile the production source of the project.
runtime
The dependencies required by the production classes at runtime. By default, also includes the compile time dependencies.
testCompile
The dependencies required to compile the test source of the project. By default, also includes the compiled production classes and the compile time dependencies.
testRuntime
The dependencies required to run the tests. By default, also includes the compile, runtime and test compile dependencies.
gradle -m clean compileJava
进入GUI界面
gradle --gui
gradle IDE
E.1. IntelliJ
E.2. Eclipse
2、gradle实例:
- apply plugin: 'java'
- sourceCompatibility = 1.5
- version = '1.0'
- repositories {
- mavenCentral()
- //可以自定义中央仓库
- maven {
- url "http://repo.mycompany.com/maven2"
- }
- }
- def dest = "dest"
- task copy(type: Copy) {
- description='复制脚本'
- from "source"
- into dest
- }
- task getinfo<<{
- description='获取gradle工程基本信息'
- println project.name;
- println project.description;
- println project.buildDir.canonicalPath;
- println project.defaultTasks.toListString;
- println project.gradle.gradleHomeDir.absolutePath;
- println project.gradle.gradleUserHomeDir.absolutePath;
- println project.gradle.gradleVersion;
- println project.properties.toMapString;
- println project.getDefaultTasks().toListString;
- }
- task wrapper(type: Wrapper) {
- description='任务描述,各种说明'
- gradleVersion = '2.0'
- }
- task fileinfo << {
- println "using build file '$buildFile.name' in '$buildFile.parentFile.name'."
- }
- //
- task hello << {
- println 'Hello Earth'
- }
- hello.doFirst {
- println 'Hello Venus'
- }
- hello.doLast {
- println 'Hello Mars'
- }
- hello << {
- println 'Hello Jupiter'
- }
- //动态依赖 执行命令: gradle -q task1 、 gradle -q task3
- 4.times { counter ->
- task "task$counter" << {
- println "I'm task number $counter"
- }
- }
- task taskX(dependsOn: 'hello_intro') << {
- println 'taskX'
- }
- //任务依赖
- task hello_intro << {
- println 'Hello world!'
- }
- task intro(dependsOn: hello_intro) << {
- println "I'm Gradle"
- }
- //我是注释,数字遍历
- task count << {
- 40.times { print "$it " }
- }
- /**
- * 大小写转换
- */
- task upper << {
- description='大小写转换'
- String someString = 'uper DEMO mY_nAmE'
- println "Original: " + someString
- println "Upper case: " + someString.toUpperCase()
- println "lower case: " + someString.toLowerCase()
- }
- task hello2<<{
- println("hello2")
- }
- task hello3{
- //doLast是方法
- doLast{
- println("Hello world! Love you,gradle")
- }
- }
- task fuck<<{
- println 'fuck'
- }
- task mytask<<{
- if(System.properties['path'])
- {
- println("i love java and gradle")
- }else{
- println("fuck");
- }
- }
- dependencies {
- testCompile group: 'junit', name: 'junit', version: '4.11'
- compile 'org.springframework:spring-context:3.0.4.RELEASE'
- compile group:'commons-collections',name:'commons-collections',version:'3.2'
- compile('com.alibaba:fastjson:1.2.0')
- }
- gradle使用
- Gradle 使用
- gradle使用
- gradle使用
- gradle 使用
- Gradle使用
- gradle使用
- gradle使用
- Gradle 使用命令行操作Gradle
- Gradle第十二章:使用Gradle 图形用户界面
- gradle--第十一章 使用Gradle命令行
- gradle--第十一章 使用Gradle命令行2
- gradle--第十一章 使用Gradle命令行3
- gradle 2.10 The Gradle Daemon使用详解
- Gradle学习笔记 使用Gradle Wrapper
- gradle - 使用介绍(一)
- Ant,Maven,Gradle使用。
- gradle使用文档
- iOS 拨打电话的方法总结
- 排列的字典序问题
- coderforce 598B Queries on a String
- 对话框自适应大小ReSize
- 笔记九(勾股定理应用)
- gradle使用
- java 中的包装类
- 划分数
- 八数码的八重境界
- 20151116 密码文件
- CSS定位的兼容性问题
- [TwistedFate]UIActionSheet
- [Err] 1222 - The used SELECT statements have a different number of columns
- 【数据结构与算法分析】2.3 求X的N次幂