@@ -86,7 +86,9 @@ class AndroidBuild extends JavaBuild {
8686 static private final String XML_WATCHFACE_TEMPLATE = "XMLWatchFace.xml.tmpl" ;
8787
8888 // Gradle build files
89- static private final String GRADLE_SETTINGS_TEMPLATE = "Settings.gradle.tmpl" ;
89+ static private final String GRADLE_SETTINGS_TEMPLATE = "Settings.gradle.tmpl" ;
90+ static private final String GRADLE_PROPERTIES_TEMPLATE = "Properties.gradle.tmpl" ;
91+ static private final String LOCAL_PROPERTIES_TEMPLATE = "Properties.local.tmpl" ;
9092 static private final String TOP_GRADLE_BUILD_TEMPLATE = "TopBuild.gradle.tmpl" ;
9193 static private final String APP_GRADLE_BUILD_ECJ_TEMPLATE = "AppBuildECJ.gradle.tmpl" ;
9294 static private final String APP_GRADLE_BUILD_TEMPLATE = "AppBuild.gradle.tmpl" ;
@@ -288,16 +290,30 @@ private void createTopModule(String projectModules)
288290 File buildTemplate = mode .getContentFile ("templates/" + TOP_GRADLE_BUILD_TEMPLATE );
289291 File buildlFile = new File (tmpFolder , "build.gradle" );
290292 Util .copyFile (buildTemplate , buildlFile );
293+
294+ File gradlePropsTemplate = mode .getContentFile ("templates/" + GRADLE_PROPERTIES_TEMPLATE );
295+ File gradlePropsFile = new File (tmpFolder , "gradle.properties" );
296+ Util .copyFile (gradlePropsTemplate , gradlePropsFile );
291297
292- writeLocalProps (new File (tmpFolder , "local.properties" ));
293- AndroidUtil .writeFile (new File (tmpFolder , "gradle.properties" ),
294- new String []{"org.gradle.jvmargs=-Xmx1536m" });
295-
296- File settingsTemplate = mode .getContentFile ("templates/" + GRADLE_SETTINGS_TEMPLATE );
298+ File settingsTemplate = mode .getContentFile ("templates/" + GRADLE_SETTINGS_TEMPLATE );
297299 File settingsFile = new File (tmpFolder , "settings.gradle" );
298300 HashMap <String , String > replaceMap = new HashMap <String , String >();
299- replaceMap .put ("@@project_modules@@" , projectModules );
300- AndroidUtil .createFileFromTemplate (settingsTemplate , settingsFile , replaceMap );
301+ replaceMap .put ("@@project_modules@@" , projectModules );
302+ AndroidUtil .createFileFromTemplate (settingsTemplate , settingsFile , replaceMap );
303+
304+ File localPropsTemplate = mode .getContentFile ("templates/" + LOCAL_PROPERTIES_TEMPLATE );
305+ File localPropsFile = new File (tmpFolder , "local.properties" );
306+ replaceMap .clear ();
307+ final String sdkPath = sdk .getFolder ().getAbsolutePath ();
308+ if (Platform .isWindows ()) {
309+ // Windows needs backslashes escaped, or it will also accept forward
310+ // slashes in the build file. We're using the forward slashes since this
311+ // path gets concatenated with a lot of others that use forwards anyway.
312+ replaceMap .put ("@@sdk_path@@" , sdkPath .replace ('\\' , '/' ));
313+ } else {
314+ replaceMap .put ("@@sdk_path@@" , sdkPath );
315+ }
316+ AndroidUtil .createFileFromTemplate (localPropsTemplate , localPropsFile , replaceMap );
301317 }
302318
303319
@@ -551,22 +567,6 @@ private void writeResXMLWatchFace(final File xmlFolder) {
551567 }
552568
553569
554- private void writeLocalProps (final File file ) {
555- final PrintWriter writer = PApplet .createWriter (file );
556- final String sdkPath = sdk .getFolder ().getAbsolutePath ();
557- if (Platform .isWindows ()) {
558- // Windows needs backslashes escaped, or it will also accept forward
559- // slashes in the build file. We're using the forward slashes since this
560- // path gets concatenated with a lot of others that use forwards anyway.
561- writer .println ("sdk.dir=" + sdkPath .replace ('\\' , '/' ));
562- } else {
563- writer .println ("sdk.dir=" + sdkPath );
564- }
565- writer .flush ();
566- writer .close ();
567- }
568-
569-
570570 private void writeRes (File resFolder ) throws SketchException {
571571 File layoutFolder = AndroidUtil .createPath (resFolder , "layout" );
572572 writeResLayoutMainActivity (layoutFolder );
0 commit comments