120 lines
4.5 KiB
Groovy
120 lines
4.5 KiB
Groovy
if (versions == null || versions.publishVersionName == null) {
|
|
throw new IllegalStateException("Unable to reference publishVersionName!")
|
|
} else if (libraryGroupId == null || libraryArtifactId == null) {
|
|
throw new IllegalStateException("Must provide libraryGroupId and libraryArtifactId!")
|
|
}
|
|
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'signing'
|
|
|
|
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
|
|
}
|
|
|
|
// Default values
|
|
ext["signing.keyId"] = ''
|
|
ext["signing.password"] = ''
|
|
ext["signing.secretKeyRingFile"] = ''
|
|
ext["ossrhUsername"] = ''
|
|
ext["ossrhPassword"] = ''
|
|
|
|
File secretPropsFile = project.rootProject.file('local.properties')
|
|
if (secretPropsFile.exists()) {
|
|
Properties props = new Properties()
|
|
new FileInputStream(secretPropsFile).withCloseable { is -> props.load(is) }
|
|
props.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')
|
|
}
|
|
|
|
publishing {
|
|
repositories {
|
|
maven {
|
|
name = "sonatype"
|
|
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
|
credentials {
|
|
username ossrhUsername
|
|
password ossrhPassword
|
|
}
|
|
}
|
|
}
|
|
publications {
|
|
release(MavenPublication) {
|
|
groupId libraryGroupId
|
|
artifactId libraryArtifactId
|
|
version versions.publishVersionName
|
|
|
|
if (project.plugins.findPlugin("com.android.library")) {
|
|
artifact("$buildDir/outputs/aar/${libraryArtifactId}-release.aar")
|
|
} else {
|
|
artifact("$buildDir/libs/${libraryArtifactId}-${version}.jar")
|
|
}
|
|
artifact androidSourcesJar
|
|
|
|
pom {
|
|
packaging 'aar'
|
|
name = libraryArtifactId
|
|
description = 'Fragula is a swipe-to-dismiss extension for navigation component library for Android.'
|
|
url = 'https://github.com/massivemadness/Fragula'
|
|
licenses {
|
|
license {
|
|
name = 'Apache 2.0 License'
|
|
url = 'https://github.com/massivemadness/Fragula/blob/master/LICENSE'
|
|
}
|
|
}
|
|
developers {
|
|
developer {
|
|
id = 'massivemadness'
|
|
name = 'Dmitrii Rubtsov'
|
|
email = 'dm.mironov01@gmail.com'
|
|
}
|
|
}
|
|
scm {
|
|
connection = 'scm:git:github.com/massivemadness/Fragula.git'
|
|
developerConnection = 'scm:git:ssh://github.com/massivemadness/Fragula.git'
|
|
url = 'https://github.com/massivemadness/Fragula/tree/master'
|
|
}
|
|
withXml {
|
|
def dependenciesNode = asNode().appendNode('dependencies')
|
|
configurations.implementation.dependencies.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")
|
|
}
|
|
configurations.api.dependencies.each {
|
|
def dependencyNode = dependenciesNode.appendNode('dependency')
|
|
dependencyNode.appendNode('groupId', it.group)
|
|
dependencyNode.appendNode('artifactId', it.name)
|
|
dependencyNode.appendNode('version', it.version)
|
|
dependencyNode.appendNode('scope', "compile")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
signing {
|
|
sign publishing.publications
|
|
}
|
|
|
|
afterEvaluate {
|
|
publishReleasePublicationToSonatypeRepository.dependsOn assembleRelease
|
|
} |