Skip to content

Commit 0c980d0

Browse files
committed
added gradle version to properties
1 parent ff98245 commit 0c980d0

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

mode/src/processing/mode/android/AndroidBuild.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class AndroidBuild extends JavaBuild {
6363
// Versions of all required dependencies
6464
static public String TARGET_SDK;
6565
static public String TARGET_PLATFORM;
66+
static public String GRADLE_VER;
6667
static public String APPCOMPAT_VER;
6768
static public String V4LEGACY_VER;
6869
static public String PLAY_SERVICES_VER;
@@ -287,18 +288,21 @@ protected boolean gradleBuild() throws SketchException {
287288

288289

289290
private void createTopModule(String projectModules)
290-
throws IOException {
291+
throws IOException {
292+
HashMap<String, String> replaceMap = new HashMap<String, String>();
293+
291294
File buildTemplate = mode.getContentFile("templates/" + TOP_GRADLE_BUILD_TEMPLATE);
292295
File buildlFile = new File(tmpFolder, "build.gradle");
293-
Util.copyFile(buildTemplate, buildlFile);
296+
replaceMap.put("@@gradle_version@@", GRADLE_VER);
297+
AndroidUtil.createFileFromTemplate(buildTemplate, buildlFile, replaceMap);
294298

295299
File gradlePropsTemplate = mode.getContentFile("templates/" + GRADLE_PROPERTIES_TEMPLATE);
296300
File gradlePropsFile = new File(tmpFolder, "gradle.properties");
297301
Util.copyFile(gradlePropsTemplate, gradlePropsFile);
298302

299303
File settingsTemplate = mode.getContentFile("templates/" + GRADLE_SETTINGS_TEMPLATE);
300304
File settingsFile = new File(tmpFolder, "settings.gradle");
301-
HashMap<String, String> replaceMap = new HashMap<String, String>();
305+
replaceMap.clear();
302306
replaceMap.put("@@project_modules@@", projectModules);
303307
AndroidUtil.createFileFromTemplate(settingsTemplate, settingsFile, replaceMap);
304308

@@ -903,9 +907,15 @@ static public void initVersions(File file) {
903907
MIN_SDK_AR = props.getProperty("android-min-ar");
904908
MIN_SDK_WATCHFACE = props.getProperty("android-min-wear");
905909

906-
// Versions of the target sdk, support, play services, wear, VR, and AR are stored in
907-
// preferences file so they can be changed by the user without having to rebuilt/reinstall
908-
// the mode.
910+
// Versions strings of all dependencies are stored in a preferences file so they can be changed by the
911+
// user without having to rebuild/reinstall the mode.
912+
913+
GRADLE_VER = Preferences.get("android.gradle");
914+
String defGradleVersion = props.getProperty("gradle");
915+
if (GRADLE_VER == null || PApplet.parseInt(GRADLE_VER) != PApplet.parseInt(defGradleVersion)) {
916+
GRADLE_VER = defGradleVersion;
917+
Preferences.set("android.gradle", GRADLE_VER);
918+
}
909919

910920
TARGET_SDK = Preferences.get("android.sdk.target");
911921
String defTargetSDK = props.getProperty("android-platform");

mode/templates/TopBuild.gradle.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
jcenter()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.1.1'
10+
classpath 'com.android.tools.build:gradle:@@gradle_version@@'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

mode/version.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
android-platform = 29
33
android-toolslib = 27.1.1
44
gradlew = 6.7.1
5+
gradle = 4.1.1
56

67
# Minimum SDK versions for each type of project
78
android-min-app = 17

0 commit comments

Comments
 (0)