Gradle for java library
Summary: This builds the java bindings with gradle, and adds a script for Facebook employees to upload the generated artifacts to JCenter. Reviewed By: emilsjolander Differential Revision: D4597335 fbshipit-source-id: 4c01695a8638000a417bfb49deba4b9b9b4e114b
This commit is contained in:
committed by
Facebook Github Bot
parent
67717a7872
commit
5519a73087
3
.gitignore
vendored
3
.gitignore
vendored
@@ -60,3 +60,6 @@ Pods/
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# Gradle
|
||||
.gradle
|
||||
|
@@ -9,7 +9,7 @@ include_defs('//YOGA_DEFS')
|
||||
|
||||
android_aar(
|
||||
name = 'android',
|
||||
manifest_skeleton = 'AndroidManifest.xml',
|
||||
manifest_skeleton = 'src/main/AndroidManifest.xml',
|
||||
deps = [
|
||||
ANDROID_JAVA_TARGET,
|
||||
ANDROID_RES_TARGET,
|
||||
|
@@ -14,27 +14,27 @@
|
||||
|
||||
<attr name="align_content" format="enum">
|
||||
<enum name="auto" value="0"/>
|
||||
<enum name="flex-start" value="1"/>
|
||||
<enum name="flex_start" value="1"/>
|
||||
<enum name="center" value="2"/>
|
||||
<enum name="flex-end" value="3"/>
|
||||
<enum name="flex_end" value="3"/>
|
||||
<enum name="stretch" value="4"/>
|
||||
<enum name="baseline" value="5"/>
|
||||
</attr>
|
||||
|
||||
<attr name="align_items" format="enum">
|
||||
<enum name="auto" value="0"/>
|
||||
<enum name="flex-start" value="1"/>
|
||||
<enum name="flex_start" value="1"/>
|
||||
<enum name="center" value="2"/>
|
||||
<enum name="flex-end" value="3"/>
|
||||
<enum name="flex_end" value="3"/>
|
||||
<enum name="stretch" value="4"/>
|
||||
<enum name="baseline" value="5"/>
|
||||
</attr>
|
||||
|
||||
<attr name="align_self" format="enum">
|
||||
<enum name="auto" value="0"/>
|
||||
<enum name="flex-start" value="1"/>
|
||||
<enum name="flex_start" value="1"/>
|
||||
<enum name="center" value="2"/>
|
||||
<enum name="flex-end" value="3"/>
|
||||
<enum name="flex_end" value="3"/>
|
||||
<enum name="stretch" value="4"/>
|
||||
<enum name="baseline" value="5"/>
|
||||
</attr>
|
||||
@@ -65,9 +65,9 @@
|
||||
|
||||
<attr name="flex_direction" format="enum">
|
||||
<enum name="column" value="0"/>
|
||||
<enum name="column-reverse" value="1"/>
|
||||
<enum name="column_reverse" value="1"/>
|
||||
<enum name="row" value="2"/>
|
||||
<enum name="row-reverse" value="3"/>
|
||||
<enum name="row_reverse" value="3"/>
|
||||
</attr>
|
||||
|
||||
<attr name="flex_grow" format="float"/>
|
||||
@@ -79,11 +79,11 @@
|
||||
<attr name="height_percent" format="float"/>
|
||||
|
||||
<attr name="justify_content" format="enum">
|
||||
<enum name="flex-start" value="0"/>
|
||||
<enum name="flex_start" value="0"/>
|
||||
<enum name="center" value="1"/>
|
||||
<enum name="flex-end" value="2"/>
|
||||
<enum name="space-between" value="3"/>
|
||||
<enum name="space-around" value="4"/>
|
||||
<enum name="flex_end" value="2"/>
|
||||
<enum name="space_between" value="3"/>
|
||||
<enum name="space_around" value="4"/>
|
||||
</attr>
|
||||
|
||||
<attr name="margin_left" format="dimension"/>
|
||||
@@ -178,7 +178,7 @@
|
||||
<attr name="width_percent" format="float"/>
|
||||
|
||||
<attr name="wrap" format="enum">
|
||||
<enum name="no-wrap" value="0"/>
|
||||
<enum name="no_wrap" value="0"/>
|
||||
<enum name="wrap" value="1"/>
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
31
build.gradle
Normal file
31
build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||
classpath 'com.nabilhachicha:android-native-dependencies:0.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs "${rootDir}/lib/jsr-305"
|
||||
dirs "${rootDir}/lib/soloader"
|
||||
dirs "${rootDir}/lib/appcompat"
|
||||
dirs "${rootDir}/lib/android-support"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
6
java/AndroidManifest.xml
Normal file
6
java/AndroidManifest.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.facebook.yoga">
|
||||
|
||||
<application/>
|
||||
|
||||
</manifest>
|
148
java/build.gradle
Normal file
148
java/build.gradle
Normal file
@@ -0,0 +1,148 @@
|
||||
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'
|
||||
|
||||
// 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'
|
||||
}
|
||||
|
||||
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 {
|
||||
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')
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'source'
|
||||
}
|
||||
|
||||
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 {
|
||||
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
|
||||
}
|
14
java/res/values/strings.xml
Normal file
14
java/res/values/strings.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014-present, Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
This source code is licensed under the BSD-style license found in the
|
||||
LICENSE file in the root directory of this source tree. An additional grant
|
||||
of patent rights can be found in the PATENTS file in the same directory.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Yoga</string>
|
||||
</resources>
|
16
scripts/build_natives_for_gradle.sh
Executable file
16
scripts/build_natives_for_gradle.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
buck build //android:android
|
||||
|
||||
X86_DEST=build/buck-out/jniLibs/x86
|
||||
ARMV7_DEST=build/buck-out/jniLibs/armabi-v7a
|
||||
|
||||
mkdir -p $X86_DEST
|
||||
mkdir -p $ARMV7_DEST
|
||||
|
||||
cp ../buck-out/gen/java/jni#android-armv7,shared/libyoga.so $ARMV7_DEST
|
||||
cp ../buck-out/gen/java/jni#android-x86,shared/libyoga.so $X86_DEST
|
||||
|
||||
cp ../buck-out/gen/yoga#android-armv7,shared/libyogacore.so $ARMV7_DEST
|
||||
cp ../buck-out/gen/yoga#android-x86,shared/libyogacore.so $X86_DEST
|
||||
|
30
scripts/deploy_jcenter.sh
Executable file
30
scripts/deploy_jcenter.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
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 "\033[1;34m** [1/3] Please enter your Bintray username (probably not your email address): \033[0m"
|
||||
read -r BINTRAY_USER
|
||||
echo -e "\033[1;34m** [2/3] Please enter your Bintray API key: \033[0m"
|
||||
read -r BINTRAY_KEY
|
||||
echo -e "\033[1;34m** [3/3] Please enter your GPG passphrase: \033[0m"
|
||||
read -r GPG_PASS
|
||||
|
||||
uploadcmd="gradle clean build bintrayUpload --info -PbintrayUsername='$BINTRAY_USER' -PbintrayApiKey='$BINTRAY_KEY' -PbintrayGpgPassword='$GPG_PASS'"
|
||||
|
||||
echo
|
||||
echo -e "\033[1;34m** Dry run\033[0m"
|
||||
(cd java; eval "$uploadcmd -PdryRun=true")
|
||||
|
||||
echo
|
||||
echo -e "\033[1;34m** Are you happy to conintue?: [yN]\033[0m"
|
||||
read -p "" -n 1 yn
|
||||
case $yn in
|
||||
[Yy]* ) ;;
|
||||
* ) echo -e "\n\033[1;34m** Run $0 when you're ready to try again\033[0m" && exit;;
|
||||
esac
|
||||
|
||||
echo
|
||||
echo -e "\033[1;34m** Publishing\033[0m"
|
||||
eval "$uploadcmd"
|
2
settings.gradle
Normal file
2
settings.gradle
Normal file
@@ -0,0 +1,2 @@
|
||||
include ':yoga'
|
||||
project(':yoga').projectDir = file('java')
|
Reference in New Issue
Block a user