-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupload_maven.gradle
More file actions
52 lines (47 loc) · 1.85 KB
/
upload_maven.gradle
File metadata and controls
52 lines (47 loc) · 1.85 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
apply plugin: 'maven-publish'
def MAVEN_LOCAL_PATH = 'https://s01.oss.sonatype.org/content/repositories/releases/'
def ARTIFACT_ID = project.archivesBaseName
def GROUP_ID = 'io.github.ckenergy'
//def ACCOUNT = username
//def PASSWORD = password
def _version = CETVersion
//gradle 7.0以上 用这个方式上传 https://developer.android.com/studio/build/maven-publish-plugin?hl=zh-cn
afterEvaluate {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ACCOUNT = properties.getProperty('username')
def PASSWORD = properties.getProperty('password')
publishing {
publications {
release(MavenPublication) {
// Applies the component for the release build variant.
if (project.plugins.hasPlugin("com.android.library")) {
//aar包用下面这个
from components.release
}else {
//jar包用下面这个
from components.java
}
// You can then customize attributes of the publication as shown below.
groupId = GROUP_ID
artifactId = ARTIFACT_ID
version = _version
}
// Creates a Maven publication called "release".
}
repositories {
// 定义一个 maven 仓库
maven {
allowInsecureProtocol(true)
// 可以有且仅有一个仓库不指定 name 属性,会隐式设置为 Maven
// 根据 versionName 来判断仓库地址
url = MAVEN_LOCAL_PATH
// 仓库用户名密码
credentials {
username = ACCOUNT
password = PASSWORD
}
}
}
}
}