From ba31f88ed17fbd8958fd58527af3b1776ad4344c Mon Sep 17 00:00:00 2001 From: George Nash Date: Tue, 1 Aug 2017 17:33:32 -0700 Subject: [PATCH] IOT-2533 Build java with scons When building generic_java stop using gradle. Gradle is required to build aar and apk files for android but scons is capable of building the java code without using gradle. This also has the side effect that we can add a more complete manifest file that makes running the samples simpler. We no longer need to run long commandline java commands to start the samples. example: cd /java java -Djava.library.path=.. -jar simplerserver.jar See IOT-2419 for SECURED=1 build Bug: Bug: https://jira.iotivity.org/browse/IOT-2419 Bug: https://jira.iotivity.org/browse/IOT-2533 Change-Id: I8bf5228173745d26114e612a0d82d1f28060d801 Signed-off-by: George Nash Reviewed-on: https://gerrit.iotivity.org/gerrit/21965 Tested-by: jenkins-iotivity Reviewed-by: Larry Sachs Reviewed-by: Rick Bell --- build_common/external_libs.scons | 11 +- build_common/linux/SConscript | 27 --- build_common/windows/SConscript | 28 --- java/SConscript | 212 ++++++++++++++++----- java/examples-java/SConscript | 32 ++++ java/examples-java/build.gradle | 22 --- java/examples-java/gradle.properties | 47 ----- java/examples-java/gradlew | 164 ---------------- java/examples-java/gradlew.bat | 90 --------- java/examples-java/settings.gradle | 1 - java/examples-java/simpleclient/.gitignore | 1 - java/examples-java/simpleclient/MANIFEST.MF | 3 + java/examples-java/simpleclient/SConscript | 26 +++ java/examples-java/simpleclient/build.gradle | 0 java/examples-java/simpleclientserver/.gitignore | 1 - java/examples-java/simpleclientserver/MANIFEST.MF | 3 + java/examples-java/simpleclientserver/SConscript | 33 ++++ java/examples-java/simpleclientserver/build.gradle | 0 java/examples-java/simpleserver/.gitignore | 1 - java/examples-java/simpleserver/MANIFEST.MF | 3 + java/examples-java/simpleserver/SConscript | 34 ++++ java/examples-java/simpleserver/build.gradle | 1 - java/iotivity-java/build.gradle | 37 ---- java/iotivity-java/settings.gradle | 23 --- 24 files changed, 305 insertions(+), 495 deletions(-) create mode 100644 java/examples-java/SConscript delete mode 100755 java/examples-java/build.gradle delete mode 100644 java/examples-java/gradle.properties delete mode 100755 java/examples-java/gradlew delete mode 100755 java/examples-java/gradlew.bat delete mode 100755 java/examples-java/settings.gradle delete mode 100644 java/examples-java/simpleclient/.gitignore create mode 100644 java/examples-java/simpleclient/MANIFEST.MF create mode 100644 java/examples-java/simpleclient/SConscript delete mode 100644 java/examples-java/simpleclient/build.gradle delete mode 100644 java/examples-java/simpleclientserver/.gitignore create mode 100644 java/examples-java/simpleclientserver/MANIFEST.MF create mode 100644 java/examples-java/simpleclientserver/SConscript delete mode 100644 java/examples-java/simpleclientserver/build.gradle delete mode 100644 java/examples-java/simpleserver/.gitignore create mode 100644 java/examples-java/simpleserver/MANIFEST.MF create mode 100644 java/examples-java/simpleserver/SConscript delete mode 100644 java/examples-java/simpleserver/build.gradle delete mode 100755 java/iotivity-java/build.gradle delete mode 100644 java/iotivity-java/settings.gradle diff --git a/build_common/external_libs.scons b/build_common/external_libs.scons index 9088e93..10326a4 100644 --- a/build_common/external_libs.scons +++ b/build_common/external_libs.scons @@ -34,14 +34,15 @@ if env.get('BUILD_JAVA') is True and target_os != 'android': env.AppendUnique(CPPDEFINES=['__JAVA__']) if target_os in ['windows', 'winrt']: env.AppendUnique(CPPPATH=[ - java_home + '/include', - java_home + '/include/win32' + java_home + '/include', + java_home + '/include/win32' ]) + env.AppendENVPath('PATH', java_home + '/bin') else: env.AppendUnique(CPPPATH=[ - java_home + '/include', - java_home + '/include/' + target_os - ]) + java_home + '/include', + java_home + '/include/' + target_os + ]) else: msg = "Error: BUILD_JAVA requires JAVA_HOME to be set for target '%s'" % target_os Exit(msg) diff --git a/build_common/linux/SConscript b/build_common/linux/SConscript index 5632296..a7aa15c 100644 --- a/build_common/linux/SConscript +++ b/build_common/linux/SConscript @@ -8,33 +8,6 @@ Import('env') src_dir = env.get('SRC_DIR') -help_vars = Variables() -if env.get('BUILD_JAVA') == True: - if not env.get('ANDROID_GRADLE'): - SConscript('../../extlibs/android/gradle/SConscript') - help_vars.Add( - PathVariable('ANDROID_GRADLE', - 'Android Gradle directory', - default=os.path.join( - src_dir, 'extlibs', 'android', - 'gradle', 'gradle-2.2.1/bin/gradle'))) - - if env.get('ANDROID_GRADLE'): - android_gradle = env.get('ANDROID_GRADLE') - else: - print ''' -*************************************** Info ********************************** -* Android Gradle path is not set, the default will be used. You can set -* environment variable ANDROID_GRADLE or add it on the command line as: -* # scons ANDROID_GRADLE= ... -******************************************************************************* -''' - android_gradle = os.path.join( - src_dir, 'extlibs', 'android', 'gradle', 'gradle-2.2.1', 'bin', 'gradle') - -help_vars.Update(env) -Help(help_vars.GenerateHelpText(env)) - # Add the default lib directory build_dir = env.get('BUILD_DIR') env.AppendUnique(LIBPATH=[build_dir]) diff --git a/build_common/windows/SConscript b/build_common/windows/SConscript index 015d145..6496d13 100644 --- a/build_common/windows/SConscript +++ b/build_common/windows/SConscript @@ -103,34 +103,6 @@ def MSBuildClean(env, target, solutionfile): % (solutionfile, configuration, platform, outdir) env.Execute(msbuild_cmd) -help_vars = Variables() -if env.get('BUILD_JAVA') == True: - if not env.get('ANDROID_GRADLE'): - SConscript('../../extlibs/android/gradle/SConscript') - help_vars.Add( - PathVariable('ANDROID_GRADLE', - 'Android Gradle directory', - default=os.path.join( - src_dir, 'extlibs', 'android', - 'gradle', 'gradle-2.2.1/bin/gradle'))) - - if env.get('ANDROID_GRADLE'): - android_gradle = env.get('ANDROID_GRADLE') - else: - print( -''' -*************************************** Info ********************************** -* Android Gradle path is not set, the default will be used. You can set -* environment variable ANDROID_GRADLE or add it on the command line as: -* # scons ANDROID_GRADLE= ... -******************************************************************************* -''') - android_gradle = os.path.join( - src_dir, 'extlibs', 'android', 'gradle', 'gradle-2.2.1', 'bin', 'gradle') - -help_vars.Update(env) -Help(help_vars.GenerateHelpText(env)) - if env.get('MSVC_UWP_APP') == '1': # Create an MSBuilder that uses a generator to generate the MSBuild actions MSBuilder = Builder(generator = MSBuildGenerator) diff --git a/java/SConscript b/java/SConscript index aa3321a..208fd90 100644 --- a/java/SConscript +++ b/java/SConscript @@ -1,5 +1,28 @@ +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Copyright 2017 Intel Corporation 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 SCons import os import platform +import subprocess +from distutils.version import StrictVersion Import('env') PROJECT_VERSION = env.get('PROJECT_VERSION') @@ -57,7 +80,7 @@ else: if 'NFC' in TARGET_TRANSPORT: TRANSPORT_NFC = 1 -if target_os == "android": +if target_os in ['android']: android_home = env.get('ANDROID_HOME') os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME') os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK') @@ -95,12 +118,87 @@ if target_os == "android": def ensure_libs(target, source, env): if platform.system() == 'Windows': - return target, [source, env.get('BUILD_DIR') + 'ca-interface.dll', + return target, [source, env.get('BUILD_DIR') + 'ca-interface.dll', env.get('BUILD_DIR') + 'ocstack-jni.dll'] else: return target, [source, env.get('BUILD_DIR') + 'libca-interface.so', env.get('BUILD_DIR') + 'libocstack-jni.so'] +def find_scons_java_version(env): + ''' + Attempt to find the version of the javac tool that will be used to build + the java code. + This will return a string that SHOULD be placed into SCons' JAVAVERSION + environment variable. + If a version can not be determined return None + ''' + possible_versions = ['1.8', '1.7', '1.6', '1.5'] + # This command is used to get the java version used. + # Then walk through the output line by line to see if it has one of the + # expected java version. Note older versions of SCons do not support newer + # versions of Java. Since the way java code is compiled by SCons has not + # changed significantly since Java 1.6 we just tell SCons to use the + # maximum version of Java that was supported for by SCons for a given + # release + # SCons 2.1.0 Java 1.6 support (older versions of SCons were not investigated) + # SCons 2.3.0 Java 1.7 support added + # SCons 2.3.3 Java 1.8 support added + # Support for Java 1.9 not yet added. At this time JDK1.9 has not be released + # Until support for Java 1.9 is officially added to SCons this script will + # use the the 1.8 for the JAVAVERSION. + javac_cmd = os.path.join(env['JAVA_HOME'], 'bin', 'javac') + java_ver = subprocess.check_output([javac_cmd, '-version'], stderr=subprocess.STDOUT) + print('Trying to discover the version of Java used for compilation') + scons_version = SCons.__version__ + if StrictVersion(scons_version) < StrictVersion('2.1.0'): + print('\t***** Version of SCons older than 2.0.0 detected. *****') + print('\t***** Java build will likely fail or have errors in the build output. *****') + print('\t***** Recommend updating to the latest version of SCons *****') + return None + for line in java_ver.split('\n'): + # handle building with versions of Java not supported by SCons + if ' 1.9' in line: + print('\tJava version 1.9 found.') + if StrictVersion(scons_version) <= StrictVersion('2.2.0'): + print('\tJava 1.9 not supported in SCons ' + scons_version + ', max supported Java 1.6.') + print('\tSetting JAVAVERSION to 1.6') + return '1.6' + if StrictVersion(scons_version) <= StrictVersion('2.3.2'): + print('\tJava 1.9 not supported in SCons ' + scons_version + ', max supported Java 1.7.') + print('\tSetting JAVAVERSION to 1.7') + return '1.7' + if StrictVersion(scons_version) > StrictVersion('2.5.1'): + # only printing this if Java 1.9 is found. Newer versions of + # scons should be able to handle older versions of Java + print('\t***** Unrecognized version of SCons found in java version Check. Build script may need to be updated *****') + # drop through to the next if statement. + if StrictVersion(scons_version) > StrictVersion('2.3.2'): + print('\tJava 1.9 not supported in SCons ' + scons_version + ', max supported Java 1.8.') + print('\tSetting JAVAVERSION to 1.8') + return '1.8' + if ' 1.8' in line: + print('\tJava version 1.8 found.') + if StrictVersion(scons_version) <= StrictVersion('2.2.0'): + print('\tJava 1.8 not supported in SCons ' + scons_version + ', max supported Java 1.6.') + print('\tSetting JAVAVERSION to 1.6') + return '1.6' + if StrictVersion(scons_version) <= StrictVersion('2.3.2'): + print('\tJava 1.8 not supported in SCons ' + scons_version + ', max supported Java 1.7.') + print('\tSetting JAVAVERSION to 1.7') + return '1.7' + if ' 1.7' in line: + print('\tJava version 1.7 found.') + if StrictVersion(scons_version) <= StrictVersion('2.2.0'): + print('\tJava 1.7 not supported in SCons ' + scons_version + ', max supported Java 1.6.') + print('\tSetting JAVAVERSION to 1.6') + return '1.6' + # handle versions supported by SCons + for v in possible_versions: + if (' ' + v) in line: + print('\tSetting JAVAVERSION to ' + v) + return v + print('\tJava version NOT found!') + return None jniOut = SConscript('jni/SConscript') @@ -108,44 +206,71 @@ target_variant = "java" if target_os == 'android': target_variant = "android" -jdk_env = Environment(ENV=os.environ) -jdk_env['BUILDERS']['Gradle'] = Builder( - action=env.get('ANDROID_GRADLE') + ' build -b ' + env.get('SRC_DIR') + - '/java/iotivity-%s/build.gradle -PPROJECT_VERSION=%s -PWITH_TRANSPORT_EDR=%s -PWITH_TRANSPORT_BLE=%s -PWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' - % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, - TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, - MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')), - emitter=ensure_libs) -jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') -cmdBuildApi = jdk_env.Gradle( - target="base/objs", - source="common/src/main/java/org/iotivity/base/OcResource.java") - -jdk_env['BUILDERS']['Gradle'] = Builder( - action=env.get('ANDROID_GRADLE') + ' build -b ' + - 'java/examples-%s/build.gradle -PPROJECT_VERSION=%s -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' - % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, - TRANSPORT_NFC, target_os, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, - RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, - env.get('BUILD_DIR'))) -#cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (target_variant, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (target_variant, )) -cmdBuildExamples = jdk_env.Gradle( - target="examples-%s/simpleclient/jar" % (target_variant, ), - source= - "examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java" - % (target_variant, )) - -if target_os != 'android': - exampleAclFiles = jdk_env.Install( - '#java/examples-java/simpleserver/build/libs/', - 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat') - exampleAclFiles += jdk_env.Install( - '#java/examples-java/simpleclientserver/build/libs/', - 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat') - Depends(exampleAclFiles, cmdBuildExamples) - -Depends(cmdBuildExamples, cmdBuildApi) -Depends(cmdBuildExamples, jniOut) +jdk_env = None +if target_os in ['android']: + # IOT-2559 Why does Gradle build require importing the os.environ + jdk_env = Environment(ENV=os.environ) +else: + jdk_env = env.Clone() + + +cmdBuildApi = [] +cmdBuildExamples = [] +if target_os in ['android']: + jdk_env['BUILDERS']['Gradle'] = Builder( + action=env.get('ANDROID_GRADLE') + ' build -b ' + env.get('SRC_DIR') + + '/java/iotivity-%s/build.gradle -PPROJECT_VERSION=%s -PWITH_TRANSPORT_EDR=%s -PWITH_TRANSPORT_BLE=%s -PWITH_TRANSPORT_NFC=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' + % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, TRANSPORT_NFC, + TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, RD_MODE, MQ_PUB, MQ_SUB, + MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, env.get('BUILD_DIR')), + emitter=ensure_libs) + jdk_env['BUILD_DIR'] = env.get('BUILD_DIR') + + cmdBuildApi = jdk_env.Gradle( + target="base/objs", + source="common/src/main/java/org/iotivity/base/OcResource.java") + + jdk_env.NoClean(cmdBuildApi) + jdk_env['BUILDERS']['Gradle'] = Builder( + action=env.get('ANDROID_GRADLE') + ' build -b ' + + 'java/examples-%s/build.gradle -PPROJECT_VERSION=%s -DWITH_TRANSPORT_EDR=%s -DWITH_TRANSPORT_BLE=%s -DWITH_TRANSPORT_NFC=%s -PTARGET_OS=%s -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s -PWITH_CLOUD=%s -PRD_MODE=%s -PWITH_MQ_PUB=%s -PWITH_MQ_SUB=%s -PWITH_MQ_BROKER=%s -PWITH_TCP=%s -PMULTIPLE_OWNER=%s -PBUILD_DIR=%s --stacktrace' + % (target_variant, PROJECT_VERSION, TRANSPORT_EDR, TRANSPORT_BLE, + TRANSPORT_NFC, target_os, TARGET_ARCH, RELEASE, SECURED, SECURED, CLOUD, + RD_MODE, MQ_PUB, MQ_SUB, MQ_BROKER, TCP, ANDROID_MULTIPLE_OWNER, + env.get('BUILD_DIR'))) + #cmdBuildExamples=jdk_env.Gradle(target="../examples-%s/devicediscoveryclient/apk" % (target_variant, ), source="examples-%s/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java" % (target_variant, )) + cmdBuildExamples = jdk_env.Gradle( + target="examples-%s/simpleclient/jar" % (target_variant, ), + source= + "examples-%s/simpleclient/src/main/java/org/iotivity/base/examples/SimpleClient.java" + % (target_variant, )) + jdk_env.NoClean(cmdBuildExamples) + + if target_os != 'android': + exampleAclFiles = jdk_env.Install( + '.', + 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat') + exampleAclFiles += jdk_env.Install( + '.', + 'examples-java/simpleserver/src/main/assets/oic_svr_db_server.dat') + Depends(exampleAclFiles, cmdBuildExamples) + + Depends(cmdBuildExamples, cmdBuildApi) + Depends(cmdBuildExamples, jniOut) +else: + # Build iotivity.jar + # TODO At this time we expect this build flag is required for i18n support + # need to do additional testing to verify this assumption. + jdk_env.Append(JAVACFLAGS=['-encoding', 'UTF-8']) + java_v = find_scons_java_version(jdk_env) + if java_v != None: + jdk_env.Append(JAVAVERSION=java_v) + jdk_env.Append(JAVASOURCEPATH=['java/iotivity-java/src/main/java', 'java/common/src/main/java']) + java_class_out = jdk_env.Java(target='classes', source=['iotivity-java/src/main/java', 'common/src/main/java']) + cmdBuildApi = jdk_env.Jar(target='iotivity.jar', source=java_class_out) + + # Build examples + jdk_env.SConscript('examples-java/SConscript', exports='jdk_env') if target_os == 'android': jdk_env.Clean(cmdBuildExamples, '#/java/iotivity-android/build/') @@ -186,12 +311,5 @@ if target_os == 'android': '#/java/examples-android/simpleclientserver/build/') jdk_env.Clean(cmdBuildExamples, '#/java/examples-android/simpleserver/build/') -else: - jdk_env.Clean(cmdBuildExamples, '#/java/iotivity-linux/build/') - jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/build/') - jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/simpleclient/build/') - jdk_env.Clean(cmdBuildExamples, - '#/java/examples-java/simpleclientserver/build/') - jdk_env.Clean(cmdBuildExamples, '#/java/examples-java/simpleserver/build/') env.AppendUnique(baseAAR=cmdBuildApi) diff --git a/java/examples-java/SConscript b/java/examples-java/SConscript new file mode 100644 index 0000000..da85f05 --- /dev/null +++ b/java/examples-java/SConscript @@ -0,0 +1,32 @@ +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Copyright 2017 Intel Corporation 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('jdk_env') + +# Build examples + +# Build simplerserver sample +jdk_env.SConscript('simpleserver/SConscript', exports='jdk_env') + +# Build simpleclient sample +jdk_env.SConscript('simpleclient/SConscript', exports='jdk_env') + +# Build simpleclientserver sample +jdk_env.SConscript('simpleclientserver/SConscript', exports='jdk_env') \ No newline at end of file diff --git a/java/examples-java/build.gradle b/java/examples-java/build.gradle deleted file mode 100755 index 5f5a666..0000000 --- a/java/examples-java/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - repositories { - jcenter() - } - dependencies { - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - apply plugin: 'java' - repositories { - jcenter() - } - dependencies { - compile fileTree(dir: "../../iotivity-java/build/libs/", include: '*.jar') - } -} diff --git a/java/examples-java/gradle.properties b/java/examples-java/gradle.properties deleted file mode 100644 index 9046951..0000000 --- a/java/examples-java/gradle.properties +++ /dev/null @@ -1,47 +0,0 @@ -# -# //****************************************************************** -# // -# // Copyright 2015 Intel Corporation. -# // -# //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# // -# // 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 /android/examples/gradle.properties,\ - if your aar file has different values for TARGET_ARCH and RELEASE" - diff --git a/java/examples-java/gradlew b/java/examples-java/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/java/examples-java/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/java/examples-java/gradlew.bat b/java/examples-java/gradlew.bat deleted file mode 100755 index aec9973..0000000 --- a/java/examples-java/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/java/examples-java/settings.gradle b/java/examples-java/settings.gradle deleted file mode 100755 index 2c00535..0000000 --- a/java/examples-java/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':simpleserver', ':simpleclient', ':simpleclientserver'//, ':fridgeserver', ':fridgeclient', ':guiclient', ':provisioningclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver' diff --git a/java/examples-java/simpleclient/.gitignore b/java/examples-java/simpleclient/.gitignore deleted file mode 100644 index 3543521..0000000 --- a/java/examples-java/simpleclient/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/java/examples-java/simpleclient/MANIFEST.MF b/java/examples-java/simpleclient/MANIFEST.MF new file mode 100644 index 0000000..d22eb77 --- /dev/null +++ b/java/examples-java/simpleclient/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: iotivity.jar +Main-Class: org.iotivity.base.examples.SimpleClient diff --git a/java/examples-java/simpleclient/SConscript b/java/examples-java/simpleclient/SConscript new file mode 100644 index 0000000..40f348f --- /dev/null +++ b/java/examples-java/simpleclient/SConscript @@ -0,0 +1,26 @@ +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Copyright 2017 Intel Corporation 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('jdk_env') + +# Build simpleclient sample +simpleclient_classes = jdk_env.Java(target='classes', source=['src/main/java']) +example_jar = jdk_env.Jar(target='simpleclient.jar', source=[simpleclient_classes, 'MANIFEST.MF']) +jdk_env.Install("../..", example_jar) \ No newline at end of file diff --git a/java/examples-java/simpleclient/build.gradle b/java/examples-java/simpleclient/build.gradle deleted file mode 100644 index e69de29..0000000 diff --git a/java/examples-java/simpleclientserver/.gitignore b/java/examples-java/simpleclientserver/.gitignore deleted file mode 100644 index 3543521..0000000 --- a/java/examples-java/simpleclientserver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/java/examples-java/simpleclientserver/MANIFEST.MF b/java/examples-java/simpleclientserver/MANIFEST.MF new file mode 100644 index 0000000..f3a92a1 --- /dev/null +++ b/java/examples-java/simpleclientserver/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: iotivity.jar +Main-Class: org.iotivity.base.examples.SimpleClientServer diff --git a/java/examples-java/simpleclientserver/SConscript b/java/examples-java/simpleclientserver/SConscript new file mode 100644 index 0000000..cee5170 --- /dev/null +++ b/java/examples-java/simpleclientserver/SConscript @@ -0,0 +1,33 @@ +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Copyright 2017 Intel Corporation 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('jdk_env') + +# Build simpleclientserver sample +simpleclientserver_classes = jdk_env.Java(target='classes', source=['src/main/java']) +# jdk_env.Jar(target='simpleclientserver.jar', +# source=[simpleclientserver_classes, 'MANIFEST.MF']) +# SCons is incorrectly calculating the output classes for simpleclientserver sample. +# The following is a work around for the build command above. The unfortunate +# side effect of this work around results in a larger output. +example_jar =jdk_env.Jar(target='simpleclientserver.jar', + source=['classes','MANIFEST.MF'], + JARCHDIR='$SOURCE') +jdk_env.Install("../..", example_jar) \ No newline at end of file diff --git a/java/examples-java/simpleclientserver/build.gradle b/java/examples-java/simpleclientserver/build.gradle deleted file mode 100644 index e69de29..0000000 diff --git a/java/examples-java/simpleserver/.gitignore b/java/examples-java/simpleserver/.gitignore deleted file mode 100644 index 3543521..0000000 --- a/java/examples-java/simpleserver/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/java/examples-java/simpleserver/MANIFEST.MF b/java/examples-java/simpleserver/MANIFEST.MF new file mode 100644 index 0000000..c15f00f --- /dev/null +++ b/java/examples-java/simpleserver/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: iotivity.jar +Main-Class: org.iotivity.base.examples.SimpleServer diff --git a/java/examples-java/simpleserver/SConscript b/java/examples-java/simpleserver/SConscript new file mode 100644 index 0000000..05a307f --- /dev/null +++ b/java/examples-java/simpleserver/SConscript @@ -0,0 +1,34 @@ +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Copyright 2017 Intel Corporation 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('jdk_env') + +# Build simplerserver sample +simpleserver_classes = jdk_env.Java(target='classes', + source=['src/main/java']) +# jdk_env.Jar(target='simpleserver.jar', +# source=[simpleserver_classes, 'MANIFEST.MF']) +# SCons is incorrectly calculating the output classes for simpleserver sample. +# The following is a work around for the build command above. The unfortunate +# side effect of this work around results in a larger output. +example_jar = jdk_env.Jar(target='simpleserver.jar', + source=['classes', 'MANIFEST.MF'], + JARCHDIR='$SOURCE') +jdk_env.Install("../..", example_jar) \ No newline at end of file diff --git a/java/examples-java/simpleserver/build.gradle b/java/examples-java/simpleserver/build.gradle deleted file mode 100644 index 8b13789..0000000 --- a/java/examples-java/simpleserver/build.gradle +++ /dev/null @@ -1 +0,0 @@ - diff --git a/java/iotivity-java/build.gradle b/java/iotivity-java/build.gradle deleted file mode 100755 index 1d8acbb..0000000 --- a/java/iotivity-java/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -/* - * //****************************************************************** - * // - * // Copyright 2015 Intel Corporation. - * // - * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - * // - * // 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: 'java' - -sourceSets { - main { - java { - srcDirs 'src/main/java', '../common/src/main/java' - } - } -} - - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) -} diff --git a/java/iotivity-java/settings.gradle b/java/iotivity-java/settings.gradle deleted file mode 100644 index 2fd480c..0000000 --- a/java/iotivity-java/settings.gradle +++ /dev/null @@ -1,23 +0,0 @@ -/* - ******************************************************************* - * - * Copyright 2017 Intel Corporation. - * - *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - * - * 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. - * - *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - */ - - rootProject.name='iotivity' \ No newline at end of file -- 2.7.4