diff --git a/README.md b/README.md index 690a126..d1a0482 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.gradle b/build.gradle index 43129a5..d0b9efb 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } diff --git a/forms/build.gradle b/forms/build.gradle index fee2eda..9360097 100644 --- a/forms/build.gradle +++ b/forms/build.gradle @@ -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 = 'developer.nwagu@gmail.com' + bintrayRepo = "Forms" + bintrayName = "com.nwagu.forms" - licenseName = 'MIT License' - licenseUrl = 'https://opensource.org/licenses/MIT' - allLicenses = ["MIT"] } dependencies { @@ -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" } diff --git a/publish.gradle b/publish-bintray.gradle similarity index 71% rename from publish.gradle rename to publish-bintray.gradle index ecd3aaf..9737ba9 100644 --- a/publish.gradle +++ b/publish-bintray.gradle @@ -2,8 +2,8 @@ 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 { @@ -11,34 +11,32 @@ install { 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 = 'developer.nwagu@gmail.com' } } 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' } } } @@ -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 { diff --git a/publish-mavencentral.gradle b/publish-mavencentral.gradle new file mode 100644 index 0000000..6d9993d --- /dev/null +++ b/publish-mavencentral.gradle @@ -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 = 'developer.nwagu@gmail.com' + } + } + 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 +} \ No newline at end of file