Skip to content

Commit 92c5fc8

Browse files
committed
working on gradle build file for cardboard
1 parent 1b731f5 commit 92c5fc8

File tree

5 files changed

+89
-31
lines changed

5 files changed

+89
-31
lines changed

build.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ buildscript {
1212

1313
apply plugin: 'java'
1414

15-
16-
1715
allprojects {
1816
apply plugin: 'java'
1917
// Find location of android jar relative to ANDROID_HOME
@@ -29,11 +27,10 @@ allprojects {
2927
targetCompatibility = 1.7
3028
}
3129

32-
33-
3430
dependencies {
3531
compile name: 'android'
3632
compile project(":core")
33+
compile project(":libraries:cardboard")
3734
compile group: 'org.processing', name: 'core', version: '3.2.3'
3835
compile group: 'org.processing', name: 'pde', version: '3.2.3'
3936
compile group: 'org.processing', name: 'java-mode', version: '3.2.3'
@@ -47,7 +44,6 @@ sourceSets {
4744
}
4845
}
4946

50-
5147
import java.nio.file.Files
5248
import org.zeroturnaround.zip.ZipUtil
5349
import org.apache.commons.io.FileUtils
@@ -56,6 +52,7 @@ import static java.nio.file.StandardCopyOption.*;
5652
task dist {
5753
try {
5854
def root = "$buildDir/zip/AndroidMode"
55+
5956
// Copy assets to build dir
6057
FileUtils.copyDirectory(file("templates"), file("$root/templates"))
6158
FileUtils.copyDirectory(file("examples"), file("$root/examples"))
@@ -77,9 +74,6 @@ task dist {
7774
ZipUtil.pack(file("$buildDir/zip"), new File("release/AndroidMode.zip"))
7875
Files.copy(file("mode.properties").toPath(),
7976
file("release/AndroidMode.txt").toPath(), REPLACE_EXISTING);
80-
Files.copy(file("core/build/libs/android-core.zip").toPath(),
81-
file("android-core.zip").toPath(), REPLACE_EXISTING);
82-
8377
} catch (Exception ex) {
8478
logger.error ex.getMessage()
8579
}

core/build.gradle

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ buildscript {
88
dependencies {
99
classpath group: 'commons-io', name: 'commons-io', version: '2.5'
1010
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.9'
11-
1211
}
1312
}
1413

1514
// Find location of android jar relative to ANDROID_HOME
1615
def android_platform = "$sdkdir/platforms/android-$sdkver"
16+
def core_jar_path = "../android-core.zip"
1717

1818
// Check to see if required API exists
1919
// TODO: Look for any higher SDK and use it.
@@ -28,16 +28,7 @@ repositories {
2828

2929
dependencies {
3030
compile name: 'android'
31-
32-
// android-support-v4.jar is in $sdkdir/extras/android/support/v4
3331
compile name: 'android-support-v4'
34-
35-
// Could not find the source of the wearable aars in Android Studio, so far
36-
// these two repositories seem to have up-to-date versions:
37-
// http://mvn.sibext.com/com/google/android/support/wearable/
38-
// http://uiq3.sourceforge.net/Repository/com/google/android/support/wearable/
39-
// MavenCentral and JCenter don't seem to have any wearable file.
40-
// Use the wear-update script to create a new wearable-$version jar
4132
compile name: 'wearable-1.4.0'
4233
}
4334

@@ -52,7 +43,6 @@ sourceSets {
5243
}
5344
}
5445

55-
5646
// Create Jar
5747
jar {
5848
manifest {
@@ -61,27 +51,24 @@ jar {
6151
"Gradle-Version": "$gradle.gradleVersion"
6252
)
6353
}
64-
54+
}
6555

56+
clean.doFirst {
57+
delete "$core_jar_path"
6658
}
6759

6860
import groovy.util.AntBuilder
6961
import java.nio.file.Files
7062
import static java.nio.file.StandardCopyOption.*;
7163

72-
//import org.apache.commons.io.FileUtils
73-
//import org.zeroturnaround.zip.ZipUtil
74-
75-
7664
task dist {
7765
doLast {
7866
// make copy of jar file as zip
7967
Files.copy(file("$buildDir/libs/core.jar").toPath(),
8068
file("$buildDir/libs/android-core.zip").toPath(), REPLACE_EXISTING);
81-
82-
//FileUtils.copyDirectory(file("src/assets"), file("$buildDir/zip/assets"))
83-
//FileUtils.copyDirectory(file("$buildDir/classes/main"), file("$buildDir/zip/"))
84-
//ZipUtil.pack(file("$buildDir/zip"), new File("$buildDir/libs/android-core.zip"))
69+
70+
Files.copy(file("$buildDir/libs/core.jar").toPath(),
71+
file("$core_jar_path").toPath(), REPLACE_EXISTING);
8572
}
8673
}
8774

libraries/cardboard/build.gradle

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
apply plugin: 'java'
2+
3+
buildscript {
4+
repositories {
5+
// mavenCentral()
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath group: 'commons-io', name: 'commons-io', version: '2.5'
10+
classpath group: 'org.zeroturnaround', name: 'zt-zip', version: '1.9'
11+
}
12+
}
13+
14+
// Find location of android jar relative to ANDROID_HOME
15+
def android_platform = "$sdkdir/platforms/android-$sdkver"
16+
def core_libs_path = "../../core/build/libs"
17+
18+
// Check to see if required API exists
19+
// TODO: Look for any higher SDK and use it.
20+
if (!file(android_platform).exists()) {
21+
logger.error "Android SDK $sdkver could not be found in $sdkdir"
22+
}
23+
24+
repositories {
25+
//jcenter()
26+
flatDir {dirs 'lib', core_libs_path, android_platform}
27+
}
28+
29+
dependencies {
30+
compile name: 'android'
31+
compile name: 'core'
32+
compile name: 'gvr-base'
33+
compile name: 'gvr-common'
34+
compile name: 'gvr-audio'
35+
}
36+
37+
sourceSets {
38+
main {
39+
java {
40+
srcDirs = ['src/']
41+
}
42+
resources {
43+
srcDirs = ['src/']
44+
}
45+
}
46+
}
47+
48+
// Create Jar
49+
jar {
50+
manifest {
51+
attributes(
52+
"Manifest-Version": "1.0",
53+
"Gradle-Version": "$gradle.gradleVersion"
54+
)
55+
}
56+
}
57+
58+
clean.doFirst {
59+
// delete "$core_jar_path"
60+
}
61+
62+
import groovy.util.AntBuilder
63+
import java.nio.file.Files
64+
import static java.nio.file.StandardCopyOption.*;
65+
66+
task dist {
67+
doLast {
68+
// make copy of jar file as zip
69+
// Files.copy(file("$buildDir/libs/core.jar").toPath(),
70+
// file("$buildDir/libs/android-core.zip").toPath(), REPLACE_EXISTING);
71+
72+
// Files.copy(file("$buildDir/libs/core.jar").toPath(),
73+
// file("$core_jar_path").toPath(), REPLACE_EXISTING);
74+
}
75+
}
76+
77+
dist.dependsOn build

libraries/cardboard/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
encoding="UTF-8"
3131
includeAntRuntime="false"
3232
classpath="lib/gvr-base.jar;
33-
lib/gvr-common.jar;
34-
lib/gvr-audio.jar;
33+
lib/gvr-common.jar;
34+
lib/gvr-audio.jar;
3535
../../android-core.zip;
3636
${env.ANDROID_SDK}/platforms/android-23/android.jar"
3737
nowarn="true"

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include 'core'
1+
include 'core', 'libraries:cardboard'

0 commit comments

Comments
 (0)