Created
May 6, 2021 19:16
-
-
Save rezaiyan/d26156b77815756cd6880b7deb4ec27a to your computer and use it in GitHub Desktop.
Add your android library to the sonatype (maven central)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Define these lines to the library gradle file: | |
project.group = "io.github.rezaiyan" | |
project.archivesBaseName = "LevelProgressBar" | |
project.version = "1.0.0" | |
apply from: '../publish.gradle' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# home/.gradle/gradle.properties | |
nexusUsername=user | |
nexusPassword=pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# projectDir/gradle.properties | |
GROUP=io.github.rezaiyan | |
POM_ARTIFACT_ID=levelprogressbar | |
POM_PACKAGING=aar | |
VERSION_NAME=1.0.3 | |
VERSION_CODE=1.0.3 | |
POM_NAME=LevelProgressBar | |
POM_DESCRIPTION=An custom progressbar for android. | |
POM_INCEPTION_YEAR=2020 | |
POM_URL=https://github.com/rezaiyan/LevelProgressBar/ | |
POM_LICENCE_NAME=The Apache Software License, Version 2.0 | |
POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt | |
POM_LICENCE_DIST=repo | |
POM_SCM_URL=https://github.com/rezaiyan/LevelProgressBar/ | |
POM_SCM_CONNECTION=scm:git:git://github.com/rezaiyan/LevelProgressBar.git | |
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/rezaiyan/LevelProgressBar.git | |
POM_DEVELOPER_ID=rezaiyan | |
POM_DEVELOPER_NAME=Ali Rezaiyan | |
POM_DEVELOPER_URL=https://github.com/rezaiyan/ | |
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ | |
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven' | |
apply plugin: 'signing' | |
def sonatypeRepositoryUrl | |
if (isReleaseBuild()) { | |
println 'RELEASE BUILD' | |
sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL | |
: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" | |
} else { | |
println 'DEBUG BUILD' | |
sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL | |
: "https://s01.oss.sonatype.org/content/repositories/snapshots/" | |
} | |
def getRepositoryUsername() { | |
return hasProperty('nexusUsername') ? nexusUsername : "" | |
} | |
def getRepositoryPassword() { | |
return hasProperty('nexusPassword') ? nexusPassword : "" | |
} | |
afterEvaluate { project -> | |
uploadArchives { | |
repositories { | |
mavenDeployer { | |
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | |
pom.artifactId = POM_ARTIFACT_ID | |
repository(url: sonatypeRepositoryUrl) { | |
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) | |
} | |
pom.project { | |
name POM_NAME | |
packaging POM_PACKAGING | |
description POM_DESCRIPTION | |
url POM_URL | |
scm { | |
url POM_SCM_URL | |
connection POM_SCM_CONNECTION | |
developerConnection POM_SCM_DEV_CONNECTION | |
} | |
licenses { | |
license { | |
name POM_LICENCE_NAME | |
url POM_LICENCE_URL | |
distribution POM_LICENCE_DIST | |
} | |
} | |
developers { | |
developer { | |
id POM_DEVELOPER_ID | |
name POM_DEVELOPER_NAME | |
} | |
} | |
} | |
} | |
} | |
} | |
signing { | |
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } | |
sign configurations.archives | |
} | |
task androidJavadocs(type: Javadoc) { | |
source = android.sourceSets.main.java.sourceFiles | |
} | |
task androidJavadocsJar(type: Jar) { | |
classifier = 'javadoc' | |
//basename = artifact_id | |
from androidJavadocs.destinationDir | |
} | |
task androidSourcesJar(type: Jar) { | |
classifier = 'sources' | |
//basename = artifact_id | |
from android.sourceSets.main.java.sourceFiles | |
} | |
artifacts { | |
//archives packageReleaseJar | |
archives androidSourcesJar | |
archives androidJavadocsJar | |
} | |
} | |
def isReleaseBuild() { | |
return version.contains("SNAPSHOT") == false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment