Skip to content

Commit 60ffa19

Browse files
Robert Spencerfacebook-github-bot
authored andcommitted
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
1 parent 5519a73 commit 60ffa19

File tree

5 files changed

+176
-105
lines changed

5 files changed

+176
-105
lines changed

android/build.gradle

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
apply plugin: "com.jfrog.bintray"
2+
apply plugin: 'com.android.library'
3+
apply plugin: 'com.github.dcendents.android-maven'
4+
apply plugin: 'maven-publish'
5+
6+
targetCompatibility = '1.7'
7+
sourceCompatibility = '1.7'
8+
9+
version = '1.0.0'
10+
group = 'com.facebook.yoga.android'
11+
12+
android {
13+
compileSdkVersion 19
14+
buildToolsVersion "19.1.0"
15+
16+
defaultConfig {
17+
minSdkVersion 15
18+
targetSdkVersion 19
19+
}
20+
21+
compileOptions {
22+
sourceCompatibility JavaVersion.VERSION_1_7
23+
targetCompatibility JavaVersion.VERSION_1_7
24+
}
25+
26+
sourceSets.main {
27+
jni.srcDirs = [] // disalbe NDK auto build (not sure why this is necessary)
28+
// The alternative, fat-aar does an equivalent thing to this hack
29+
// seehttps://github.com/adwiv/android-fat-aar/blob/master/fat-aar.gradle#L307
30+
jniLibs.srcDirs = ['build/intermediates/exploded-aar/com.facebook.yoga/yoga/1.0.0/jni']
31+
}
32+
}
33+
34+
dependencies {
35+
compile project(':yoga')
36+
}
37+
38+
task sourcesJar(type: Jar) {
39+
classifier = 'source'
40+
from android.sourceSets.main.java.srcDirs
41+
}
42+
43+
task javadoc(type: Javadoc) {
44+
failOnError false
45+
source = android.sourceSets.main.java.sourceFiles
46+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
47+
classpath += configurations.compile
48+
}
49+
50+
task javadocJar(type: Jar, dependsOn: javadoc) {
51+
classifier = 'javadoc'
52+
from javadoc.destinationDir
53+
}
54+
55+
ext {
56+
bintrayName = "com.facebook.yoga.android:yoga-layout"
57+
}
58+
59+
apply from: rootProject.file('gradle/android-jcenter-install.gradle')
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
ext {
2+
bintrayUserOrg = 'facebook'
3+
bintrayRepo = 'maven'
4+
siteURL = "https://facebook.github.io/yoga/"
5+
projectLicenses = {
6+
license {
7+
name 'BSD License'
8+
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
9+
distribution 'repo'
10+
}
11+
}
12+
}
13+
14+
def getBintrayUsername() {
15+
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
16+
}
17+
18+
def getBintrayApiKey() {
19+
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
20+
}
21+
22+
def getBintrayGpgPassword() {
23+
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
24+
}
25+
26+
def dryRunOnly() {
27+
return hasProperty('dryRun') ? property('dryRun').toBoolean() : false
28+
}
29+
30+
def pomConfig = {
31+
licenses {
32+
// TODO Can we grab this from above?
33+
license {
34+
name 'BSD License'
35+
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
36+
distribution 'repo'
37+
}
38+
}
39+
}
40+
41+
publishing {
42+
publications {
43+
primaryPublication(MavenPublication) {
44+
groupId group
45+
artifact(sourcesJar)
46+
artifact(javadocJar)
47+
pom.withXml {
48+
def root = asNode()
49+
root.appendNode('name', 'Yoga')
50+
root.appendNode('url', siteURL)
51+
root.children().last() + pomConfig
52+
}
53+
}
54+
}
55+
}
56+
57+
58+
bintray {
59+
user = getBintrayUsername()
60+
key = getBintrayApiKey()
61+
publications = ['primaryPublication']
62+
configurations = ['archives']
63+
pkg {
64+
repo = bintrayRepo
65+
userOrg = bintrayUserOrg
66+
name = project.bintrayName
67+
dryRun = dryRunOnly()
68+
licenses = projectLicenses
69+
override = true
70+
publish = true
71+
publicDownloadNumbers = true
72+
version {
73+
name = project.version
74+
released = new Date()
75+
gpg {
76+
sign = true
77+
passphrase = getBintrayGpgPassword()
78+
}
79+
}
80+
}
81+
}

java/build.gradle

Lines changed: 22 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,43 @@ group = 'com.facebook.yoga'
1212
// We currently build the native libraries with buck and bundle them together
1313
// at this point into the AAR
1414
task buckBuildAndCopy(type: Exec) {
15-
commandLine '../scripts/build_natives_for_gradle.sh'
15+
commandLine '../scripts/build_natives_for_gradle.sh'
1616
}
1717

