From 3edbe4c8754c4eea94be1f78fd1c40daee9caaf2 Mon Sep 17 00:00:00 2001 From: Robert Atkinson Date: Mon, 8 Feb 2016 17:02:32 -0800 Subject: [PATCH 1/2] auto-track (yay!) required versionCode in YourCodeHere's build.gradle Former-commit-id: d026a66aa7fbd055d9384303e33a3f704b8c07a0 Former-commit-id: 1fc304bfc219c1a98595a38b9026700dbaa17b0e --- YourCodeHere/build.gradle | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/YourCodeHere/build.gradle b/YourCodeHere/build.gradle index 2b7e8d6de15..e9862ed42f5 100644 --- a/YourCodeHere/build.gradle +++ b/YourCodeHere/build.gradle @@ -1,3 +1,5 @@ +import java.util.regex.Pattern + apply plugin: 'com.android.application' android { @@ -15,11 +17,17 @@ android { // module from FTC HQ. If this is not done, the robot controller may potentially have // multiple versions of the app simultaneously installed, which can lead to confusion. // - // The versionName need not match; you can set that to what you may please. - // + // Here, we have a funky little Groovy script to maintain that correspondence automatically // See also: http://developer.android.com/tools/building/configuring-gradle.html - // - versionCode 6 // http://developer.android.com/tools/publishing/versioning.html + + def manifestFile = file('../FtcRobotController/src/main/AndroidManifest.xml'); + def pattern = Pattern.compile("versionCode=\"(\\d+)\"") + def manifestText = manifestFile.getText() + def matcher = pattern.matcher(manifestText) + matcher.find() + def code = Integer.parseInt(matcher.group(1)) + + versionCode code // http://developer.android.com/tools/publishing/versioning.html versionName '@string/version_name' // http://developer.android.com/tools/publishing/versioning.html } buildTypes { @@ -34,7 +42,7 @@ android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 - } + } } repositories { From a04d09765f461d691414567b2f01193b5ad45cba Mon Sep 17 00:00:00 2001 From: Robert Atkinson Date: Mon, 8 Feb 2016 17:35:27 -0800 Subject: [PATCH 2/2] build.common.gradle: centralize build.gradle management for YourCodeHere apps Former-commit-id: d727aefa998e53436835bab3942d9ae8677ed0c4 Former-commit-id: 53f1c5b9a1738c4e1d1e098366b3ce49602b035a --- YourCodeHere/build.gradle | 65 +-------------------------------- build.common.gradle | 77 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 64 deletions(-) create mode 100644 build.common.gradle diff --git a/YourCodeHere/build.gradle b/YourCodeHere/build.gradle index e9862ed42f5..3a6c2c93cca 100644 --- a/YourCodeHere/build.gradle +++ b/YourCodeHere/build.gradle @@ -1,64 +1 @@ -import java.util.regex.Pattern - -apply plugin: 'com.android.application' - -android { - compileSdkVersion 19 - buildToolsVersion "22.0.1" - - defaultConfig { - applicationId 'com.qualcomm.ftcrobotcontroller' - minSdkVersion 16 - targetSdkVersion 19 - - // Note: this versionCode must be kept in sync with the - // android:versionCode="nn" - // attribute that is found in the AndroidManifest.xml file of the FtcRobotController - // module from FTC HQ. If this is not done, the robot controller may potentially have - // multiple versions of the app simultaneously installed, which can lead to confusion. - // - // Here, we have a funky little Groovy script to maintain that correspondence automatically - // See also: http://developer.android.com/tools/building/configuring-gradle.html - - def manifestFile = file('../FtcRobotController/src/main/AndroidManifest.xml'); - def pattern = Pattern.compile("versionCode=\"(\\d+)\"") - def manifestText = manifestFile.getText() - def matcher = pattern.matcher(manifestText) - matcher.find() - def code = Integer.parseInt(matcher.group(1)) - - versionCode code // http://developer.android.com/tools/publishing/versioning.html - versionName '@string/version_name' // http://developer.android.com/tools/publishing/versioning.html - } - buildTypes { - release { - debuggable true - } - debug { - debuggable true - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 - } -} - -repositories { - flatDir { - dirs '../FtcRobotController/libs' - } -} - -dependencies { - compile files('libs/android-support-v4.jar') - compile (name:'RobotCore-release', ext:'aar') - compile (name:'Hardware-release', ext:'aar') - compile (name:'FtcCommon-release', ext:'aar') - compile (name:'ModernRobotics-release', ext:'aar') - compile (name:'Analytics-release', ext:'aar') - compile (name:'WirelessP2p-release', ext:'aar') - compile project(':SwerveRoboticsLibrary') - compile project(':FtcRobotController') -} +apply from: '../build.common.gradle' \ No newline at end of file diff --git a/build.common.gradle b/build.common.gradle new file mode 100644 index 00000000000..5251b996543 --- /dev/null +++ b/build.common.gradle @@ -0,0 +1,77 @@ +// +// build.common.gradle +// +// This contains the content of the 'build.gradle' files for all YourCodeHere applications +// built using the Swerve Library. Each individual 'build.gradle' in those applications can +// simply contain the one line: +// +// apply from: '../build.common.gradle' +// +// That will pick up this file here. This approach allows the maintenance of individual +// build.gradle files to be carried out automatically on behalf of individual YourCodeHere +// applications. + +import java.util.regex.Pattern + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 19 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId 'com.qualcomm.ftcrobotcontroller' + minSdkVersion 16 + targetSdkVersion 19 + + // Note: this versionCode must be kept in sync with the + // android:versionCode="nn" + // attribute that is found in the AndroidManifest.xml file of the FtcRobotController + // module from FTC HQ. If this is not done, the robot controller may potentially have + // multiple versions of the app simultaneously installed, which can lead to confusion. + // + // Here, we have a funky little Groovy script to maintain that correspondence automatically + // See also: http://developer.android.com/tools/building/configuring-gradle.html + + def manifestFile = file('../FtcRobotController/src/main/AndroidManifest.xml'); + def pattern = Pattern.compile("versionCode=\"(\\d+)\"") + def manifestText = manifestFile.getText() + def matcher = pattern.matcher(manifestText) + matcher.find() + def code = Integer.parseInt(matcher.group(1)) + + versionCode code // http://developer.android.com/tools/publishing/versioning.html + versionName '@string/version_name' // http://developer.android.com/tools/publishing/versioning.html + } + buildTypes { + release { + debuggable true + } + debug { + debuggable true + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } +} + +repositories { + flatDir { + dirs '../FtcRobotController/libs' + } +} + +dependencies { + compile files('libs/android-support-v4.jar') + compile (name:'RobotCore-release', ext:'aar') + compile (name:'Hardware-release', ext:'aar') + compile (name:'FtcCommon-release', ext:'aar') + compile (name:'ModernRobotics-release', ext:'aar') + compile (name:'Analytics-release', ext:'aar') + compile (name:'WirelessP2p-release', ext:'aar') + compile project(':SwerveRoboticsLibrary') + compile project(':FtcRobotController') +}