fluentui-android/publish-check.gradle

37 строки
1.4 KiB
Groovy

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()
}