Skip to content

Commit 35b98f0

Browse files
committed
Update library publishing tools
1 parent b583ba8 commit 35b98f0

File tree

4 files changed

+80
-78
lines changed

4 files changed

+80
-78
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.4.2'
10+
classpath "com.android.tools.build:gradle:4.0.1"
1111
}
1212
}
1313

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# This option should only be used with decoupled projects. More details, visit
1313
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1414
# org.gradle.parallel=true
15-
VERSION_NAME=4.0.0
16-
VERSION_CODE=24
15+
VERSION_NAME=4.0.0-beta01
16+
VERSION_CODE=25
1717
GROUP=com.splitwise
1818
ANDROID_BUILD_MIN_SDK_VERSION=14
1919
ANDROID_BUILD_TARGET_SDK_VERSION=28

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip

library/build.gradle

Lines changed: 76 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
apply plugin: 'com.android.library'
2-
1+
plugins {
2+
id("com.android.library")
3+
id("maven-publish")
4+
id("signing")
5+
}
36

47
android {
58
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
69

710
configurations {
8-
javadocSources.extendsFrom implementation
11+
javadocSources.extendsFrom(implementation)
912
}
1013

1114
defaultConfig {
@@ -14,6 +17,7 @@ android {
1417
versionCode Integer.parseInt(project.VERSION_CODE)
1518
versionName project.VERSION_NAME
1619
}
20+
1721
buildTypes {
1822
release {
1923
minifyEnabled false
@@ -31,90 +35,88 @@ android {
3135
}
3236

3337
dependencies {
34-
testImplementation 'junit:junit:4.13'
38+
testImplementation("junit:junit:4.13")
3539

36-
implementation "androidx.annotation:annotation:$ANDROIDX_VERSION"
37-
implementation "androidx.appcompat:appcompat:$ANDROIDX_VERSION"
40+
implementation("androidx.annotation:annotation:$ANDROIDX_VERSION")
41+
implementation("androidx.appcompat:appcompat:$ANDROIDX_VERSION")
3842
}
3943

40-
//Release tasks
41-
afterEvaluate {
42-
apply plugin: 'maven'
43-
apply plugin: 'signing'
44-
uploadArchives.repositories.mavenDeployer {
45-
beforeDeployment {
46-
MavenDeployment deployment -> signing.signPom(deployment)
47-
}
48-
49-
pom.groupId = GROUP
50-
pom.artifactId = POM_ARTIFACT_ID
51-
pom.version = VERSION_NAME
52-
53-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
54-
authentication(userName: hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "",
55-
password: hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "")
56-
}
44+
task libraryJavadocs(type: Javadoc) {
45+
failOnError = false
46+
source = android.sourceSets.main.java.srcDirs
47+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
48+
classpath += configurations.javadocSources
49+
}
5750

58-
pom.project {
59-
name POM_NAME
60-
packaging POM_PACKAGING
61-
description POM_DESCRIPTION
62-
url POM_URL
51+
task libraryJavadocsJar(type: Jar, dependsOn: libraryJavadocs) {
52+
archiveClassifier.set("javadoc")
53+
from libraryJavadocs.destinationDir
54+
}
6355

64-
developers {
65-
developer {
66-
id POM_DEVELOPER_ID
67-
name POM_DEVELOPER_NAME
68-
}
69-
}
56+
task librarySourcesJar(type: Jar) {
57+
archiveClassifier.set("sources")
58+
from android.sourceSets.main.java.srcDirs
59+
}
7060

71-
licenses {
72-
license {
73-
name POM_LICENCE_NAME
74-
url POM_LICENCE_URL
75-
distribution POM_LICENCE_DIST
76-
}
77-
}
61+
task jar(type: Jar) {
62+
dependsOn 'assembleRelease'
63+
baseName project.POM_ARTIFACT_ID
64+
version project.VERSION_NAME
65+
from fileTree(dir: 'build/intermediates/classes/release/')
66+
}
7867

79-
scm {
80-
url POM_SCM_URL
81-
connection = POM_SCM_CONNECTION
82-
developerConnection = POM_SCM_DEV_CONNECTION
68+
publishing {
69+
repositories {
70+
maven {
71+
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
72+
credentials {
73+
username = project.properties['NEXUS_USERNAME'] ?: ""
74+
password = project.properties['NEXUS_PASSWORD'] ?: ""
8375
}
8476
}
8577
}
8678

87-
signing {
88-
required { gradle.taskGraph.hasTask("uploadArchives") }
89-
sign configurations.archives
90-
}
91-
92-
task libraryJavadocs(type: Javadoc) {
93-
failOnError = false
94-
source = android.sourceSets.main.java.srcDirs
95-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
96-
classpath += configurations.javadocSources
97-
}
98-
99-
task libraryJavadocsJar(type: Jar, dependsOn: libraryJavadocs) {
100-
classifier = 'javadoc'
101-
from libraryJavadocs.destinationDir
102-
}
79+
publications {
80+
maven(MavenPublication) { publication ->
81+
groupId = GROUP
82+
artifactId = POM_ARTIFACT_ID
83+
version = VERSION_NAME
84+
85+
artifact(librarySourcesJar)
86+
artifact(libraryJavadocsJar)
87+
artifact("$buildDir/outputs/aar/library-release.aar")
88+
89+
pom {
90+
name = POM_NAME
91+
packaging = POM_PACKAGING
92+
description = POM_DESCRIPTION
93+
url = POM_URL
94+
95+
licenses {
96+
license {
97+
name = POM_LICENCE_NAME
98+
url = POM_LICENCE_URL
99+
distribution = POM_LICENCE_DIST
100+
}
101+
}
103102

104-
task librarySourcesJar(type: Jar) {
105-
classifier = 'sources'
106-
from android.sourceSets.main.java.srcDirs
107-
}
103+
developers {
104+
developer {
105+
id = POM_DEVELOPER_ID
106+
name = POM_DEVELOPER_NAME
107+
}
108+
}
108109

109-
task jar(type: Jar) {
110-
dependsOn 'assembleRelease'
111-
baseName project.POM_ARTIFACT_ID
112-
version project.VERSION_NAME
113-
from fileTree(dir: 'build/intermediates/classes/release/')
110+
scm {
111+
connection = POM_SCM_CONNECTION
112+
developerConnection = POM_SCM_DEV_CONNECTION
113+
url = POM_SCM_URL
114+
}
115+
}
116+
}
114117
}
118+
}
115119

116-
artifacts {
117-
archives libraryJavadocsJar
118-
archives librarySourcesJar
119-
}
120+
signing {
121+
sign publishing.publications.maven
120122
}

0 commit comments

Comments
 (0)