Gradle for android library

Summary: Adds a buildscript for gradle as well as bintray upload capabilities for the YogaLayout library

Reviewed By: emilsjolander

Differential Revision: D4604712

fbshipit-source-id: bacbcc20b7ed6ee8689130287a48bd5d3826298c
This commit is contained in:
Robert Spencer
2017-02-23 04:57:18 -08:00
committed by Facebook Github Bot
parent 5519a73087
commit 60ffa1953b
5 changed files with 178 additions and 107 deletions

59
android/build.gradle Normal file
View File

@@ -0,0 +1,59 @@
apply plugin: "com.jfrog.bintray"
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
version = '1.0.0'
group = 'com.facebook.yoga.android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets.main {
jni.srcDirs = [] // disalbe NDK auto build (not sure why this is necessary)
// The alternative, fat-aar does an equivalent thing to this hack
// seehttps://github.com/adwiv/android-fat-aar/blob/master/fat-aar.gradle#L307
jniLibs.srcDirs = ['build/intermediates/exploded-aar/com.facebook.yoga/yoga/1.0.0/jni']
}
}
dependencies {
compile project(':yoga')
}
task sourcesJar(type: Jar) {
classifier = 'source'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
ext {
bintrayName = "com.facebook.yoga.android:yoga-layout"
}
apply from: rootProject.file('gradle/android-jcenter-install.gradle')

View File

@@ -0,0 +1,81 @@
ext {
bintrayUserOrg = 'facebook'
bintrayRepo = 'maven'
siteURL = "https://facebook.github.io/yoga/"
projectLicenses = {
license {
name 'BSD License'
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
distribution 'repo'
}
}
}
def getBintrayUsername() {
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
}
def getBintrayApiKey() {
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
}
def getBintrayGpgPassword() {
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
}
def dryRunOnly() {
return hasProperty('dryRun') ? property('dryRun').toBoolean() : false
}
def pomConfig = {
licenses {
// TODO Can we grab this from above?
license {
name 'BSD License'
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
distribution 'repo'
}
}
}
publishing {
publications {
primaryPublication(MavenPublication) {
groupId group
artifact(sourcesJar)
artifact(javadocJar)
pom.withXml {
def root = asNode()
root.appendNode('name', 'Yoga')
root.appendNode('url', siteURL)
root.children().last() + pomConfig
}
}
}
}
bintray {
user = getBintrayUsername()
key = getBintrayApiKey()
publications = ['primaryPublication']
configurations = ['archives']
pkg {
repo = bintrayRepo
userOrg = bintrayUserOrg
name = project.bintrayName
dryRun = dryRunOnly()
licenses = projectLicenses
override = true
publish = true
publicDownloadNumbers = true
version {
name = project.version
released = new Date()
gpg {
sign = true
passphrase = getBintrayGpgPassword()
}
}
}
}

View File

@@ -12,43 +12,43 @@ group = 'com.facebook.yoga'
// We currently build the native libraries with buck and bundle them together
// at this point into the AAR
task buckBuildAndCopy(type: Exec) {
commandLine '../scripts/build_natives_for_gradle.sh'
commandLine '../scripts/build_natives_for_gradle.sh'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
java.srcDir 'com'
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
jniLibs.srcDirs = ['build/buck-out/jniLibs']
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
java.srcDir 'com'
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res']
jniLibs.srcDirs = ['build/buck-out/jniLibs']
}
}
}
}
preBuild.dependsOn buckBuildAndCopy
dependencies {
compile(name: 'jsr305')
compile(name: 'soloader-0.1.0', ext: 'aar')
compile(name: 'jsr305')
compile(name: 'soloader-0.1.0', ext: 'aar')
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'source'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
@@ -64,85 +64,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
}
ext {
bintrayRepo = 'maven'
bintrayUserOrg = 'facebook'
bintrayName = "com.facebook.yoga:yoga"
siteURL = "https://facebook.github.io/yoga/"
projectLicenses = {
license {
name 'BSD License'
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
distribution 'repo'
}
}
}
def pomConfig = {
licenses {
// TODO Can we grab this from above?
license {
name 'BSD License'
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
distribution 'repo'
}
}
}
publishing {
publications {
yoga(MavenPublication) {
groupId group
artifact(sourcesJar)
artifact(javadocJar)
pom.withXml {
def root = asNode()
root.appendNode('name', 'Yoga')
root.appendNode('url', siteURL)
root.children().last() + pomConfig
}
}
}
}
bintray {
user = getBintrayUsername()
key = getBintrayApiKey()
publications = ['yoga']
configurations = ['archives']
pkg {
repo = bintrayRepo
userOrg = bintrayUserOrg
name = bintrayName
dryRun = dryRunOnly()
licenses = projectLicenses
override = true
publish = true
publicDownloadNumbers = true
version {
name = version
released = new Date()
gpg {
sign = true
passphrase = getBintrayGpgPassword()
}
}
}
}
def getBintrayUsername() {
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
}
def getBintrayApiKey() {
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
}
def getBintrayGpgPassword() {
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
}
def dryRunOnly() {
return hasProperty('dryRun') ? property('dryRun').toBoolean() : false
}
apply from: rootProject.file('gradle/android-jcenter-install.gradle')

View File

@@ -1,8 +1,14 @@
#!/bin/bash
set -e
echo -e "\033[1;34m** We can deploy two libraries\n** (1) Java bindings to Yoga\n** (2) Android YogaLayout\n** Which do you want to ship today? \033[0m"
read -p "" -n 1 mod
case $mod in
1 ) MODULE="java";;
2 ) MODULE="android";;
* ) echo -e "\n\033[1;34m** Invalid selection" && exit
esac
echo
echo -e "\033[1;34m** We'll need your Bintray credentials. If you don't remember them go to https://bintray.com/profile/edit\033[0m"
echo -e "\n\033[1;34m** We'll need your Bintray credentials. If you don't remember them go to https://bintray.com/profile/edit\033[0m"
echo -e "\033[1;34m** [1/3] Please enter your Bintray username (probably not your email address): \033[0m"
read -r BINTRAY_USER
@@ -15,7 +21,8 @@ uploadcmd="gradle clean build bintrayUpload --info -PbintrayUsername='$BINTRAY_U
echo
echo -e "\033[1;34m** Dry run\033[0m"
(cd java; eval "$uploadcmd -PdryRun=true")
(cd $MODULE ; eval "$uploadcmd -PdryRun=true")
echo
echo -e "\033[1;34m** Are you happy to conintue?: [yN]\033[0m"
@@ -27,4 +34,5 @@ read -p "" -n 1 yn
echo
echo -e "\033[1;34m** Publishing\033[0m"
eval "$uploadcmd"
(cd $MODULE ; eval "$uploadcmd")

View File

@@ -1,2 +1,3 @@
include ':yoga'
include ':yoga', ':yoga-layout'
project(':yoga').projectDir = file('java')
project(':yoga-layout').projectDir = file('android')