Enable gradle build for Easy setup app for Android with scons
authorJihun Ha <jihun.ha@samsung.com>
Mon, 8 Aug 2016 09:25:09 +0000 (18:25 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 8 Aug 2016 12:43:31 +0000 (12:43 +0000)
Along with the patch 10093, this is for build easy setup
Android app with gradle build in scons.

Change-Id: Ib99cb63cfe8859766b8263e5669cb2cd9d9ddba9
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10095
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml [new file with mode: 0755]
service/easy-setup/sampleapp/mediator/android/EasySetup/app/build.gradle
service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro [new file with mode: 0644]
service/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle [changed mode: 0644->0755]
service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties [new file with mode: 0644]
service/easy-setup/sampleapp/mediator/android/EasySetup/settings.gradle
service/easy-setup/sampleapp/mediator/android/SConscript [new file with mode: 0644]

index 2ae46dc..09dd228 100644 (file)
@@ -143,6 +143,10 @@ if target_os in ['android']:
 if target_os in ['linux']:
        SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
 
+if target_os in ['android']:
+       SConscript('../../sampleapp/mediator/android/SConscript')
+
+
 ######################################################################
 #Build UnitTestcases for Mediator[RichSDK]
 ################################################ ######################
diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml b/service/easy-setup/sampleapp/mediator/android/EasySetup/EasySetup.iml
new file mode 100755 (executable)
index 0000000..b8f4dc9
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<module external.linked.project.id="EasySetup" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="java-gradle" name="Java-Gradle">\r
+      <configuration>\r
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />\r
+        <option name="BUILDABLE" value="false" />\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">\r
+    <exclude-output />\r
+    <content url="file://$MODULE_DIR$">\r
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />\r
+    </content>\r
+    <orderEntry type="inheritedJdk" />\r
+    <orderEntry type="sourceFolder" forTests="false" />\r
+  </component>\r
+</module>\r
index c249744..11c057b 100644 (file)
@@ -1,21 +1,58 @@
-apply plugin: 'com.android.application'\r
-android {\r
-    compileSdkVersion 21\r
-    buildToolsVersion '21.1.2'\r
-\r
-    defaultConfig {\r
-        applicationId "org.iotivity.service.easysetup"\r
-        minSdkVersion 21\r
-        targetSdkVersion 21\r
-    }\r
-\r
-    buildTypes {\r
-        release {\r
-            minifyEnabled false\r
-            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'\r
-        }\r
-    }\r
-}\r
-\r
-dependencies {\r
-}
\ No newline at end of file
+//******************************************************************
+//
+// Copyright 2016 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 21
+    buildToolsVersion "20.0.0"
+
+    defaultConfig {
+        applicationId "org.iotivity.service.easysetup"
+        minSdkVersion 21
+        targetSdkVersion 21
+        versionCode 1
+        versionName "1.0"
+    }
+    buildTypes {
+        release {
+            minifyEnabled false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+        }
+    }
+    lintOptions {
+        abortOnError false
+    }
+}
+repositories {
+    flatDir {
+        dirs "../../../../../../../android/android_api/base/build/outputs/aar/", "../../../../../mediator/richsdk/android/EasySetupCore/build/outputs/aar/"
+    }
+}
+
+try {
+    dependencies {
+        compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
+        compile ":EasySetupCore-${RELEASE}@aar"
+    }
+} catch (all) {
+    print "${ERROR_MSG}"
+    assert all
+}
diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro b/service/easy-setup/sampleapp/mediator/android/EasySetup/app/proguard-rules.pro
new file mode 100644 (file)
index 0000000..d26150c
--- /dev/null
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /home/rahul/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
old mode 100644 (file)
new mode 100755 (executable)
index 81f1373..c02583e
@@ -1,10 +1,34 @@
+//******************************************************************\r
+//\r
+// Copyright 2016 Samsung Electronics All Rights Reserved.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//      http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+\r
 // Top-level build file where you can add configuration options common to all sub-projects/modules.\r
