Skip to content

Commit 69890b1

Browse files
committed
create local.properties if ANDROID_SDK exists
1 parent f56f600 commit 69890b1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ allprojects {
4040
vrProperties.load(project.rootProject.file("mode/libraries/vr/library.properties").newDataInputStream())
4141
ext.vrLibVersion = vrProperties.getProperty("prettyVersion")
4242

43+
44+
def fn = project.rootProject.file("local.properties")
45+
if (!fn.exists()) {
46+
if (System.env["ANDROID_SDK"] != null) {
47+
def path = System.env["ANDROID_SDK"]
48+
fn.withWriterAppend { w ->
49+
w << "sdk.dir=${path}\n"
50+
}
51+
} else {
52+
throw new GradleException(
53+
"The file local.properties does not exist, and there is no ANDROID_SDK environmental variable defined in the system.\n" +
54+
"Define ANDROID_SDK so it points to the location of the Android SDK, or create the local.properties file manually\n" +
55+
"and add the following line to it:\n" +
56+
"sdk.dir=<path to Android SDK>")
57+
}
58+
59+
60+
// new File( folder, 'file.txt' )
61+
}
62+
63+
4364
Properties localProperties = new Properties()
4465
localProperties.load(project.rootProject.file("local.properties").newDataInputStream())
4566
def sdkDir = localProperties.getProperty("sdk.dir")

0 commit comments

Comments
 (0)