-
Notifications
You must be signed in to change notification settings - Fork 107
/
publish-check.gradle
37 lines (31 loc) · 1.37 KB
/
publish-check.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
project.ext.artifactExists = { repo, artifactId, artifactVersion ->
def groupId = 'com/microsoft/fluentui'
def pomFileName = artifactId+"-"+artifactVersion+".pom"
def artifactPath = groupId+"/"+artifactId+"/"+artifactVersion+"/"+pomFileName
def url = 'https://pkgs.dev.azure.com/microsoftdesign/fluentui-native/_packaging/fluentui-android/maven/v1'
if(repo != "feed"){
url = 'https://repo1.maven.org/maven2'
}
def repositoryUrl = url+"/"+artifactPath
try {
def connection = (HttpURLConnection) new URL(repositoryUrl).openConnection()
if(repo == "feed"){
connection.setRequestProperty("Authorization", "Basic " + getBase64EncodedCredentials())
}
connection.setConnectTimeout(10000)
connection.setReadTimeout(10000)
connection.setRequestMethod("HEAD")
def responseCode = connection.getResponseCode()
return (200 == responseCode)
} catch (IOException ignored) {
println(ignored)
return false
}
}
def getBase64EncodedCredentials() {
Map<String, ?> properties = project.getProperties();
def username = project.hasProperty("mavenUserName") ? properties.get("mavenUsername") : ""
def password = project.hasProperty("mavenPassword") ? properties.get("mavenPassword") : ""
def s = username + ":" + password
return s.bytes.encodeBase64().toString()
}