+\r
 buildscript {\r
     repositories {\r
         jcenter()\r
     }\r
     dependencies {\r
-        classpath 'com.android.tools.build:gradle:2.1.2'\r
+        classpath 'com.android.tools.build:gradle:1.3.0'\r
+\r
+        // NOTE: Do not place your application dependencies here; they belong\r
+        // in the individual module build.gradle files\r
     }\r
 }\r
 \r
diff --git a/service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties b/service/easy-setup/sampleapp/mediator/android/EasySetup/gradle.properties
new file mode 100644 (file)
index 0000000..23f541f
--- /dev/null
@@ -0,0 +1,47 @@
+#
+# //******************************************************************
+# //
+# // Copyright 2016 Samsung Electronics All Rights Reserved.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+# //
+# // Licensed under the Apache License, Version 2.0 (the "License");
+# // you may not use this file except in compliance with the License.
+# // You may obtain a copy of the License at
+# //
+# //      http://www.apache.org/licenses/LICENSE-2.0
+# //
+# // Unless required by applicable law or agreed to in writing, software
+# // distributed under the License is distributed on an "AS IS" BASIS,
+# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# // See the License for the specific language governing permissions and
+# // limitations under the License.
+# //
+# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+TARGET_ARCH=armeabi
+RELEASE=release
+SECURED=1
+ERROR_MSG="if building examples from android-studio, you might need to modify the default TARGET_ARCH\
+   and RELEASE in <iotivity>/android/examples/gradle.properties,\
+   if your aar file has different values for TARGET_ARCH and RELEASE"
+
index d3db109..a86cfbe 100755 (executable)
@@ -1 +1,21 @@
-include ':app'\r
+//******************************************************************
+//
+// Copyright 2016 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+include ':app'
diff --git a/service/easy-setup/sampleapp/mediator/android/SConscript b/service/easy-setup/sampleapp/mediator/android/SConscript
new file mode 100644 (file)
index 0000000..54d9624
--- /dev/null
@@ -0,0 +1,78 @@
+#//******************************************************************
+#//
+#// Copyright 2016 Samsung Electronics All Rights Reserved.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#//
+#// Licensed under the Apache License, Version 2.0 (the "License");
+#// you may not use this file except in compliance with the License.
+#// You may obtain a copy of the License at
+#//
+#//      http://www.apache.org/licenses/LICENSE-2.0
+#//
+#// Unless required by applicable law or agreed to in writing, software
+#// distributed under the License is distributed on an "AS IS" BASIS,
+#// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#// See the License for the specific language governing permissions and
+#// limitations under the License.
+#//
+#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+import os
+import platform
+Import('env')
+
+android_home = env.get('ANDROID_HOME')
+
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
+if env.get('RELEASE'):
+       ANDROID_RELEASE="release"
+else:
+       ANDROID_RELEASE="debug"
+
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
+
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
+    print '''
+***************************************** Info ********************************
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
+*   be sure to deselect all options, then select the following 2 packages:    *
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
+*       3. Continue by selecting "Install 2 Packages"                         *
+*                                                                             *
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
+*         the following file in your $HOME directory as follows:              *
+*                                                                             *
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
+*                                                                             *
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
+*    sdkman.monitor.density=108                                               *
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
+*    sdkman.show.update.only=true                                             *
+*    sdkman.ask.adb.restart=false                                             *
+*    sdkman.force.http=true                                                   *
+*    sdkman.show.updateonly=true                                              *
+*                                                                             *
+*******************************************************************************
+
+...Opening Android SDK Manager now. Once you are finished, the build will continue.
+'''
+    os.system(android_home + '/tools/android')
+
+#SConscript("../../../../../../android/android_api/SConscript")
+
+def ensure_libs(target, source, env):
+    return target, [source, env.get('BUILD_DIR') + 'liboc.so', env.get('BUILD_DIR') + 'liboc_logger.so']                        
+
+jdk_env = Environment(ENV=os.environ)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + 
+    ' build -bservice/easy-setup/sampleapp/mediator/android/EasySetup/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE),
+    emitter = ensure_libs)
+jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
+cmdBuildEasysetupApp=jdk_env.Gradle(target="EasySetup/app/apk", 
+    source="EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java")
+
+Depends(cmdBuildEasysetupApp, env.get('baseAAR'))
\ No newline at end of file