Skip to content

Commit

Permalink
Replaced code to publish in Bintray with code to publish in Maven Cen…
Browse files Browse the repository at this point in the history
…tral
  • Loading branch information
ernestoyaquello committed Feb 5, 2021
1 parent f7d0f79 commit 96163c5
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 121 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0'
}
}

allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

apply plugin: 'io.codearte.nexus-staging'
13 changes: 1 addition & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# 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
systemProp.org.gradle.internal.publish.checksums.insecure=true
123 changes: 123 additions & 0 deletions scripts/publish-mavencentral.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

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

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives androidSourcesJar
}

apply plugin: 'maven-publish'
apply plugin: 'signing'

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

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()) {
println "Found secret props file, loading props"
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
}
} else {
println "No props file, loading env vars"
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')
}

nexusStaging {
packageGroup = PUBLISH_GROUP_ID
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
}

publishing {
publications {
release(MavenPublication) {
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
artifact androidSourcesJar
artifact javadocJar

pom {
name = PUBLISH_ARTIFACT_ID
description = 'Vertical Stepper Form Library for Android. It follows Google Material Design guidelines.'
url = 'https://github.com/ernestoyaquello/VerticalStepperForm'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'ernestoyaquello'
name = 'Julio Ernesto Rodríguez Cabañas'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:github.com/ernestoyaquello/VerticalStepperForm.git'
developerConnection = 'scm:git:ssh://github.com/ernestoyaquello/VerticalStepperForm.git'
url = 'https://github.com/ernestoyaquello/VerticalStepperForm'
}
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)
dependencyNode.appendNode('scope', 'runtime')
}
}
}
}
}
repositories {
maven {
name = "sonatype"

def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}

signing {
sign publishing.publications
}
113 changes: 6 additions & 107 deletions vertical-stepper-form/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

ext {
bintrayRepo = 'maven'
bintrayName = 'vertical-stepper-form'

publishedGroupId = 'com.ernestoyaquello.stepperform'
libraryName = 'VerticalStepperForm'
artifact = 'vertical-stepper-form'

libraryDescription = 'A highly customizable vertical stepper form for Android.'

siteUrl = 'https://github.com/ernestoyaquello/VerticalStepperForm'
gitUrl = 'https://github.com/ernestoyaquello/VerticalStepperForm.git'

libraryVersion = '2.4.0'

developerId = 'ernestoyaquello'
developerName = 'Julio Ernesto Rodríguez Cabañas'
developerEmail = '[email protected]'

licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}

android {
compileSdkVersion 30
Expand All @@ -33,7 +7,7 @@ android {
minSdkVersion 19
targetSdkVersion 30
versionCode 19
versionName libraryVersion
versionName '2.4.0'
}

buildTypes {
Expand All @@ -45,89 +19,14 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
}

group = publishedGroupId
version = libraryVersion

install {
repositories.mavenInstaller {
pom.project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact

name libraryName
description libraryDescription
url siteUrl

licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}

task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
}

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

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
ext {
PUBLISH_GROUP_ID = 'com.ernestoyaquello.stepperform'
PUBLISH_ARTIFACT_ID = 'vertical-stepper-form'
PUBLISH_VERSION = android.defaultConfig.versionName
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
dryRun = false
publish = true
override = false
publicDownloadNumbers = true
version {
desc = libraryDescription
}
}
}
apply from: "${rootProject.projectDir}/scripts/publish-mavencentral.gradle"

0 comments on commit 96163c5

Please sign in to comment.