-
Notifications
You must be signed in to change notification settings - Fork 3
/
publishing.gradle
168 lines (138 loc) · 5.43 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// this relies on a vault connection or the presence of a publish.properties file with:
// bintray_api_key
// bintray_username
def gitUrl = "https://github.com/uport-project/kotlin-common.git"
def groupID = "com.github.uport-project.kotlin-common"
def siteUrl = "https://developer.uport.me"
def sdkDescription = "common libraries for kotlin implementations of uPort standards"
subprojects { subproject ->
afterEvaluate {
if (subproject.plugins.hasPlugin('maven')) {
subproject.group = groupID
subproject.version = current_release_version
subproject.description = subproject.ext.has("description") ? subproject.ext.description : sdkDescription
//pom fields required by maven central
install {
repositories.mavenInstaller {
pom.project {
groupId subproject.group
artifactId subproject.name
name subproject.name
description subproject.description
url siteUrl
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id "mirceanis"
name "Mircea Nistor"
email "[email protected]"
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
task sourcesJar(type: Jar) {
classifier = 'sources'
if (subproject.hasProperty("android")) {
from android.sourceSets.main.javaDirectories
} else {
from sourceSets.main.java.srcDirs
}
}
artifacts {
archives sourcesJar
}
//config for jcenter
if (gradle.startParameter.taskNames.find { it.contains("bintray") }) {
bintray {
user = getBintrayUser()
key = getBintrayApiKey()
configurations = ['archives']
pkg {
repo = "uport-project"
name = subproject.name
licenses = ["Apache-2.0"]
desc = subproject.description
websiteUrl = siteUrl
vcsUrl = gitUrl
dryRun = false
publish = true
override = true
publicDownloadNumbers = false
version {
name = current_release_version
released = new Date()
}
}
}
}
}
}
}
//////////////////////////////////////////////////
// helpers for loading publishing configuration //
//////////////////////////////////////////////////
def getBintrayApiKey() {
return getInfoFromPropOrVault("bintray_api_key")
}
def getBintrayUser() {
return getInfoFromPropOrVault("bintray_username")
}
def getInfoFromPropOrVault(String key) {
checkLocalPublishingProperties()
checkVaultEnvironment()
String info
if (project.publishProps?.get(key) != null) {
info = project.publishProps?.get(key)
} else if (project.hasProperty("IGNORE_VAULT")) {
info = ""
} else {
try {
info = project?.vault?.get("secret/android_sdk/$key")['data']['value']
} catch (Exception e) {
throw new InvalidUserDataException("There was an error while reading $key from vault.\n" +
"Make sure to have secret/android_sdk/$key in the vault.\n" +
"Run this task with -PIGNORE_VAULT to default to local configuration if available", e)
}
}
return info
}
def checkVaultEnvironment() {
if (project.hasProperty("IGNORE_VAULT")) {
//use only local data if available
return
}
File tokenFile = new File("${System.env.HOME}/.vault-token")
if (tokenFile.canRead()) {
if (System.env.VAULT_TOKEN == null || System.env.VAULT_TOKEN == "") {
project?.vault?.token = tokenFile.text
}
}
if (System.env.VAULT_ADDR == null || (System.env.VAULT_TOKEN == null && !tokenFile.canRead())) {
throw new InvalidUserDataException("Vault coordinates are not configured.\n" +
"VAULT_ADDR and VAULT_TOKEN need to be set as environment variables.\n" +
"Run this task with -PIGNORE_VAULT to skip secrets and build using local configuration only")
}
}
def checkLocalPublishingProperties() {
def propFile = file("${rootDir}/publish.properties")
if (propFile.canRead()) {
Properties publishProps = new Properties()
propFile.withInputStream {
publishProps.load(it)
}
project.ext.publishProps = publishProps
} else {
project.ext.publishProps = null
}
}