-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmaven_push.gradle
45 lines (37 loc) · 1012 Bytes
/
maven_push.gradle
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
apply plugin: 'maven'
apply plugin: 'signing'
configurations {
deployerJars
}
repositories {
mavenCentral()
}
// 判断版本是Release or Snapshots
def isReleaseBuild() {
return !VERSION.contains("SNAPSHOT");
}
// 获取仓库url
def getRepositoryUrl() {
return isReleaseBuild() ? RELEASE_URL : SNAPSHOT_URL;
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}
pom.version = VERSION
pom.artifactId = POM_ARTIFACT_ID
pom.groupId = GROUP
repository(url: getRepositoryUrl()) {
authentication(userName: NAME, password: PASSWORD) // maven授权信息
}
}
}
}
// 进行数字签名
signing {
// 当 发布版本 & 存在"uploadArchives"任务时,才执行
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}