Gradle 仓库设置
来源:互联网 发布:android 数据加密 编辑:程序博客网 时间:2024/06/03 20:50
Gradle 的主要配置文件是 build.gradle
,如果要使用 Maven 库,可以如下配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
repositories {
//Maven中心库(http://repo1.maven.org/maven2)
mavenCentral()
//本地库,local repository(${user.home}/.m2/repository)
mavenLocal()
//指定库
maven {
url
"http://repo.mycompany.com/maven2"
}
//指定库
maven {
// Look for POMs and artifacts, such as JARs, here
url
"http://repo2.mycompany.com/maven2"
// Look for artifacts here if not found at the above location
artifactUrls
"http://repo.mycompany.com/jars"
artifactUrls
"http://repo.mycompany.com/jars2"
}
//带认证的库
maven {
credentials {
username
'user'
password
'password'
}
url
"http://repo.mycompany.com/maven2"
}
}
其中有必要说说 mavenLocal(),能不能用 Maven 本地库也是笔者最关心的特性之一。
经实践,发现直接使用 mavenLocal() 时,gradle 会查找 Maven 配置文件 ${user.home}/.m2/settings.xml 来定位本地 Maven 库的路径,如果没有找到该文件,则默认本地库路径为 ${user.home}/.m2/repository,而笔者的 Maven 配置文件在 $M2_HOME/conf/settings.xml ,gradle 竟然不能读取到这个配置文件。
这个问题已经作为一个Improvement(#GRADLE-1900 [5])被提出,并显示在 1.0-milestone-9 版本中已经修正,而使用的1.0正式版时,竟然还有这个问题,真是相当诡异。
既然不能直接使用 mavenLocal(),就必须做一些变通,笔者最终测试用的 build.gradle
文件如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apply plugin:
'java'
version:
'1.0-SNAPSHOT'
group:
'org.opoo'
repositories {
maven{ url
"file:///D:/m2.repo"}
//mavenLocal()
//mavenCentral()
}
dependencies {
compile group:
'commons-lang'
, name:
'commons-lang'
, version:
'2.1'
compile group:
'commons-logging'
, name:
'commons-logging'
, version:
'1.0.4'
testCompile group:
'junit'
, name:
'junit'
, version:
'4.+'
}
阅读全文
0 0
- Gradle 仓库设置
- Gradle修改Maven仓库
- Gradle仓库配置
- Gradle仓库简介
- Gradle使用Maven仓库
- Gradle-仓库详解
- Gradle的仓库搭建
- Gradle使用Maven仓库
- Gradle仓库配置
- gradle仓库配置
- Gradle更换maven仓库
- Gradle仓库配置
- 仓库设置
- Gradle 修改 Maven 仓库地址
- Gradle 修改 Maven 仓库地址
- Step into Gradle - 05 - 仓库
- Gradle 修改 Maven 仓库地址
- Gradle 修改 Maven 仓库地址
- i.mx6ul linux驱动开发—基于Device tree机制的驱动编写
- 课时5 文件基本操作
- 箱子排序
- C++优化之使用emplace
- 2017020
- Gradle 仓库设置
- 学习WEB的干货资料
- 求1+2!+3!+...+N!的和 oj44
- Could not obtain transaction-synchronized Session for current thread
- /*Oracle创建序列*/
- 51nod 1246 罐子和硬币 模拟 思维
- 百万年薪的人才泡沫与人工智能的虚假繁荣
- 文章标题
- 使用axis2生成webservice服务端和客户端