-
Notifications
You must be signed in to change notification settings - Fork 48
/
helper.gradle
89 lines (73 loc) · 2.84 KB
/
helper.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
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.codehaus.groovy.modules.http-builder:http-builder:0.7.1")
}
}
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.JSON
import static groovyx.net.http.Method.POST
def signArtifactsOnBintray(String user, String pass) {
final http = new HTTPBuilder(bintray.apiUrl)
http.auth.basic(user, pass)
http.request(POST, JSON) {
uri.path = "/gpg/${bintray.pkg.userOrg}/${bintray.pkg.repo}/${bintray.pkg.name}/versions/${bintray.pkg.version.name}"
logger.info(uri.path)
response.success = { res ->
logger.info("Signed version ${bintray.pkg.version.name}")
}
response.failure = { res ->
throw new GradleException("HTTP Status Code: ${res.statusLine}. Could not sign version ${bintray.pkg.version.name}")
}
}
}
def syncMavenCentralToBintray(String user, String pass) {
final http = new HTTPBuilder(bintray.apiUrl)
http.auth.basic(user, pass)
http.request(POST, JSON) {
uri.path = "/maven_central_sync/${bintray.pkg.userOrg}/${bintray.pkg.repo}/${bintray.pkg.name}/versions/${bintray.pkg.version.name}"
logger.info(uri.path)
response.success = { res ->
logger.info("Synced version ${bintray.pkg.version.name}")
}
response.failure = { res ->
throw new GradleException("HTTP Status Code: ${res.statusLine}. Could not sync version ${bintray.pkg.version.name}")
}
}
}
def getVariable(String envName, String propertyName) {
if (envName != null && System.getenv(envName) != null && !System.getenv(envName).isEmpty()) {
return System.getenv(envName)
} else if (propertyName != null && project.hasProperty(propertyName)) {
return project.property(propertyName)
} else {
return null
}
}
def getVersionNumber() {
ver = project.hasProperty('webauthn4jSpringSecurityVersion')
return (ver.startsWith('v')) ? ver.substring(1) : ver
}
ext {
getVariable = this.&getVariable
getVersionNumber = this.&getVersionNumber
signArtifactsOnBintray = this.&signArtifactsOnBintray
syncMavenCentralToBintray = this.&syncMavenCentralToBintray
}