一。下载并解压安装
配置环境变量,cmd命令gradle -v查看是否安装成功
二。配置本地仓库与远程仓库
环境变量:Gradle_USER_HOME 指向本地仓库 D:\Maven\apache-maven-3.5.4\cangku
三。Build.Gradle范本
repositories {
mavenLocal()
mavenCentral()
maven { url "http://47.96.230.188:8081/repository/Public_Repositories/" }
}
dependencies {
testCompile group:'junit',name:'junit',version:'4.12'
compileOnly "org.projectlombok:lombok:${lombok_version}"
compile group:'junit',name:'junit',version:'4.12'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation "org.springframework.boot:spring-boot-starter-actuator"
//lombok工具包
annotationProcessor "org.projectlombok:lombok:${lombok_version}"
mybatisGenerator "mysql:mysql-connector-java"
mybatisGenerator "org.mybatis.generator:mybatis-generator-core:1.3.7"
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
四。Gradle dependenciens的各种依赖说明
implementation 对该项目有依赖的项目将无法访问到使用该命令编译的依赖中的任何程序,也就是将该依赖隐藏在内部,而不对外部公开。
compile 这种是我们最常用的方式,使用该方式依赖的库将会参与编译和打包。
api 完全等同于compile指令。
testCompile 只在单元测试代码的编译以及最终打包测试apk时有效。
debugCompile 只在debug模式的编译和最终的debug apk打包时有效
releaseCompile 仅仅针对Release模式的编译和最终的Release apk打包
annotationProcessor
compileOnly 只编译不打包
五。打jar包
见maven 打jar包参考