forked from Yubico/yubikit-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
71 lines (63 loc) · 2.12 KB
/
publish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
apply plugin: 'maven-publish'
apply plugin: 'signing'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
android {
libraryVariants.configureEach { variant ->
if (variant.name == 'release') {
tasks.register('javadoc', Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
owner.classpath += variant.javaCompileProvider.get().classpath
exclude '**/R.html', '**/R.*.html', '**/index.html'
}
// build a jar with javadoc
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
// build a jar with source
tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives javadocJar
archives sourcesJar
}
}
}
}
afterEvaluate {
publishing {
publications {
maven(MavenPublication) {
from components.release
artifact javadocJar
artifact sourcesJar
groupId = rootProject.group
artifactId = project.name
version = project.version
apply from: rootProject.file('pom.gradle')
pom(pomData)
}
}
repositories {
maven {
name 'sonatype'
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username = findProperty("sonatype.username")
password = findProperty("sonatype.password")
}
}
}
}
tasks.withType(Sign).configureEach {
onlyIf { isReleaseVersion && System.getenv("NO_GPG_SIGN") != "true" }
}
signing {
useGpgCmd()
sign publishing.publications.maven
}
}