11apply plugin : ' maven-publish'
22apply plugin : ' signing'
33
4- task androidSourcesJar (type : Jar ) {
5- archiveClassifier. set(' sources' )
6- if (project. plugins. findPlugin(" com.android.library" )) {
7- from android. sourceSets. main. java. srcDirs
8- } else {
9- from sourceSets. main. java. srcDirs
10- }
11- }
12-
13- artifacts {
14- archives androidSourcesJar
15- }
16-
174group = PUBLISH_GROUP_ID
185version = PUBLISH_VERSION
196
207afterEvaluate {
218 publishing {
229 publications {
2310 release(MavenPublication ) {
24- // The coordinates of the library, being set from variables that
25- // we'll set up later
26- groupId PUBLISH_GROUP_ID
27- artifactId PUBLISH_ARTIFACT_ID
28- version PUBLISH_VERSION
11+ from components. release
2912
30- // Two artifacts, the `aar` (or `jar`) and the sources
31- if (project. plugins. findPlugin(" com.android.library" )) {
32- // from components.release
33- } else {
34- artifact(" $buildDir /libs/${ project.getName()} -${ version} .jar" )
35- }
36-
37- artifact bundleReleaseAar
13+ groupId = PUBLISH_GROUP_ID
14+ artifactId = PUBLISH_ARTIFACT_ID
15+ version = PUBLISH_VERSION
3816
39- // Mostly self-explanatory metadata
4017 pom {
18+ packaging = ' aar'
19+
4120 name = PUBLISH_ARTIFACT_ID
4221 description = PUBLISH_DESCRIPTION
4322 url = PUBLISH_URL
23+
4424 licenses {
4525 license {
4626 name = PUBLISH_LICENSE_NAME
4727 url = PUBLISH_LICENSE_URL
4828 }
4929 }
30+
5031 developers {
5132 developer {
5233 id = PUBLISH_DEVELOPER_ID
@@ -55,8 +36,6 @@ afterEvaluate {
5536 }
5637 }
5738
58- // Version control info - if you're using GitHub, follow the
59- // format as seen here
6039 scm {
6140 connection = PUBLISH_SCM_CONNECTION
6241 developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION
@@ -66,12 +45,18 @@ afterEvaluate {
6645 }
6746 }
6847 }
69- }
7048
49+ signing {
50+ required {
51+ gradle. taskGraph. allTasks. any { task ->
52+ task. name. toLowerCase(). contains(" publish" )
53+ }
54+ }
55+
56+ sign publishing. publications. release
57+ }
58+ }
7159ext[" signing.keyId" ] = rootProject. ext[" signing.keyId" ]
7260ext[" signing.password" ] = rootProject. ext[" signing.password" ]
7361ext[" signing.secretKeyRingFile" ] = rootProject. ext[" signing.secretKeyRingFile" ]
7462
75- signing {
76- sign publishing. publications
77- }
0 commit comments