mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[andoid] publishing to maven central (#53568)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53568 Bintray, JCenter are going to be unavailable on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ Migrating publishing to Maven Central the same way as other fb oss projects, reference PR https://github.com/pytorch/pytorch/pull/53568/files to publish ``` ./android/gradlew -p android publish ``` <img width="697" alt="Screen Shot 2021-03-09 at 3 14 08 PM" src="https://user-images.githubusercontent.com/6638825/110551387-3e3fc000-80ea-11eb-9604-4e69d6e6d085.png"> Test Plan: Imported from OSS Reviewed By: dreiss Differential Revision: D26928884 Pulled By: IvanKobzarev fbshipit-source-id: 8754c93a2542405870e2621be5b3f14e3d0081b9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
05e0ea9661
commit
5658ab5f77
@ -21,9 +21,7 @@ buildscript {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
|
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
|
||||||
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
|
|
||||||
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,9 @@ else
|
|||||||
echo "ndk.dir=/opt/ndk" >> $GRADLE_LOCAL_PROPERTIES
|
echo "ndk.dir=/opt/ndk" >> $GRADLE_LOCAL_PROPERTIES
|
||||||
|
|
||||||
echo "SONATYPE_NEXUS_USERNAME=${SONATYPE_NEXUS_USERNAME}" >> $GRADLE_PROPERTIES
|
echo "SONATYPE_NEXUS_USERNAME=${SONATYPE_NEXUS_USERNAME}" >> $GRADLE_PROPERTIES
|
||||||
|
echo "mavenCentralRepositoryUsername=${SONATYPE_NEXUS_USERNAME}" >> $GRADLE_PROPERTIES
|
||||||
echo "SONATYPE_NEXUS_PASSWORD=${SONATYPE_NEXUS_PASSWORD}" >> $GRADLE_PROPERTIES
|
echo "SONATYPE_NEXUS_PASSWORD=${SONATYPE_NEXUS_PASSWORD}" >> $GRADLE_PROPERTIES
|
||||||
|
echo "mavenCentralRepositoryPassword=${SONATYPE_NEXUS_PASSWORD}" >> $GRADLE_PROPERTIES
|
||||||
|
|
||||||
echo "signing.keyId=${ANDROID_SIGN_KEY}" >> $GRADLE_PROPERTIES
|
echo "signing.keyId=${ANDROID_SIGN_KEY}" >> $GRADLE_PROPERTIES
|
||||||
echo "signing.password=${ANDROID_SIGN_PASS}" >> $GRADLE_PROPERTIES
|
echo "signing.password=${ANDROID_SIGN_PASS}" >> $GRADLE_PROPERTIES
|
||||||
|
@ -26,9 +26,7 @@ allprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.2'
|
classpath 'com.android.tools.build:gradle:4.1.2'
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${GRADLE_BINTRAY_PLUGIN_VERSION}"
|
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
|
||||||
classpath "com.github.dcendents:android-maven-gradle-plugin:${ANDROID_MAVEN_GRADLE_PLUGIN_VERSION}"
|
|
||||||
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ ABI_FILTERS=armeabi-v7a,arm64-v8a,x86,x86_64
|
|||||||
VERSION_NAME=1.8.0-SNAPSHOT
|
VERSION_NAME=1.8.0-SNAPSHOT
|
||||||
GROUP=org.pytorch
|
GROUP=org.pytorch
|
||||||
MAVEN_GROUP=org.pytorch
|
MAVEN_GROUP=org.pytorch
|
||||||
|
SONATYPE_STAGING_PROFILE=orgpytorch
|
||||||
POM_URL=https://github.com/pytorch/pytorch/tree/master/android
|
POM_URL=https://github.com/pytorch/pytorch/tree/master/android
|
||||||
POM_SCM_URL=https://github.com/pytorch/pytorch.git
|
POM_SCM_URL=https://github.com/pytorch/pytorch.git
|
||||||
POM_SCM_CONNECTION=scm:git:https://github.com/pytorch/pytorch
|
POM_SCM_CONNECTION=scm:git:https://github.com/pytorch/pytorch
|
||||||
@ -13,11 +14,6 @@ POM_ISSUES_URL=https://github.com/pytorch/pytorch/issues
|
|||||||
POM_LICENSE_DIST=repo
|
POM_LICENSE_DIST=repo
|
||||||
POM_DEVELOPER_ID=pytorch
|
POM_DEVELOPER_ID=pytorch
|
||||||
POM_DEVELOPER_NAME=pytorch
|
POM_DEVELOPER_NAME=pytorch
|
||||||
syncWithMavenCentral=true
|
|
||||||
|
|
||||||
GRADLE_BINTRAY_PLUGIN_VERSION=1.8.0
|
|
||||||
GRADLE_VERSIONS_PLUGIN_VERSION=0.15.0
|
|
||||||
ANDROID_MAVEN_GRADLE_PLUGIN_VERSION=2.1
|
|
||||||
|
|
||||||
# Gradle internals
|
# Gradle internals
|
||||||
org.gradle.internal.repository.max.retries=1
|
org.gradle.internal.repository.max.retries=1
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
apply plugin: 'com.github.dcendents.android-maven'
|
|
||||||
|
|
||||||
version = VERSION_NAME
|
|
||||||
group = GROUP
|
|
||||||
project.archivesBaseName = POM_ARTIFACT_ID
|
|
||||||
|
|
||||||
install {
|
|
||||||
repositories.mavenInstaller {
|
|
||||||
pom.project {
|
|
||||||
name POM_NAME
|
|
||||||
artifactId POM_ARTIFACT_ID
|
|
||||||
packaging POM_PACKAGING
|
|
||||||
description POM_DESCRIPTION
|
|
||||||
url projectUrl
|
|
||||||
|
|
||||||
scm {
|
|
||||||
url scmUrl
|
|
||||||
connection scmConnection
|
|
||||||
developerConnection scmDeveloperConnection
|
|
||||||
}
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = POM_LICENSE_NAME
|
|
||||||
url = POM_LICENSE_URL
|
|
||||||
distribution = POM_LICENSE_DIST
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id developerId
|
|
||||||
name developerName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +1,11 @@
|
|||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.util.zip.ZipFile
|
|
||||||
|
|
||||||
// Android tasks for Javadoc and sources.jar generation
|
|
||||||
|
|
||||||
afterEvaluate { project ->
|
afterEvaluate { project ->
|
||||||
if (POM_PACKAGING == 'aar') {
|
if (POM_PACKAGING == 'aar') {
|
||||||
task androidJavadoc(type: Javadoc, dependsOn: assembleDebug) {
|
task headersJar(type: Jar) {
|
||||||
source += files(android.sourceSets.main.java.srcDirs)
|
archiveClassifier.set('headers')
|
||||||
failOnError false
|
from("$rootDir/cxx/") {
|
||||||
// This task will try to compile *everything* it finds in the above directory and
|
include '**/*.h'
|
||||||
// will choke on text files it doesn't understand.
|
|
||||||
exclude '**/BUCK'
|
|
||||||
exclude '**/*.md'
|
|
||||||
}
|
|
||||||
|
|
||||||
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from androidJavadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
task androidSourcesJar(type: Jar) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from android.sourceSets.main.java.srcDirs
|
|
||||||
}
|
|
||||||
|
|
||||||
android.libraryVariants.all { variant ->
|
|
||||||
def name = variant.name.capitalize()
|
|
||||||
task "jar${name}"(type: Jar, dependsOn: variant.javaCompileProvider) {
|
|
||||||
from variant.javaCompileProvider.get().destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
androidJavadoc.doFirst {
|
|
||||||
classpath += files(android.bootClasspath)
|
|
||||||
classpath += files(variant.javaCompileProvider.get().classpath.files)
|
|
||||||
// This is generated by `assembleDebug` and holds the JARs generated by the APT.
|
|
||||||
classpath += fileTree(dir: "$buildDir/intermediates/bundles/debug/", include: '**/*.jar')
|
|
||||||
|
|
||||||
// Process AAR dependencies
|
|
||||||
def aarDependencies = classpath.filter { it.name.endsWith('.aar') }
|
|
||||||
classpath -= aarDependencies
|
|
||||||
aarDependencies.each { aar ->
|
|
||||||
// Extract classes.jar from the AAR dependency, and add it to the javadoc classpath
|
|
||||||
def outputPath = "$buildDir/tmp/aarJar/${aar.name.replace('.aar', '.jar')}"
|
|
||||||
classpath += files(outputPath)
|
|
||||||
|
|
||||||
// Use a task so the actual extraction only happens before the javadoc task is run
|
|
||||||
dependsOn task(name: "extract ${aar.name}").doLast {
|
|
||||||
extractEntry(aar, 'classes.jar', outputPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
artifacts.add('archives', headersJar)
|
||||||
artifacts.add('archives', androidJavadocJar)
|
|
||||||
artifacts.add('archives', androidSourcesJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (POM_PACKAGING == 'jar') {
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts.add('archives', javadocJar)
|
|
||||||
artifacts.add('archives', sourcesJar)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility method to extract only one entry in a zip file
|
|
||||||
private def extractEntry(archive, entryPath, outputPath) {
|
|
||||||
if (!archive.exists()) {
|
|
||||||
throw new GradleException("archive $archive not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
def zip = new ZipFile(archive)
|
|
||||||
zip.entries().each {
|
|
||||||
if (it.name == entryPath) {
|
|
||||||
def path = Paths.get(outputPath)
|
|
||||||
if (!Files.exists(path)) {
|
|
||||||
Files.createDirectories(path.getParent())
|
|
||||||
Files.copy(zip.getInputStream(it), path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zip.close()
|
|
||||||
}
|
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
apply plugin: 'com.jfrog.bintray'
|
|
||||||
|
|
||||||
def getBintrayUsername() {
|
|
||||||
return project.hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getBintrayApiKey() {
|
|
||||||
return project.hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getBintrayGpgPassword() {
|
|
||||||
return project.hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getMavenCentralUsername() {
|
|
||||||
return project.hasProperty('mavenCentralUsername') ? property('mavenCentralUsername') : System.getenv('MAVEN_CENTRAL_USERNAME')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getMavenCentralPassword() {
|
|
||||||
return project.hasProperty('mavenCentralPassword') ? property('mavenCentralPassword') : System.getenv('MAVEN_CENTRAL_PASSWORD')
|
|
||||||
}
|
|
||||||
|
|
||||||
def shouldSyncWithMavenCentral() {
|
|
||||||
return project.hasProperty('syncWithMavenCentral') ? property('syncWithMavenCentral').toBoolean() : false
|
|
||||||
}
|
|
||||||
|
|
||||||
def dryRunOnly() {
|
|
||||||
return project.hasProperty('dryRun') ? property('dryRun').toBoolean() : false
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
user = getBintrayUsername()
|
|
||||||
key = getBintrayApiKey()
|
|
||||||
override = false
|
|
||||||
configurations = ['archives']
|
|
||||||
pkg {
|
|
||||||
repo = bintrayRepo
|
|
||||||
userOrg = bintrayUserOrg
|
|
||||||
name = bintrayName
|
|
||||||
desc = bintrayDescription
|
|
||||||
websiteUrl = projectUrl
|
|
||||||
issueTrackerUrl = issuesUrl
|
|
||||||
vcsUrl = scmUrl
|
|
||||||
licenses = [ POM_LICENSE_NAME ]
|
|
||||||
dryRun = dryRunOnly()
|
|
||||||
override = false
|
|
||||||
publish = true
|
|
||||||
publicDownloadNumbers = true
|
|
||||||
version {
|
|
||||||
name = versionName
|
|
||||||
desc = bintrayDescription
|
|
||||||
gpg {
|
|
||||||
sign = true
|
|
||||||
passphrase = getBintrayGpgPassword()
|
|
||||||
}
|
|
||||||
mavenCentralSync {
|
|
||||||
sync = shouldSyncWithMavenCentral()
|
|
||||||
user = getMavenCentralUsername()
|
|
||||||
password = getMavenCentralPassword()
|
|
||||||
close = '1' // If set to 0, you have to manually click release
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
apply plugin: 'signing'
|
|
||||||
|
|
||||||
version = VERSION_NAME
|
|
||||||
group = MAVEN_GROUP
|
|
||||||
|
|
||||||
def isReleaseBuild() {
|
|
||||||
return !VERSION_NAME.contains('SNAPSHOT')
|
|
||||||
}
|
|
||||||
|
|
||||||
def getReleaseRepositoryUrl() {
|
|
||||||
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
|
|
||||||
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
|
||||||
}
|
|
||||||
|
|
||||||
def getSnapshotRepositoryUrl() {
|
|
||||||
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
|
|
||||||
: "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
|
|
||||||
def getRepositoryUsername() {
|
|
||||||
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
mavenDeployer {
|
|
||||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
|
||||||
|
|
||||||
pom.groupId = MAVEN_GROUP
|
|
||||||
pom.artifactId = POM_ARTIFACT_ID
|
|
||||||
pom.version = VERSION_NAME
|
|
||||||
|
|
||||||
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 {
|
|
||||||
name POM_NAME
|
|
||||||
packaging POM_PACKAGING
|
|
||||||
description POM_DESCRIPTION
|
|
||||||
url POM_URL
|
|
||||||
|
|
||||||
scm {
|
|
||||||
url POM_SCM_URL
|
|
||||||
connection POM_SCM_CONNECTION
|
|
||||||
developerConnection POM_SCM_DEV_CONNECTION
|
|
||||||
}
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name POM_LICENSE_NAME
|
|
||||||
url POM_LICENSE_URL
|
|
||||||
distribution POM_LICENSE_DIST
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id POM_DEVELOPER_ID
|
|
||||||
name POM_DEVELOPER_NAME
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signing {
|
|
||||||
required { isReleaseBuild() && gradle.taskGraph.hasTask('uploadArchives') }
|
|
||||||
sign configurations.archives
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,3 @@
|
|||||||
apply from: rootProject.file('gradle/android_tasks.gradle')
|
apply from: rootProject.file('gradle/android_tasks.gradle')
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/release_bintray.gradle')
|
apply plugin: 'com.vanniktech.maven.publish'
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/gradle_maven_push.gradle')
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
ext {
|
|
||||||
bintrayRepo = 'maven'
|
|
||||||
bintrayUserOrg = 'pytorch'
|
|
||||||
bintrayName = "${GROUP}:${POM_ARTIFACT_ID}"
|
|
||||||
bintrayDescription = POM_DESCRIPTION
|
|
||||||
projectUrl = POM_URL
|
|
||||||
issuesUrl = POM_ISSUES_URL
|
|
||||||
scmUrl = POM_SCM_URL
|
|
||||||
scmConnection = POM_SCM_CONNECTION
|
|
||||||
scmDeveloperConnection = POM_SCM_DEV_CONNECTION
|
|
||||||
|
|
||||||
publishedGroupId = GROUP
|
|
||||||
libraryName = 'pytorch_android'
|
|
||||||
artifact = 'pytorch_android'
|
|
||||||
|
|
||||||
developerId = POM_DEVELOPER_ID
|
|
||||||
developerName = POM_DEVELOPER_NAME
|
|
||||||
|
|
||||||
versionName = VERSION_NAME
|
|
||||||
|
|
||||||
projectLicenses = {
|
|
||||||
license = {
|
|
||||||
name = POM_LICENSE_NAME
|
|
||||||
url = POM_LICENSE_URL
|
|
||||||
distribution = POM_LICENSE_DIST
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/android_maven_install.gradle')
|
|
||||||
|
|
||||||
apply from: rootProject.file('gradle/bintray.gradle')
|
|
Reference in New Issue
Block a user