forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[andoid] publishing to maven central (pytorch#53568)
Summary: Pull Request resolved: pytorch#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
- Loading branch information
1 parent
05e0ea9
commit 5658ab5
Showing
10 changed files
with
11 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file was deleted.
Oops, something went wrong.