Skip to content

Commit

Permalink
Update library publishing tools
Browse files Browse the repository at this point in the history
  • Loading branch information
mgod committed Aug 2, 2020
1 parent b583ba8 commit 35b98f0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 78 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "com.android.tools.build:gradle:4.0.1"
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=4.0.0
VERSION_CODE=24
VERSION_NAME=4.0.0-beta01
VERSION_CODE=25
GROUP=com.splitwise
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=28
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
150 changes: 76 additions & 74 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
apply plugin: 'com.android.library'

plugins {
id("com.android.library")
id("maven-publish")
id("signing")
}

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)

configurations {
javadocSources.extendsFrom implementation
javadocSources.extendsFrom(implementation)
}

defaultConfig {
Expand All @@ -14,6 +17,7 @@ android {
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -31,90 +35,88 @@ android {
}

dependencies {
testImplementation 'junit:junit:4.13'
testImplementation("junit:junit:4.13")

implementation "androidx.annotation:annotation:$ANDROIDX_VERSION"
implementation "androidx.appcompat:appcompat:$ANDROIDX_VERSION"
implementation("androidx.annotation:annotation:$ANDROIDX_VERSION")
implementation("androidx.appcompat:appcompat:$ANDROIDX_VERSION")
}

//Release tasks
afterEvaluate {
apply plugin: 'maven'
apply plugin: 'signing'
uploadArchives.repositories.mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment)
}

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "",
password: hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "")
}
task libraryJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.javadocSources
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
task libraryJavadocsJar(type: Jar, dependsOn: libraryJavadocs) {
archiveClassifier.set("javadoc")
from libraryJavadocs.destinationDir
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
task librarySourcesJar(type: Jar) {
archiveClassifier.set("sources")
from android.sourceSets.main.java.srcDirs
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
task jar(type: Jar) {
dependsOn 'assembleRelease'
baseName project.POM_ARTIFACT_ID
version project.VERSION_NAME
from fileTree(dir: 'build/intermediates/classes/release/')
}

scm {
url POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
publishing {
repositories {
maven {
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = project.properties['NEXUS_USERNAME'] ?: ""
password = project.properties['NEXUS_PASSWORD'] ?: ""
}
}
}

signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

task libraryJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.javadocSources
}

task libraryJavadocsJar(type: Jar, dependsOn: libraryJavadocs) {
classifier = 'javadoc'
from libraryJavadocs.destinationDir
}
publications {
maven(MavenPublication) { publication ->
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

artifact(librarySourcesJar)
artifact(libraryJavadocsJar)
artifact("$buildDir/outputs/aar/library-release.aar")

pom {
name = POM_NAME
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL

licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}

task librarySourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}

task jar(type: Jar) {
dependsOn 'assembleRelease'
baseName project.POM_ARTIFACT_ID
version project.VERSION_NAME
from fileTree(dir: 'build/intermediates/classes/release/')
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
}
}
}
}

artifacts {
archives libraryJavadocsJar
archives librarySourcesJar
}
signing {
sign publishing.publications.maven
}

0 comments on commit 35b98f0

Please sign in to comment.