Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[andoid] publishing to maven central #53568

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions .circleci/docker/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8"
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
}
}

Expand Down
2 changes: 2 additions & 0 deletions .circleci/scripts/publish_android_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ else
echo "ndk.dir=/opt/ndk" >> $GRADLE_LOCAL_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 "mavenCentralRepositoryPassword=${SONATYPE_NEXUS_PASSWORD}" >> $GRADLE_PROPERTIES

echo "signing.keyId=${ANDROID_SIGN_KEY}" >> $GRADLE_PROPERTIES
echo "signing.password=${ANDROID_SIGN_PASS}" >> $GRADLE_PROPERTIES
Expand Down
4 changes: 1 addition & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ allprojects {

dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${GRADLE_BINTRAY_PLUGIN_VERSION}"
classpath "com.github.dcendents:android-maven-gradle-plugin:${ANDROID_MAVEN_GRADLE_PLUGIN_VERSION}"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8"
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
}
}

Expand Down
6 changes: 1 addition & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ABI_FILTERS=armeabi-v7a,arm64-v8a,x86,x86_64
VERSION_NAME=1.8.0-SNAPSHOT
GROUP=org.pytorch
MAVEN_GROUP=org.pytorch
SONATYPE_STAGING_PROFILE=orgpytorch
POM_URL=https://github.com/pytorch/pytorch/tree/master/android
POM_SCM_URL=https://github.com/pytorch/pytorch.git
POM_SCM_CONNECTION=scm:git:https://github.com/pytorch/pytorch
Expand All @@ -13,11 +14,6 @@ POM_ISSUES_URL=https://github.com/pytorch/pytorch/issues
POM_LICENSE_DIST=repo
POM_DEVELOPER_ID=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
org.gradle.internal.repository.max.retries=1
Expand Down
38 changes: 0 additions & 38 deletions android/gradle/android_maven_install.gradle

This file was deleted.

93 changes: 5 additions & 88 deletions android/gradle/android_tasks.gradle
Original file line number Diff line number Diff line change
@@ -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 ->
if (POM_PACKAGING == 'aar') {
task androidJavadoc(type: Javadoc, dependsOn: assembleDebug) {
source += files(android.sourceSets.main.java.srcDirs)
failOnError false
// This task will try to compile *everything* it finds in the above directory and
// 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', 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)
task headersJar(type: Jar) {
archiveClassifier.set('headers')
from("$rootDir/cxx/") {
include '**/*.h'
}
}
artifacts.add('archives', headersJar)
}
zip.close()
}
64 changes: 0 additions & 64 deletions android/gradle/bintray.gradle

This file was deleted.

99 changes: 0 additions & 99 deletions android/gradle/gradle_maven_push.gradle

This file was deleted.

4 changes: 1 addition & 3 deletions android/gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
apply from: rootProject.file('gradle/android_tasks.gradle')

apply from: rootProject.file('gradle/release_bintray.gradle')

apply from: rootProject.file('gradle/gradle_maven_push.gradle')
apply plugin: 'com.vanniktech.maven.publish'
32 changes: 0 additions & 32 deletions android/gradle/release_bintray.gradle

This file was deleted.