Commit 8a124b92 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Added build types, separated resources according to build types. Split gradle...

Added build types, separated resources according to build types. Split gradle properties for development and production versions. Refactored RMBTAndroid/build.gradle.
parent 71bffb93
......@@ -37,8 +37,8 @@
<uses-feature android:name="android.hardware.wifi" android:required="false"/>
<application
android:icon="@drawable/app_icon"
android:logo="@drawable/app_icon"
android:icon="@mipmap/ic_launcher"
android:logo="@mipmap/ic_launcher"
android:label="@string/app_name" android:allowBackup="true"
android:supportsRtl="false">
<activity android:name="at.alladin.rmbt.android.main.RMBTMainActivity"
......
......@@ -40,9 +40,10 @@ repositories {
}
dependencies {
implementation project(":util:clientSecret")
implementation project(':util:clientSecret')
implementation project(':RMBTUtil')
compile 'com.google.android.gms:play-services:4.+' // Not supported in Eclipse now. Needs to install Google play Services from Android SDK Manager and use it as a library project.
compile 'com.google.android.gms:play-services:4.+'
// Not supported in Eclipse now. Needs to install Google play Services from Android SDK Manager and use it as a library project.
compile 'dnsjava:dnsjava:2.1.6'
compile 'net.sf.jopt-simple:jopt-simple:3.2'
}
......@@ -73,35 +74,6 @@ task prepareReleaseVersion(dependsOn: 'processReleaseManifest') {
}
}
//TODO - Find a better way
//task prepareCrashlyticsDebug(dependsOn: 'processDebugManifest') {
// doLast{
// // api key
// File manifest = file("${buildDir}/intermediates/manifests/full/debug/AndroidManifest.xml")
// String manifestContent = manifest.getText('UTF-8')
//
// // bug reporting
// if (project.hasProperty('RMBT_USE_BUGREPORT')) {
// manifestContent = manifestContent.replaceAll(/RMBT_USE_BUGREPORT/, RMBT_USE_BUGREPORT)
// }
// manifest.write(manifestContent, 'UTF-8')
// }
//}
//task prepareCrashlyticsRelease(dependsOn: 'processReleaseManifest') {
// doLast{
// // api key
// File manifest = file("${buildDir}/intermediates/manifests/full/release/AndroidManifest.xml")
// String manifestContent = manifest.getText('UTF-8')
//
// // bug reporting
// if (project.hasProperty('RMBT_USE_BUGREPORT')) {
// manifestContent = manifestContent.replaceAll(/RMBT_USE_BUGREPORT/, RMBT_USE_BUGREPORT)
// }
// manifest.write(manifestContent, 'UTF-8')
// }
//}
tasks.whenTaskAdded { task ->
if (task.name == 'processDebugResources')
task.dependsOn prepareDebugVersion
......@@ -112,17 +84,6 @@ tasks.whenTaskAdded { task ->
task.dependsOn prepareReleaseVersion
}
//TODO - Is this necessary?
//tasks.whenTaskAdded { task ->
// if (task.name == 'crashlyticsGenerateResourcesDebug')
// task.dependsOn prepareCrashlyticsDebug
//}
//
//tasks.whenTaskAdded { task ->
// if (task.name == 'crashlyticsGenerateResourcesRelease')
// task.dependsOn prepareCrashlyticsRelease
//}
// copy NDT resources to android debug
tasks.whenTaskAdded { task ->
if (task.name.startsWith("processDebugManifest")) {
......@@ -151,30 +112,43 @@ tasks.whenTaskAdded { task ->
}
}
android {
compileSdkVersion 19
sourceSets {
main {
java {
srcDirs = ['src', '../RMBTClient/src']
exclude 'at/alladin/rmbt/client/applet/RMBTApplet.java'
}
java {
srcDirs = ['src', '../RMBTClient/src']
exclude 'at/alladin/rmbt/client/applet/RMBTApplet.java'
}
manifest {
srcFile 'AndroidManifest.xml'
}
res {
srcDir 'res'
srcDir 'res/main'
}
assets {
srcDir 'assets'
}
}
}
buildTypes.all { buildType ->
buildConfigField "String", "CLIENT_SECRET", project.hasProperty('RMBT_CLIENT_SECRET') ? String.format("\"%s\"", RMBT_CLIENT_SECRET) : "null"
release {
res {
srcDir 'res/release'
}
}
debug {
res {
srcDir 'res/debug'
}
}
dev {
res {
srcDir 'res/devel'
}
}
}
defaultConfig {
......@@ -182,34 +156,59 @@ android {
versionName getVersionNameFromGit()
versionCode getVersionCodeFromGit()
applicationId = 'cz.nic.netmetr'
}
if(project.hasProperty('RMBT_CONTROL_IPV4_HOST')) {
resValue 'string', 'default_control_host', "${RMBT_CONTROL_IPV4_HOST}"
resValue 'string', 'default_control_host_ipv4_only', project.property('RMBT_CONTROL_IPV4_HOST')
}
if(project.hasProperty('RMBT_CONTROL_IPV6_HOST')) {
resValue 'string', 'default_control_host_ipv6_only', project.property('RMBT_CONTROL_IPV6_HOST')
}
if(project.hasProperty('RMBT_CONTROL_IPV4_CHECK_HOST')) {
resValue 'string', 'default_control_check_ipv4_url', project.property('RMBT_CONTROL_IPV4_CHECK_HOST')
}
if(project.hasProperty('RMBT_CONTROL_IPV6_CHECK_HOST')) {
resValue 'string', 'default_control_check_ipv6_url', project.property('RMBT_CONTROL_IPV6_CHECK_HOST')
}
if (project.hasProperty('RMBT_CONTROL_PORT')) {
resValue 'string', 'default_control_port', project.property('RMBT_CONTROL_PORT')
buildTypes {
release {
debuggable false
resValue 'string', 'app_name', 'NetMetr'
buildConfigField 'Boolean', 'DEVELOPER_OPTIONS', 'false'
buildConfigField "String", "CLIENT_SECRET", project.hasProperty('RMBT_CLIENT_SECRET_RELEASE') ? String.format("\"%s\"", RMBT_CLIENT_SECRET_RELEASE) : "null"
initializeResValues(
buildTypes.release,
'RMBT_CONTROL_IPV4_HOST_RELEASE',
'RMBT_CONTROL_IPV6_HOST_RELEASE',
'RMBT_CONTROL_IPV4_CHECK_HOST_RELEASE',
'RMBT_CONTROL_IPV6_CHECK_HOST_RELEASE',
'RMBT_CONTROL_PORT_RELEASE',
'RMBT_CONTROL_SSL_RELEASE',
'RMBT_QOS_SSL_RELEASE')
}
if (project.hasProperty('RMBT_CONTROL_SSL')) {
resValue 'string', 'default_control_ssl', project.property('RMBT_CONTROL_SSL')
debug {
applicationIdSuffix = '.debug'
resValue 'string', 'app_name', 'NetMetr Debug'
//These build config fields are inherited by dev build type
buildConfigField 'Boolean', 'DEVELOPER_OPTIONS', 'true'
buildConfigField 'String', 'CLIENT_SECRET', project.hasProperty('RMBT_CLIENT_SECRET_DEV') ? String.format("\"%s\"", RMBT_CLIENT_SECRET_DEV) : "null"
initializeResValues(
buildTypes.debug,
'RMBT_CONTROL_IPV4_HOST_RELEASE',
'RMBT_CONTROL_IPV6_HOST_RELEASE',
'RMBT_CONTROL_IPV4_CHECK_HOST_RELEASE',
'RMBT_CONTROL_IPV6_CHECK_HOST_RELEASE',
'RMBT_CONTROL_PORT_RELEASE',
'RMBT_CONTROL_SSL_RELEASE',
'RMBT_QOS_SSL_RELEASE')
}
if (project.hasProperty('RMBT_QOS_SSL')) {
resValue 'string', 'default_qos_ssl', project.property('RMBT_QOS_SSL')
dev {
initWith(buildTypes.debug) //Enable auto signing
applicationIdSuffix = '.dev'
resValue 'string', 'app_name', 'NetMetr Devel'
initializeResValues(
buildTypes.dev,
'RMBT_CONTROL_IPV4_HOST_DEV',
'RMBT_CONTROL_IPV6_HOST_DEV',
'RMBT_CONTROL_IPV4_CHECK_HOST_DEV',
'RMBT_CONTROL_IPV6_CHECK_HOST_DEV',
'RMBT_CONTROL_PORT_DEV',
'RMBT_CONTROL_SSL_DEV',
'RMBT_QOS_SSL_DEV')
}
}
......@@ -221,35 +220,52 @@ android {
&& project.hasProperty('RMBT_RELEASE_KEY_ALIAS') && project.hasProperty('RMBT_RELEASE_KEY_PASSWORD')) {
signingConfigs {
release {
storeFile file(RMBT_RELEASE_KEYSTORE)
storePassword RMBT_RELEASE_KEYSTORE_PASSWORD
keyAlias RMBT_RELEASE_KEY_ALIAS
keyPassword RMBT_RELEASE_KEY_PASSWORD
}
debug {
storeFile file(RMBT_RELEASE_KEYSTORE)
storePassword RMBT_RELEASE_KEYSTORE_PASSWORD
keyAlias RMBT_RELEASE_KEY_ALIAS
keyPassword RMBT_RELEASE_KEY_PASSWORD
storeFile file(RMBT_RELEASE_KEYSTORE)
storePassword RMBT_RELEASE_KEYSTORE_PASSWORD
keyAlias RMBT_RELEASE_KEY_ALIAS
keyPassword RMBT_RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
debuggable false
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.all { output ->
def file = output.outputFile
outputFileName = file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk")
}
}
}
}
}
}
def initializeResValues(buildType, IPv4Host, IPv6Host, IPv4CheckHost, IPv6CheckHost, ControlServerPort, ControlServerSSL, QoSServerSSL) {
if(project.hasProperty(IPv4Host)) {
buildType.resValue 'string', 'default_control_host', project.property(IPv4Host)
buildType.resValue 'string', 'default_control_host_ipv4_only', project.property(IPv4Host)
}
if(project.hasProperty(IPv6Host)) {
buildType.resValue 'string', 'default_control_host_ipv6_only', project.property(IPv6Host)
}
if(project.hasProperty(IPv4CheckHost)) {
buildType.resValue 'string', 'default_control_check_ipv4_url', project.property(IPv4CheckHost)
}
if(project.hasProperty(IPv6CheckHost)) {
buildType.resValue 'string', 'default_control_check_ipv6_url', project.property(IPv6CheckHost)
}
if (project.hasProperty(ControlServerPort)) {
buildType.resValue 'string', 'default_control_port', project.property(ControlServerPort)
}
if (project.hasProperty(ControlServerSSL)) {
buildType.resValue 'string', 'default_control_ssl', project.property(ControlServerSSL)
}
if (project.hasProperty(QoSServerSSL)) {
buildType.resValue 'string', 'default_qos_ssl', project.property(QoSServerSSL)
}
}
def getVersionNameFromGit() {
def stdoutVersion = new ByteArrayOutputStream()
exec {
......