Gradle基础配置

  1. gradle下载地址:http://services.gradle.org/distributions/
    从官网下载gradle后,解压,然后配置环境变量GRADLE_HOME,并将%GRADLE_HOME%/bin添加到path中,通过命令

gradle –v 测试是否安装成功,如果显示gradle版本信息,则安装成功

  1. settings.gradle设置多工程依赖
    rootProject.name = ‘activeMq’
    include ‘domain’
    include ‘service’
    include ‘war’

  2. build.gradle常用配置:
    Java插件定义 Apply plugin: ’java’
    添加Maven仓库 :
    Repositories{
    mavenCentral()
    maven{
    url ‘http://repo.sprinig.io/milestone/’
    }
    }
    添加依赖:
    dependencies {
    compile group: ‘commons-collections’, name: ‘commons-collections’, version: ‘3.2’
    testCompile group: ‘junit’, name: ‘junit’, version: ‘4.+’
    }

compile:
编译范围依赖在所有的 classpath 中可用,同时它们也会被打包
runtime:
runtime 依赖在运行和测试系统的时候需要,但在编译的时候不需要。比如,你可能在编译的时候只需要 JDBC API JAR,而只有在运行的时候才需要 JDBC 驱动实现
testCompile:
测试期编译需要的附加依赖
testRuntime:
测试运行期需要

外部依赖包含 group,name 和 version 几个属性。根据选取仓库的不同,group 和 version 也可能是可选的。
当然,也有一种更加简洁的方式来声明外部依赖。采用:将三个属性拼接在一起即可。“group:name:version”

发布到 Maven私库:

//发布到私服
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.name
version project.version
//若是war包,就写components.web,若是jar包,就写components.java
from components.java
}
}
}

//私服配置
publishing {
repositories {
maven{
url ‘http://127.0.0.1:8081/repository/maven-snapshots/
credentials {
username ‘admin’
password ‘admin123’
}
}
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值