diff --git a/.gitignore b/.gitignore
index bfedb9c3..a0476725 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,3 +60,6 @@ Pods/
# Carthage/Checkouts
Carthage/Build
+
+# Gradle
+.gradle
diff --git a/android/BUCK b/android/BUCK
index 037f3be5..a1516b50 100644
--- a/android/BUCK
+++ b/android/BUCK
@@ -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,
diff --git a/android/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
similarity index 100%
rename from android/AndroidManifest.xml
rename to android/src/main/AndroidManifest.xml
diff --git a/android/src/main/res/values/attrs.xml b/android/src/main/res/values/attrs.xml
index dc50a5a3..8c8bd22b 100644
--- a/android/src/main/res/values/attrs.xml
+++ b/android/src/main/res/values/attrs.xml
@@ -14,27 +14,27 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -65,9 +65,9 @@
-
+
-
+
@@ -79,11 +79,11 @@
-
+
-
-
-
+
+
+
@@ -178,7 +178,7 @@
-
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..afc336f1
--- /dev/null
+++ b/build.gradle
@@ -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
+}
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
new file mode 100644
index 00000000..d2788cb5
--- /dev/null
+++ b/java/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
diff --git a/java/build.gradle b/java/build.gradle
new file mode 100644
index 00000000..9cd6c077
--- /dev/null
+++ b/java/build.gradle
@@ -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
+}
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
new file mode 100644
index 00000000..404fa8fe
--- /dev/null
+++ b/java/res/values/strings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Yoga
+
diff --git a/scripts/build_natives_for_gradle.sh b/scripts/build_natives_for_gradle.sh
new file mode 100755
index 00000000..b6448103
--- /dev/null
+++ b/scripts/build_natives_for_gradle.sh
@@ -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
+
diff --git a/scripts/deploy_jcenter.sh b/scripts/deploy_jcenter.sh
new file mode 100755
index 00000000..c88ce614
--- /dev/null
+++ b/scripts/deploy_jcenter.sh
@@ -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"
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 00000000..dba1acbf
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,2 @@
+include ':yoga'
+project(':yoga').projectDir = file('java')