Pickup proxy parameters for publishing (#27389)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27389

Pickup gradle proxy parameters (handy for publishing from devserver) in maven publishing gradle plugin

Test Plan: Imported from OSS

Differential Revision: D17773548

Pulled By: IvanKobzarev

fbshipit-source-id: 662c0b2835e6cf1e4009da79e27268d4a19c2ceb
This commit is contained in:
Ivan Kobzarev
2019-10-04 16:19:41 -07:00
committed by Facebook Github Bot
parent 18215337f4
commit 92a2caa028

View File

@ -25,6 +25,18 @@ def getRepositoryPassword() {
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
}
def getHttpProxyHost() {
return project.properties['systemProp.http.proxyHost']
}
def getHttpProxyPort() {
return project.properties['systemProp.http.proxyPort']
}
def needProxy() {
return (getHttpProxyHost() != null) && (getHttpProxyPort() != null)
}
afterEvaluate { project ->
uploadArchives {
repositories {
@ -37,9 +49,15 @@ afterEvaluate { project ->
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
if (needProxy()) {
proxy(host: getHttpProxyHost(), port: getHttpProxyPort() as Integer, type: 'http')
}
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
if (needProxy()) {
proxy(host: getHttpProxyHost(), port: getHttpProxyPort() as Integer, type: 'http')
}
}
pom.project {