1818
android {
19-
compileSdkVersion 19
20-
buildToolsVersion "19.1.0"
19+
compileSdkVersion 19
20+
buildToolsVersion "19.1.0"
2121

22-
defaultConfig {
23-
minSdkVersion 15
24-
targetSdkVersion 19
25-
}
22+
defaultConfig {
23+
minSdkVersion 15
24+
targetSdkVersion 19
25+
}
2626

27-
compileOptions {
28-
sourceCompatibility JavaVersion.VERSION_1_7
29-
targetCompatibility JavaVersion.VERSION_1_7
30-
}
27+
compileOptions {
28+
sourceCompatibility JavaVersion.VERSION_1_7
29+
targetCompatibility JavaVersion.VERSION_1_7
30+
}
3131

32-
sourceSets {
33-
main {
34-
java.srcDir 'com'
35-
manifest.srcFile 'AndroidManifest.xml'
36-
res.srcDirs = ['res']
37-
jniLibs.srcDirs = ['build/buck-out/jniLibs']
32+
sourceSets {
33+
main {
34+
java.srcDir 'com'
35+
manifest.srcFile 'AndroidManifest.xml'
36+
res.srcDirs = ['res']
37+
jniLibs.srcDirs = ['build/buck-out/jniLibs']
38+
}
3839
}
39-
}
4040
}
4141

4242
preBuild.dependsOn buckBuildAndCopy
4343

4444
dependencies {
45-
compile(name: 'jsr305')
46-
compile(name: 'soloader-0.1.0', ext: 'aar')
45+
compile(name: 'jsr305')
46+
compile(name: 'soloader-0.1.0', ext: 'aar')
4747
}
4848

4949
task sourcesJar(type: Jar) {
50-
from android.sourceSets.main.java.srcDirs
5150
classifier = 'source'
51+
from android.sourceSets.main.java.srcDirs
5252
}
5353

5454
task javadoc(type: Javadoc) {
@@ -64,85 +64,7 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
6464
}
6565

6666
ext {
67-
bintrayRepo = 'maven'
68-
bintrayUserOrg = 'facebook'
6967
bintrayName = "com.facebook.yoga:yoga"
70-
siteURL = "https://facebook.github.io/yoga/"
71-
projectLicenses = {
72-
license {
73-
name 'BSD License'
74-
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
75-
distribution 'repo'
76-
}
77-
}
7868
}
7969

80-
81-
def pomConfig = {
82-
licenses {
83-
// TODO Can we grab this from above?
84-
license {
85-
name 'BSD License'
86-
url 'https://github.com/facebook/yoga/blob/master/LICENSE'
87-
distribution 'repo'
88-
}
89-
}
90-
}
91-
92-
publishing {
93-
publications {
94-
yoga(MavenPublication) {
95-
groupId group
96-
artifact(sourcesJar)
97-
artifact(javadocJar)
98-
pom.withXml {
99-
def root = asNode()
100-
root.appendNode('name', 'Yoga')
101-
root.appendNode('url', siteURL)
102-
root.children().last() + pomConfig
103-
}
104-
}
105-
}
106-
}
107-
108-
bintray {
109-
user = getBintrayUsername()
110-
key = getBintrayApiKey()
111-
publications = ['yoga']
112-
configurations = ['archives']
113-
pkg {
114-
repo = bintrayRepo
115-
userOrg = bintrayUserOrg
116-
name = bintrayName
117-
dryRun = dryRunOnly()
118-
licenses = projectLicenses
119-
override = true
120-
publish = true
121-
publicDownloadNumbers = true
122-
version {
123-
name = version
124-
released = new Date()
125-
gpg {
126-
sign = true
127-
passphrase = getBintrayGpgPassword()
128-
}
129-
}
130-
}
131-
}
132-
133-
134-
def getBintrayUsername() {
135-
return hasProperty('bintrayUsername') ? property('bintrayUsername') : System.getenv('BINTRAY_USERNAME')
136-
}
137-
138-
def getBintrayApiKey() {
139-
return hasProperty('bintrayApiKey') ? property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
140-
}
141-
142-
def getBintrayGpgPassword() {
143-
return hasProperty('bintrayGpgPassword') ? property('bintrayGpgPassword') : System.getenv('BINTRAY_GPG_PASSWORD')
144-
}
145-
146-
def dryRunOnly() {
147-
return hasProperty('dryRun') ? property('dryRun').toBoolean() : false
148-
}
70+
apply from: rootProject.file('gradle/android-jcenter-install.gradle')

scripts/deploy_jcenter.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#!/bin/bash
22
set -e
3+
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"
4+
read -p "" -n 1 mod
5+
case $mod in
6+
1 ) MODULE="java";;
7+
2 ) MODULE="android";;
8+
* ) echo -e "\n\033[1;34m** Invalid selection" && exit
9+
esac
310

4-
echo
5-
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"
11+
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"
612

713
echo -e "\033[1;34m** [1/3] Please enter your Bintray username (probably not your email address): \033[0m"
814
read -r BINTRAY_USER
@@ -15,7 +21,8 @@ uploadcmd="gradle clean build bintrayUpload --info -PbintrayUsername='$BINTRAY_U
1521

1622
echo
1723
echo -e "\033[1;34m** Dry run\033[0m"
18-
(cd java; eval "$uploadcmd -PdryRun=true")
24+
25+
(cd $MODULE ; eval "$uploadcmd -PdryRun=true")
1926

2027
echo
2128
echo -e "\033[1;34m** Are you happy to conintue?: [yN]\033[0m"
@@ -27,4 +34,5 @@ read -p "" -n 1 yn
2734

2835
echo
2936
echo -e "\033[1;34m** Publishing\033[0m"
30-
eval "$uploadcmd"
37+
38+
(cd $MODULE ; eval "$uploadcmd")

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
include ':yoga'
1+
include ':yoga', ':yoga-layout'
22
project(':yoga').projectDir = file('java')
3+
project(':yoga-layout').projectDir = file('android')

0 commit comments

Comments
 (0)