Skip to content

Commit

Permalink
migrate to gradle plugin "maven"
Browse files Browse the repository at this point in the history
  • Loading branch information
i.o.novikov committed Feb 22, 2022
1 parent 9b3c6ef commit 01585eb
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions gradle/publish-lib.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,36 @@
* limitations under the License.
*/
apply plugin: 'maven-publish'
apply plugin: 'signing'

def getEnvValueOrEmpty(String key) {
String value = System.getenv(key)
return value != null ? value : ""
}
def isAndroidLibrary = project.extensions.findByName('android') != null

def getReleaseRepository() {
return getEnvValueOrEmpty("PRIVATE_NEXUS_RELEASE_URL")
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepository() {
return getEnvValueOrEmpty("PRIVATE_NEXUS_SNAPSHOT_URL")
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return getEnvValueOrEmpty("PRIVATE_NEXUS_USER")
return hasProperty('ossrhUsername') ? ossrhUsername : ''
}

def getRepositoryPassword() {
return getEnvValueOrEmpty("PRIVATE_NEXUS_PASSWORD")
return hasProperty('ossrhPassword') ? ossrhPassword : ''
}

afterEvaluate { project ->
afterEvaluate {
publishing {
publications {
mavenAar(MavenPublication) {
from components.release
release(MavenPublication) {
from isAndroidLibrary ? components.release : components.java
groupId GROUP
version versionName
artifactId POM_ARTIFACT_ID
afterEvaluate {
artifact sourcesJar
artifact javadocJar
Expand Down Expand Up @@ -73,10 +74,9 @@ afterEvaluate { project ->
}
}
}

repositories {
maven {
url isRelease ? getReleaseRepository() : getSnapshotRepository()
url isRelease ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
Expand Down Expand Up @@ -107,4 +107,9 @@ afterEvaluate { project ->
archiveClassifier.set('javadoc')
from "$buildDir/docs/javadoc"
}
}

signing {
required { isRelease }
sign publishing.publications.release
}
}

0 comments on commit 01585eb

Please sign in to comment.