Skip to content

Commit c808d16

Browse files
fmassaIvanKobzarev
andauthored
[android] gradle wrapper + publish to maven central (pytorch#3561)
* [android] gradle wrapper [ghstack-poisoned] * [android] publishing to maven central [ghstack-poisoned] Co-authored-by: Ivan Kobzarev <[email protected]>
1 parent 11268ca commit c808d16

13 files changed

+271
-337
lines changed

android/.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
local.properties
22
**/*.iml
33
.gradle
4-
gradlew*
5-
gradle/wrapper
64
.idea/*
75
.externalNativeBuild
86
build

android/build.gradle

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ allprojects {
2424
}
2525

2626
dependencies {
27-
classpath 'com.android.tools.build:gradle:3.3.2'
28-
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:${GRADLE_BINTRAY_PLUGIN_VERSION}"
29-
classpath "com.github.dcendents:android-maven-gradle-plugin:${ANDROID_MAVEN_GRADLE_PLUGIN_VERSION}"
30-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.9.8"
27+
classpath 'com.android.tools.build:gradle:4.1.2'
28+
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.14.2'
3129
}
3230
}
3331

android/gradle.properties

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
ABI_FILTERS=armeabi-v7a,arm64-v8a,x86,x86_64
22

3-
VERSION_NAME=0.0.1-SNAPSHOT
3+
VERSION_NAME=0.9.0-SNAPSHOT
44
GROUP=org.pytorch
55
MAVEN_GROUP=org.pytorch
6+
SONATYPE_STAGING_PROFILE=orgpytorch
67
POM_URL=https://github.com/pytorch/vision/
78
POM_SCM_URL=https://github.com/pytorch/vision.git
89
POM_SCM_CONNECTION=scm:git:https://github.com/pytorch/vision
@@ -13,11 +14,6 @@ POM_ISSUES_URL=https://github.com/pytorch/vision/issues
1314
POM_LICENSE_DIST=repo
1415
POM_DEVELOPER_ID=pytorch
1516
POM_DEVELOPER_NAME=pytorch
16-
syncWithMavenCentral=true
17-
18-
GRADLE_BINTRAY_PLUGIN_VERSION=1.8.0
19-
GRADLE_VERSIONS_PLUGIN_VERSION=0.15.0
20-
ANDROID_MAVEN_GRADLE_PLUGIN_VERSION=2.1
2117

2218
# Gradle internals
2319
android.useAndroidX=true
54.9 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

android/gradle_scripts/android_maven_install.gradle

-38
This file was deleted.
+5-89
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,11 @@
1-
2-
import java.nio.file.Files
3-
import java.nio.file.Paths
4-
import java.io.FileOutputStream
5-
import java.util.zip.ZipFile
6-
7-
// Android tasks for Javadoc and sources.jar generation
8-
91
afterEvaluate { project ->
102
if (POM_PACKAGING == 'aar') {
11-
task androidJavadoc(type: Javadoc, dependsOn: assembleDebug) {
12-
source += files(android.sourceSets.main.java.srcDirs)
13-
failOnError false
14-
// This task will try to compile *everything* it finds in the above directory and
15-
// will choke on text files it doesn't understand.
16-
exclude '**/BUCK'
17-
exclude '**/*.md'
18-
}
19-
20-
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
21-
classifier = 'javadoc'
22-
from androidJavadoc.destinationDir
23-
}
24-
25-
task androidSourcesJar(type: Jar) {
26-
classifier = 'sources'
27-
from android.sourceSets.main.java.srcDirs
28-
}
29-
30-
android.libraryVariants.all { variant ->
31-
def name = variant.name.capitalize()
32-
task "jar${name}"(type: Jar, dependsOn: variant.javaCompileProvider) {
33-
from variant.javaCompileProvider.get().destinationDir
34-
}
35-
36-
androidJavadoc.doFirst {
37-
classpath += files(android.bootClasspath)
38-
classpath += files(variant.javaCompileProvider.get().classpath.files)
39-
// This is generated by `assembleDebug` and holds the JARs generated by the APT.
40-
classpath += fileTree(dir: "$buildDir/intermediates/bundles/debug/", include: '**/*.jar')
41-
42-
// Process AAR dependencies
43-
def aarDependencies = classpath.filter { it.name.endsWith('.aar') }
44-
classpath -= aarDependencies
45-
aarDependencies.each { aar ->
46-
// Extract classes.jar from the AAR dependency, and add it to the javadoc classpath
47-
def outputPath = "$buildDir/tmp/aarJar/${aar.name.replace('.aar', '.jar')}"
48-
classpath += files(outputPath)
49-
50-
// Use a task so the actual extraction only happens before the javadoc task is run
51-
dependsOn task(name: "extract ${aar.name}").doLast {
52-
extractEntry(aar, 'classes.jar', outputPath)
53-
}
54-
}
55-
}
56-
}
57-
58-
artifacts.add('archives', androidJavadocJar)
59-
artifacts.add('archives', androidSourcesJar)
60-
}
61-
62-
if (POM_PACKAGING == 'jar') {
63-
task javadocJar(type: Jar, dependsOn: javadoc) {
64-
classifier = 'javadoc'
65-
from javadoc.destinationDir
66-
}
67-
68-
task sourcesJar(type: Jar, dependsOn: classes) {
69-
classifier = 'sources'
70-
from sourceSets.main.allSource
71-
}
72-
73-
artifacts.add('archives', javadocJar)
74-
artifacts.add('archives', sourcesJar)
75-
}
76-
}
77-
78-
// Utility method to extract only one entry in a zip file
79-
private def extractEntry(archive, entryPath, outputPath) {
80-
if (!archive.exists()) {
81-
throw new GradleException("archive $archive not found")
82-
}
83-
84-
def zip = new ZipFile(archive)
85-
zip.entries().each {
86-
if (it.name == entryPath) {
87-
def path = Paths.get(outputPath)
88-
if (!Files.exists(path)) {
89-
Files.createDirectories(path.getParent())
90-
Files.copy(zip.getInputStream(it), path)
3+
task headersJar(type: Jar) {
4+
archiveClassifier.set('headers')
5+
from("$rootDir/cxx/") {
6+
include '**/*.h'
917
}
928
}
9+
artifacts.add('archives', headersJar)
9310
}
94-
zip.close()
9511
}

android/gradle_scripts/bintray.gradle

-64
This file was deleted.

android/gradle_scripts/gradle_maven_push.gradle

-99
This file was deleted.

android/gradle_scripts/release.gradle

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
apply from: rootProject.file('gradle_scripts/android_tasks.gradle')
22

3-
apply from: rootProject.file('gradle_scripts/release_bintray.gradle')
4-
5-
apply from: rootProject.file('gradle_scripts/gradle_maven_push.gradle')
3+
apply plugin: 'com.vanniktech.maven.publish'

android/gradle_scripts/release_bintray.gradle

-32
This file was deleted.

0 commit comments

Comments
 (0)