Last active
February 16, 2018 13:30
-
-
Save bmoliveira/3d9c28aaaa737aba9ad5fd894603395b to your computer and use it in GitHub Desktop.
BintrayUpload via providing properties
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
// This script will configure the deploy to bintray with aar | |
// Of an android-library using kotlin project | |
// Simply by providing the .property files | |
// all boilerplate code is here. | |
apply plugin: 'com.github.dcendents.android-maven' | |
apply plugin: 'com.jfrog.bintray' | |
apply plugin: 'org.jetbrains.dokka-android' | |
apply plugin: 'maven-publish' | |
// | |
// You must have in your root project a local.properties file | |
// And in your project root a deploy.properties | |
// With the following properties set | |
// | |
// deploy.mavenRepo=<maven-package> // Bintray package | |
// deploy.group=<group-id> // Bintray group | |
// deploy.artifactID=<artifact-id> // Artifact id | |
// deploy.version=<version> // Current lib version | |
// deploy.shouldPublish=true // Optional: [Default: true] Whether version should be auto published after an upload | |
// deploy.shouldOverride=true // Optional: [Default: false] Whether to override version artifacts already published | |
//bintray.user=<user> // Bintray username | |
//bintray.apikey=<apikey> // Bintray api key | |
// Get local.properties file | |
Properties localProperties = new Properties() | |
localProperties.load(project.rootProject.file('local.properties').newDataInputStream()) | |
// Get deploy properties config file | |
Properties deployProperties = new Properties() | |
deployProperties.load(project.file('deploy.properties').newDataInputStream()) | |
def getProperty = { String propertyName -> | |
deployProperties.get(propertyName) ?: localProperties.get(propertyName) | |
} | |
version = getProperty("deploy.version") | |
group = getProperty("deploy.group") | |
//take a look at https://github.com/bintray/gradle-bintray-plugin#buildgradle | |
bintray { | |
user = getProperty("bintray.user") | |
key = getProperty("bintray.apikey") | |
configurations = ['archives'] | |
publish = getProperty("deploy.shouldPublish") ?: true | |
override = getProperty("deploy.shouldOverride") ?: false | |
pkg { | |
repo = getProperty("deploy.mavenRepo") | |
name = getProperty("deploy.artifactID") | |
version { | |
name = getProperty("deploy.version") | |
} | |
} | |
} | |
install { | |
repositories.mavenInstaller { | |
pom.project { | |
packaging 'aar' | |
groupId getProperty("deploy.group") | |
artifactId getProperty("deploy.artifactID") | |
version getProperty("deploy.version") | |
name getProperty("deploy.artifactID") | |
} | |
} | |
} | |
if (project.hasProperty("kotlin")) { //Kotlin libraries | |
task sourcesJar(type: Jar) { | |
classifier = 'sources' | |
from android.sourceSets.main.java.srcDirs | |
} | |
task javadoc(type: Javadoc, dependsOn: dokka) { | |
} | |
} else if (project.hasProperty("android")) { | |
task sourcesJar(type: Jar) { | |
classifier = '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)) | |
} | |
} else { // Java libraries | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
} | |
task javadocJar(type: Jar, dependsOn: javadoc) { | |
classifier = 'javadoc' | |
from javadoc.destinationDir | |
} | |
artifacts { | |
archives javadocJar | |
archives sourcesJar | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use with raw link, like this:
And add a properties file to project with config vars: