gradle/gradle-mvn-push.gradle
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
// sets the project version
version = VERSION_NAME
group = GROUP
// Bintray deployment config
def projectName = project.rootProject.name
def localPropertiesName = 'local.properties'
def isLocalBuild = project.rootProject.file(localPropertiesName).exists()
def uploadConfig = [
user : '',
apiKey : '',
gpgPassword: '',
ossUser : '',
ossPassword: ''
]
if (!isLocalBuild) {
// load from environment variables
println "# $projectName: '$localPropertiesName' not found, loading deployment config from environment variables"
uploadConfig.user = System.env.BINTRAY_USER
uploadConfig.apiKey = System.env.BINTRAY_API_KEY
uploadConfig.gpgPassword = System.env.BINTRAY_GPG_PASSWORD
uploadConfig.ossUser = System.env.BINTRAY_OSS_USER
uploadConfig.ossPassword = System.env.BINTRAY_OSS_PASSWORD
} else {
// load from local properties
println "# $projectName: '$localPropertiesName' found, loading deployment config from file"
Properties fileProperties = new Properties()
fileProperties.load(project.rootProject.file(localPropertiesName).newDataInputStream())
uploadConfig.user = fileProperties.getProperty('bintray.user')
uploadConfig.apiKey = fileProperties.getProperty('bintray.apikey')
uploadConfig.gpgPassword = fileProperties.getProperty('bintray.gpg.password')
uploadConfig.ossUser = fileProperties.getProperty('bintray.oss.user')
uploadConfig.ossPassword = fileProperties.getProperty('bintray.oss.password')
}
bintray {
user = uploadConfig.user
key = uploadConfig.apiKey
configurations = ['archives']
pkg {
repo = 'maven'
name = POM_ARTIFACT_ID
desc = POM_DESCRIPTION
websiteUrl = POM_URL
issueTrackerUrl = POM_ISSUE_URL
vcsUrl = POM_SCM_URL
licenses = ["Apache-2.0"]
publish = true
publicDownloadNumbers = true
// noinspection GroovyAssignabilityCheck
version {
desc = POM_DESCRIPTION
gpg {
sign = true // Determines whether to GPG sign the files. The default is false
passphrase = uploadConfig.gpgPassword // Optional. The passphrase for GPG signing
}
mavenCentralSync {
sync = true
user = uploadConfig.ossUser
password = uploadConfig.ossPassword
close = '1'
}
}
}
}
if (project.getPlugins().hasPlugin('com.android.application') || project.getPlugins().hasPlugin('com.android.library')) {
install {
repositories.mavenInstaller {
configuration = configurations.archives
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
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
}
}
}
}
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.source
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError true
println "# $projectName: Configured Android javadocs"
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.source
}
} else {
install {
repositories.mavenInstaller {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
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
email POM_DEVELOPER_EMAIL
}
}
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.getDestinationDir()
failOnError false
println "# $projectName: Configured JAR javadocs"
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
artifacts {
if (project.getPlugins().hasPlugin('com.android.application') || project.getPlugins().hasPlugin('com.android.library')) {
archives androidSourcesJar
archives androidJavadocsJar
} else {
archives sourcesJar
archives javadocJar
}
}