forked from ably/ably-asset-tracking-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.gradle
101 lines (92 loc) · 4.13 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
apply plugin: 'maven-publish'
apply plugin: 'signing'
final githubActor = findProperty('GITHUB_ACTOR')
final githubToken = findProperty('GITHUB_TOKEN')
final isPublishingToGitHubPackages = findProperty('publishTarget') == 'GitHubPackages'
task sourcesJar(type: Jar) {
// Copy files from main source directories to the JAR.
from android.sourceSets.main.java.srcDirs
// Specify the JAR type (it will be appended to its filename).
archiveClassifier.set("sources")
}
task dokkaJavadocJar(type: Jar) {
// Generate the javadocs.
dependsOn dokkaJavadoc
// Copy files from the javadocs directory to the jar.
from dokkaJavadoc.outputDirectory
// Specify the JAR type (it will be appended to its filename).
archiveClassifier.set("javadoc")
}
afterEvaluate {
// Based on: https://developer.android.com/studio/build/maven-publish-plugin
// See: https://docs.gradle.org/current/dsl/org.gradle.api.publish.PublishingExtension.html
publishing {
publications {
release(MavenPublication) {
from components.release
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
// Add a JAR with source code (to enable viewing the code when the library is included from a maven repository).
artifact sourcesJar
// Add a JAR with javadocs.
artifact dokkaJavadocJar
// Add POM metadata
pom {
name = PUBLISH_POM_NAME
description = PUBLISH_POM_DESCRIPTION
url = 'https://github.com/ably/ably-asset-tracking-android'
licenses {
license {
name = 'Apache License 2.0'
url = 'https://github.com/ably/ably-asset-tracking-android/blob/main/LICENSE'
}
}
developers {
// https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPomDeveloper.html
developer {
id = 'ably' // our company org in GitHub: https://github.com/ably
name = 'Ably' // UK based company: Ably Real-time Ltd
email = '[email protected]'
url = 'https://ably.com/'
}
}
organization {
name = 'Ably' // UK based company: Ably Real-time Ltd
url = 'https://ably.com/'
}
scm {
connection = 'scm:git:git://github.com/ably/ably-asset-tracking-android.git'
developerConnection = 'scm:git:ssh://github.com/ably/ably-asset-tracking-android.git'
url = 'https://github.com/ably/ably-asset-tracking-android'
tag = 'v' + PUBLISH_VERSION
}
}
}
}
repositories {
if (isPublishingToGitHubPackages && githubActor != null && githubToken != null) {
// per: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry
maven {
url = uri("https://maven.pkg.github.com/ably/ably-asset-tracking-android")
credentials {
username = githubActor
password = githubToken
}
}
}
}
}
}
// Sign the artifacts
signing {
// According to signing plugin docs we should be providing the secret key in the ascii-armored format.
// This means that the bytes of the key should be converted to a Base64 encoded string.
// https://docs.gradle.org/current/userguide/signing_plugin.html#using_in_memory_ascii_armored_openpgp_subkeys
useInMemoryPgpKeys(
findProperty("SIGNING_KEY_ID"),
findProperty("SIGNING_KEY_BASE64"),
findProperty("SIGNING_PASSWORD"),
)
sign publishing.publications
}