-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublishing.gradle
100 lines (90 loc) · 3.72 KB
/
publishing.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'maven-publish'
version = project.ext.VERSION_NAME
group = POM_GROUP
def keyFile = rootProject.file("key.properties")
def keyProp = new Properties()
keyFile.exists() ? keyProp.load(keyFile.newInputStream()) : keyProp
afterEvaluate { project ->
publishing {
publications {
println "publish ${project.name}"
library(MavenPublication) {
groupId POM_GROUP
artifactId POM_ARTIFACT_ID
version project.ext.VERSION_NAME
artifact("${buildDir}/outputs/aar/${artifactId}-release.aar")
println "publish ${buildDir}/outputs/aar/${artifactId}-release.aar"
pom {
name = POM_NAME
description = POM_DESCRIPTION
url = POM_URL
scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = POM_DEVELOPER_ID
organizationUrl = POM_DEVELOPER_ORGANIZATION_URL
roles = ["developer"]
}
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Note that this only handles implementation
// dependencies. In the future, may need to add api,
// etc.
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
url = "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = keyProp.getProperty("ossrhUsername")
password = keyProp.getProperty("ossrhPassword")
}
}
}
}
signing {
if (keyFile.exists()) {
def signingPassword = keyProp.getProperty("signing.password")
def keyId = keyProp.getProperty("signing.keyId")
def signingKey = keyProp.getProperty("signing.inMemoryKey").replace("\\n", "\n")
useInMemoryPgpKeys(keyId, signingKey, signingPassword)
sign publishing.publications.library
}
}
}