Skip to content

Commit

Permalink
Merge pull request #6 from nwagu/cn-dev
Browse files Browse the repository at this point in the history
publish library to maven central
  • Loading branch information
nwagu authored Feb 12, 2021
2 parents ee10839 + f96b049 commit 300fffd
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 39 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Bintray](https://img.shields.io/badge/dynamic/json.svg?label=latest&query=name&style=plastic-square&url=https%3A%2F%2Fapi.bintray.com%2Fpackages%2Fnwagu%2FForms%2Fcom.nwagu.forms%2Fversions%2F_latest)](https://bintray.com/nwagu/Forms/com.nwagu.forms)
[![Maven Central](https://img.shields.io/maven-central/v/com.nwagu.forms/forms)](https://repo1.maven.org/maven2/com/nwagu/forms/forms)

## A form management library for Android

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
Expand Down
26 changes: 8 additions & 18 deletions forms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,16 @@ android {

ext {

bintrayRepo = "Forms"
bintrayName = "com.nwagu.forms"
publishGroupId = 'com.nwagu.forms'
publishArtifactId = 'forms'
publishVersion = '1.0.1'

publishedGroupId = 'com.nwagu.forms'
libraryName = 'forms'
artifact = 'forms'

libraryDescription = 'Android library for form management and validation'

siteUrl = ''
gitUrl = ''

libraryVersion = '1.0.1'

developerId = 'nwagu'
developerName = 'Chukwuemeka Nwagu'
developerEmail = '[email protected]'
bintrayRepo = "Forms"
bintrayName = "com.nwagu.forms"

licenseName = 'MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}

dependencies {
Expand All @@ -59,9 +48,10 @@ dependencies {

// Android LiveData library
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
}

if (project.rootProject.file('local.properties').exists()) {
apply from: '../publish.gradle'
apply from: "${rootProject.projectDir}/publish-bintray.gradle"
apply from: "${rootProject.projectDir}/publish-mavencentral.gradle"
}
36 changes: 17 additions & 19 deletions publish.gradle → publish-bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,41 @@ apply plugin: 'maven-publish'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

group = publishedGroupId
version = libraryVersion
group = publishGroupId
version = publishVersion

install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
version libraryVersion
groupId publishGroupId
artifactId publishArtifactId
version publishVersion

// Add your description here
name libraryName
description libraryDescription
url siteUrl
url = 'https://github.com/nwagu/forms'

// Set your license
licenses {
license {
name licenseName
url licenseUrl
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
id = 'nwagu'
name = 'Chukwuemeka Nwagu'
email = '[email protected]'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

connection = 'scm:git:github.com/nwagu/forms.git'
developerConnection = 'scm:git:ssh://github.com/nwagu/forms.git'
url = 'https://github.com/nwagu/forms/tree/master'
}
}
}
Expand Down Expand Up @@ -88,9 +86,9 @@ bintray {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
websiteUrl = "https://github.com/nwagu/forms"
vcsUrl = "https://github.com/nwagu/forms.git"
licenses = ["MIT"]
publish = true
publicDownloadNumbers = true
version {
Expand Down
110 changes: 110 additions & 0 deletions publish-mavencentral.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

group = publishGroupId
version = publishVersion

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

artifacts {
archives androidSourcesJar
}

ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.secretKeyRingFile"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
}
} else {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}

publishing {
publications {
release(MavenPublication) {
groupId = publishGroupId
artifactId publishArtifactId
version publishVersion

if (project.plugins.findPlugin("com.android.library")) {
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}

artifact androidSourcesJar

pom {
name = libraryName
description = libraryDescription
url = 'https://github.com/nwagu/forms'

licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'nwagu'
name = 'Chukwuemeka Nwagu'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:github.com/nwagu/forms.git'
developerConnection = 'scm:git:ssh://github.com/nwagu/forms.git'
url = 'https://github.com/nwagu/forms/tree/master'
}
withXml {
def dependenciesNode = asNode().appendNode('dependencies')

project.configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
repositories {
maven {
name = "sonatype"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}

signing {
sign publishing.publications
}

0 comments on commit 300fffd

Please sign in to comment.