diff --git a/.travis.yml b/.travis.yml index b22460a..d242862 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,25 @@ -language: android - -jdk: - - oraclejdk8 - -android: - components: - - platform-tools - - tools - - build-tools-23.0.2 - - android-22 - - extra-android-m2repository - - extra-google-m2repository - licenses: - - android-sdk-license-.+ - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - -script: ./gradlew assembleRelease +language: android + +jdk: + - oraclejdk8 + +android: + components: + - platform-tools + - tools + - build-tools-23.0.2 + - android-22 + - extra-android-m2repository + - extra-google-m2repository + licenses: + - android-sdk-license-.+ + +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + +script: ./gradlew assembleRelease diff --git a/AUTHORS.txt b/AUTHORS.txt index 78de431..0a99258 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -1,7 +1,7 @@ -======================================================================= -N: Grigori Fursin -E: Grigori.Fursin@cTuning.org -H: http://fursin.net -O: cTuning foundation / dividiti -C: original concept and design -W: since 1 November 2014 +======================================================================= +N: Grigori Fursin +E: Grigori.Fursin@cTuning.org +H: http://fursin.net +O: cTuning foundation / dividiti +C: original concept and design +W: since 1 November 2014 diff --git a/CONTRIBUTIONS.txt b/CONTRIBUTIONS.txt index 5ddb2a7..e789999 100644 --- a/CONTRIBUTIONS.txt +++ b/CONTRIBUTIONS.txt @@ -1,59 +1,59 @@ -CK uses standard 3-clause (new) BSD license. Contributions are welcome to -either improve existing functionality or add new functionality possibly using -new modules. - -Contributors should clearly mark their contributions including date and remark. - -You can easily contribute to CK and all related repositories by forking them -on GitHub and then submitting a pull request. Alternatively, you can submit -patches via collective-knowledge@googlegroups.com . - -CK bugs can be reported here: -* https://github.com/ctuning/ck/issues - -Bugs related to shared repositories (predictive analytics, reproducible -experimentation, autotuning, etc) should be reported via their corresponding -GitHub pages. For example, you can report bugs about autotuning here: -* https://github.com/ctuning/ck-autotuning/issues - -Thank you for all your help to support this community project! - -================================================================================= -Acknowledgments: - -N: Grigori Fursin (alias: FGG) -E: Grigori.Fursin@cTuning.org -H: http://fursin.net -O: cTuning foundation, France -C: original concept and design -W: since Nov.1, 2014 - -N: Michel Steuwer -E: -O: University of Edinburgh, UK -C: feedback about documentation -W: - -N: Michael Haidl -E: -H: -O: -C: helping test ARM64-based mobile phone to crowdsource optimizations - -N: Toomas Remmelg -E: -H: -O: University of Edinburgh, UK -C: helping test ARM64-based Android mobile devices (flags and OpenCL) - -N: Daniil Efremov -E: -O: Xored, Russia -C: testing and improvements (see another version for DNN crowd-benchmarking) -W: - -N: Dmitry Savenko -E: -O: Xored, Russia -C: added continuous integration -W: +CK uses standard 3-clause (new) BSD license. Contributions are welcome to +either improve existing functionality or add new functionality possibly using +new modules. + +Contributors should clearly mark their contributions including date and remark. + +You can easily contribute to CK and all related repositories by forking them +on GitHub and then submitting a pull request. Alternatively, you can submit +patches via collective-knowledge@googlegroups.com . + +CK bugs can be reported here: +* https://github.com/ctuning/ck/issues + +Bugs related to shared repositories (predictive analytics, reproducible +experimentation, autotuning, etc) should be reported via their corresponding +GitHub pages. For example, you can report bugs about autotuning here: +* https://github.com/ctuning/ck-autotuning/issues + +Thank you for all your help to support this community project! + +================================================================================= +Acknowledgments: + +N: Grigori Fursin (alias: FGG) +E: Grigori.Fursin@cTuning.org +H: http://fursin.net +O: cTuning foundation, France +C: original concept and design +W: since Nov.1, 2014 + +N: Michel Steuwer +E: +O: University of Edinburgh, UK +C: feedback about documentation +W: + +N: Michael Haidl +E: +H: +O: +C: helping test ARM64-based mobile phone to crowdsource optimizations + +N: Toomas Remmelg +E: +H: +O: University of Edinburgh, UK +C: helping test ARM64-based Android mobile devices (flags and OpenCL) + +N: Daniil Efremov +E: +O: Xored, Russia +C: testing and improvements (see another version for DNN crowd-benchmarking) +W: + +N: Dmitry Savenko +E: +O: Xored, Russia +C: added continuous integration +W: diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 2f9cb02..6026b30 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -1 +1 @@ -(C)opyright 2014-2016 Grigori Fursin +(C)opyright 2014-2016 Grigori Fursin diff --git a/LICENSE.txt b/LICENSE.txt index a13f999..de4a502 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,28 +1,28 @@ -Copyright 2014-2016 Grigori Fursin, cTuning foundation and volunteers -All rights reserved - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Grigori Fursin and CTUNING FOUNDATION - nor the names of its contributors may be used to endorse - or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright 2014-2016 Grigori Fursin, cTuning foundation and volunteers +All rights reserved + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Grigori Fursin and CTUNING FOUNDATION + nor the names of its contributors may be used to endorse + or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/NOTES.txt b/NOTES.txt index 7ac0bc5..52be89f 100644 --- a/NOTES.txt +++ b/NOTES.txt @@ -1,7 +1,7 @@ -Change version in app/build.gradle - -When trying OpenCL may need the following info: - search for a given lib in sys.path - - String[] envp = {"LD_LIBRARY_PATH=/data/data/cse.ecg.dcmtk/lib:$LD_LIBRARY_PATH"}; - Runtime.getRuntime().exec(myCommand, envp); +Change version in app/build.gradle + +When trying OpenCL may need the following info: + search for a given lib in sys.path + + String[] envp = {"LD_LIBRARY_PATH=/data/data/cse.ecg.dcmtk/lib:$LD_LIBRARY_PATH"}; + Runtime.getRuntime().exec(myCommand, envp); diff --git a/README.md b/README.md index bc711f7..7af60d8 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,77 @@ -[![Build Status](https://travis-ci.org/ctuning/crowdsource-experiments-using-android-devices.svg?branch=master)](https://travis-ci.org/ctuning/crowdsource-experiments-using-android-devices) - -NEWS -==== -* Upcoming CK presentation at [ARM TechCon'16 (Oct. 27)](http://schedule.armtechcon.com/session/know-your-workloads-design-more-efficient-systems); -* ARM uses CK as a front-end for systematic and reproducible benchmarking and tuning of real workloads: [link](https://github.com/ctuning/ck-wa); -* Open challenges in computer engineering have been updated: [link](https://github.com/ctuning/ck/wiki/Research-and-development-challenges); -* General Motors and dividiti shared CK workflow to crowdsource benchmarking and optimization of CAFFE (DNN framework) [here](https://github.com/dividiti/ck-caffe); -* We have moved related Open Science resources [here](http://github.com/ctuning/ck/wiki/Enabling-Open-Science); - -Introduction -============ - -This [CK-powered](http://github.com/ctuning/ck) open-source Android application -lets the community participate in experiment crowdsourcing using their -mobile devices (mobile phones, tablets, IoT, etc) -and exchange knowledge via public CK servers. - -You can download this app from the [Google Play Store](https://play.google.com/store/apps/details?id=openscience.crowdsource.experiments). - -You can also find public results at [Live CK repo](http://cknowledge.org/repo)! - -Current scenarios include multi-dimensional and multi-objective -optimization of benchmarks and real workloads such as -GCC and LLVM multi-objective crowd-tuning (performance / code size / bugs). - -More information is available [here](http://cKnowledge.org/repo). - -License -======= -* Permissive 3-clause BSD license. (See `LICENSE.txt` for more details). - -Minimal requirements -==================== -Android 2.2+ - -Authors -======= -* Grigori Fursin, http://fursin.net/research - -Questions/comments/discussions? -=============================== -Please subscribe to our mailing lists: -* Open, collaborative and reproducible R&D including knowledge preservation, sharing and reuse: - http://groups.google.com/group/collective-knowledge -* Software and hardware multi-objective (performance/energy/accuracy/size/reliability/cost) - benchmarking, autotuning, crowdtuning and run-time adaptation: http://groups.google.com/group/ctuning-discussions - -Publications -============ -The concepts have been described in the following publications: - -* http://arxiv.org/abs/1506.06256 (CPC'15) -* http://bit.ly/ck-date16 (DATE'16) -* http://hal.inria.fr/hal-01054763 (Journal of Scientific Programming'14) -* https://hal.inria.fr/inria-00436029 (GCC Summit'09) - -If you found this app useful for your R&D, you are welcome -to reference any of the above publications in your articles -and reports. You can download all above references in one -BibTex file [here](https://raw.githubusercontent.com/ctuning/ck-guide-images/master/collective-knowledge-refs.bib). - -Testimonials and awards -======================= -* 2014: HiPEAC technology transfer award: [HiPEAC TT winners](https://www.hipeac.net/research/technology-transfer-awards/2014) -* 2015: ARM and the cTuning foundation use CK to accelerate computer engineering: [HiPEAC Info'45 page 17](https://www.hipeac.net/assets/public/publications/newsletter/hipeacinfo45.pdf), [ARM TechCon'16 presentation and demo](http://schedule.armtechcon.com/session/know-your-workloads-design-more-efficient-systems), [public CK repo](https://github.com/ctuning/ck-wa) - -Acknowledgments -=============== - -CK development is coordinated by the [cTuning -foundation](http://cTuning.org) (non-profit research organization) -and [dividiti](http://dividiti.com). -We are also extremely grateful to all -volunteers for their valuable feedback and contributions. - -![logo](https://github.com/ctuning/ck-guide-images/blob/master/logo-validated-by-the-community-simple.png) +[![Build Status](https://travis-ci.org/ctuning/crowdsource-experiments-using-android-devices.svg?branch=master)](https://travis-ci.org/ctuning/crowdsource-experiments-using-android-devices) + +NEWS +==== +* Upcoming CK presentation at [ARM TechCon'16 (Oct. 27)](http://schedule.armtechcon.com/session/know-your-workloads-design-more-efficient-systems); +* ARM uses CK as a front-end for systematic and reproducible benchmarking and tuning of real workloads: [link](https://github.com/ctuning/ck-wa); +* Open challenges in computer engineering have been updated: [link](https://github.com/ctuning/ck/wiki/Research-and-development-challenges); +* General Motors and dividiti shared CK workflow to crowdsource benchmarking and optimization of CAFFE (DNN framework) [here](https://github.com/dividiti/ck-caffe); +* We have moved related Open Science resources [here](http://github.com/ctuning/ck/wiki/Enabling-Open-Science); + +Introduction +============ + +This [CK-powered](http://github.com/ctuning/ck) open-source Android application +lets the community participate in experiment crowdsourcing using their +mobile devices (mobile phones, tablets, IoT, etc) +and exchange knowledge via public CK servers. + +You can download this app from the [Google Play Store](https://play.google.com/store/apps/details?id=openscience.crowdsource.experiments). + +You can also find public results at [Live CK repo](http://cknowledge.org/repo)! + +Current scenarios include multi-dimensional and multi-objective +optimization of benchmarks and real workloads such as +GCC and LLVM multi-objective crowd-tuning (performance / code size / bugs). + +More information is available [here](http://cKnowledge.org/repo). + +License +======= +* Permissive 3-clause BSD license. (See `LICENSE.txt` for more details). + +Minimal requirements +==================== +Android 2.2+ + +Authors +======= +* Grigori Fursin, http://fursin.net/research + +Questions/comments/discussions? +=============================== +Please subscribe to our mailing lists: +* Open, collaborative and reproducible R&D including knowledge preservation, sharing and reuse: + http://groups.google.com/group/collective-knowledge +* Software and hardware multi-objective (performance/energy/accuracy/size/reliability/cost) + benchmarking, autotuning, crowdtuning and run-time adaptation: http://groups.google.com/group/ctuning-discussions + +Publications +============ +The concepts have been described in the following publications: + +* http://arxiv.org/abs/1506.06256 (CPC'15) +* http://bit.ly/ck-date16 (DATE'16) +* http://hal.inria.fr/hal-01054763 (Journal of Scientific Programming'14) +* https://hal.inria.fr/inria-00436029 (GCC Summit'09) + +If you found this app useful for your R&D, you are welcome +to reference any of the above publications in your articles +and reports. You can download all above references in one +BibTex file [here](https://raw.githubusercontent.com/ctuning/ck-guide-images/master/collective-knowledge-refs.bib). + +Testimonials and awards +======================= +* 2014: HiPEAC technology transfer award: [HiPEAC TT winners](https://www.hipeac.net/research/technology-transfer-awards/2014) +* 2015: ARM and the cTuning foundation use CK to accelerate computer engineering: [HiPEAC Info'45 page 17](https://www.hipeac.net/assets/public/publications/newsletter/hipeacinfo45.pdf), [ARM TechCon'16 presentation and demo](http://schedule.armtechcon.com/session/know-your-workloads-design-more-efficient-systems), [public CK repo](https://github.com/ctuning/ck-wa) + +Acknowledgments +=============== + +CK development is coordinated by the [cTuning +foundation](http://cTuning.org) (non-profit research organization) +and [dividiti](http://dividiti.com). +We are also extremely grateful to all +volunteers for their valuable feedback and contributions. + +![logo](https://github.com/ctuning/ck-guide-images/blob/master/logo-validated-by-the-community-simple.png) diff --git a/app/build.gradle b/app/build.gradle index cf1603d..92b09f0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 22 - buildToolsVersion "23.0.2" + compileSdkVersion 27 + buildToolsVersion "27.0.3" defaultConfig { applicationId "openscience.crowdsource.experiments" minSdkVersion 10 - targetSdkVersion 22 - versionCode 11 - versionName "2.4" + targetSdkVersion 26 + versionCode 12 + versionName "2.5" } buildTypes { release { diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..bd2a872 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output.json b/app/release/output.json new file mode 100644 index 0000000..f5cddcf --- /dev/null +++ b/app/release/output.json @@ -0,0 +1 @@ +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":12,"versionName":"2.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/org/ctuning/openme/openme.java b/app/src/main/java/org/ctuning/openme/openme.java index 1e98127..413e931 100644 --- a/app/src/main/java/org/ctuning/openme/openme.java +++ b/app/src/main/java/org/ctuning/openme/openme.java @@ -1,693 +1,693 @@ -/* - -# OpenME interface for Java -# -# See LICENSE.txt for licensing details. -# See Copyright.txt for copyright details. -# -# Developer: Grigori Fursin - -*/ - -package org.ctuning.openme; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.UUID; - -//Main class -public class openme -{ - // ******************************************************************* - public static JSONObject openme_store_json_file(JSONObject i, String file_name) throws JSONException { - /* - Store json object in file - - Input: i - cJSON object - file_name - name of the file to store json object - - Output: { - return - return code = 0, if successful - (error) - error text if return code > 0 - } - */ - - JSONObject r=new JSONObject(); - BufferedWriter fp=null; - - try - { - fp=new BufferedWriter(new FileWriter(file_name)); - } - catch (IOException ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't open json file for writing ("+ex.getMessage()+") ..."); - return r; - } - - try - { - StringWriter out = new StringWriter(); - fp.write(i.toString()); - fp.newLine(); - } - catch (Exception ex) - { - try - { - fp.close(); - } - catch (Exception ex1) - { - r.put("return", new Integer(1)); - r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); - return r; - } - - r.put("return", new Integer(1)); - r.put("error", "can't write json file ("+ex.getMessage()+") ..."); - return r; - } - - try - { - fp.close(); - } - catch (Exception ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't close json file ("+ex.getMessage()+") ..."); - return r; - } - - r.put("return", new Integer(0)); - return r; - } - - // ******************************************************************* - public static String[] openme_run_program(String cmd, String[] env, String path) - { - /* - FGG: TBD - call local cM - - Input: cmd - command line to run - env - list of environment variables - path - directory where to start program - - Output: string list: - [0] - error text - [1] - stdout output - [2] - stderr output - */ - - File dir=null; - if (path!=null) dir=new File(path); //getCacheDir(); - - Process p=null; - String output=""; - String eoutput=""; - String err=""; - - try { - p=Runtime.getRuntime().exec(cmd,env,dir); - - BufferedReader reader=new BufferedReader( - new InputStreamReader(p.getInputStream())); - - BufferedReader stderr = new BufferedReader( - new InputStreamReader(p.getErrorStream())); - - - String line=null; - while ((line = reader.readLine())!=null) - output+=line+'\n'; - - while ((line = stderr.readLine())!=null) - eoutput+=line+'\n'; - - reader.close(); - stderr.close(); - p.waitFor(); - } catch(Exception e) { - err=e.toString(); - } - - if (p!=null) { - try { - p.getOutputStream().close(); - p.getInputStream().close(); - p.getErrorStream().close(); - } - catch (IOException e) { - err=e.toString(); - } - } - - return new String[] {err, output, eoutput}; - } - - // ******************************************************************* - public static JSONObject openme_load_json_file(String file_name) throws JSONException { - /* - Load json file and create cJSON object - - Input: file_name - name of the file to load - - Output: { - return - return code = 0, if successful - (error) - error text if return code > 0 - dict - cJSON object, if success - */ - - JSONObject r=new JSONObject(); - BufferedReader fp=null; - - try - { - fp=new BufferedReader(new FileReader(file_name)); - } - catch (IOException ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't open json file for writing ("+ex.getMessage()+") ..."); - return r; - } - - String output=""; - try - { - String line=null; - while ((line = fp.readLine())!=null) - output+=line+'\n'; - - fp.close(); - } - catch (Exception ex) - { - try - { - fp.close(); - } - catch (Exception ex1) - { - r.put("return", new Integer(1)); - r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); - return r; - } - - r.put("return", new Integer(1)); - r.put("error", "can't read json file ("+ex.getMessage()+") ..."); - return r; - } - - try - { - fp.close(); - } - catch (Exception ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't close json file ("+ex.getMessage()+") ..."); - return r; - } - - JSONObject a=new JSONObject(output); - - r.put("return", new Integer(0)); - r.put("dict", a); - - return r; - } - - // ******************************************************************* - public static JSONObject convert_array_to_uri(JSONObject i) throws JSONException { - /* - Convert cM dict to uri (convert various special parameters) - - Input: { - dict - dict to convert to uri - } - - Output: { - return - return code (check "access" function for full description) - (error) - error text (check "access" function for full description) - string - converted string - } - */ - - // Prepare return object - JSONObject r=new JSONObject(); - - if (!i.has("dict")) - { - r.put("return", new Integer(1)); - r.put("error", "'array' is not set in openme/convert_array_to_uri"); - return r; - } - JSONObject x=(JSONObject) i.get("dict"); - - String s=""; - String s1=""; - - s=x.toString(); - - try - { - s= URLEncoder.encode(s, "UTF-8"); - } - catch (Exception ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't encode string ("+ex.getMessage()+") ..."); - return r; - } - - r.put("return", new Integer(0)); - r.put("string", s); - - return r; - } - - - // ******************************************************************* - public static JSONObject remote_access(JSONObject i) throws JSONException { - /* - Input: { - remote_server_url - remote server URL - (module_uoa) - module to run - (action) - action to perform - if =='download', prepare entry/file download through Internet - - (save_to_file) - if web_action==download, - save output to this file - - (out) - if 'json', treat output as json - if 'json_after_text', strip everything before json - if 'txt', output to stdout - - ... - all other request parameters - - //FGG TBD - should add support for proxy - } - - Output: { - return - return code = 0 if successful - > 0 if error - < 0 if warning (rarely used at this moment) - (error) - error text, if return > 0 - (stdout) - if out='txt', output there - } - */ - - // Prepare return object - JSONObject r=new JSONObject(); - - URL u; - HttpURLConnection c=null; - - // Prepare request - String x=""; - String post=""; - - String con=""; - - x=""; - if (i.has("out")) x=(String) i.get("out"); - if (x!=null && x!="") - con=x; - - String url=""; - if (i.has("remote_server_url")) - { - url=(String) i.get("remote_server_url"); - i.remove("remote_server_url"); - } - if (url==null || url=="") - { - r.put("return", new Integer(1)); - r.put("error", "'remote_server_url is not defined"); - return r; - } - - String save_to_file=""; - if (i.has("save_to_file")) - { - save_to_file=(String) i.get("save_to_file"); - i.remove("save_to_file"); - } - - // Check if data download, not json and convert it to download request - boolean download=false; - - x=""; - if (i.has("action")) - { - x=(String) i.get("action"); - } - if (x=="download" || x=="show") - { - download=true; - if (post!="") post+="&"; - post+="module_uoa=web&action="+x; - - if (i.has("module_uoa")) i.remove("module_uoa"); - if (i.has("out")) i.remove("out"); - i.remove("action"); - } - - // Prepare dict to transfer through Internet - JSONObject ii=new JSONObject(); - ii.put("dict", i); - JSONObject rx=convert_array_to_uri(ii); - if ((Integer)rx.get("return")>0) return rx; - - if (post!="") post+="&"; - post+="ck_json="+((String) rx.get("string")); - - // Prepare URL request - String s=""; - try - { - u=new URL(url); - c=(HttpURLConnection) u.openConnection(); - - c.setRequestMethod("POST"); - c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - c.setRequestProperty("Content-Length", Integer.toString(post.getBytes().length)); - c.setUseCaches(false); - c.setDoInput(true); - c.setDoOutput(true); - - //Send request - DataOutputStream dos=new DataOutputStream(c.getOutputStream()); - dos.writeBytes(post); - dos.flush(); - dos.close(); - } - catch (IOException e) - { - if (c!=null) c.disconnect(); - r.put("return", new Integer(1)); - r.put("error", "Failed sending request to remote server ("+e.getMessage()+") ..."); - return r; - } - - r.put("return", new Integer(0)); - - // Check if download, not json! - if (download) - { - String name="default_download_name.dat"; - - x=""; - if (i.has("filename")) { - x = ((String) i.get("filename")); - } - if (x!=null && x!="") - { - File xf = new File(x); - name=xf.getName(); - } - - if (save_to_file!=null && save_to_file!="") name=save_to_file; - - //Reading response in binary and at the same time saving to file - try - { - //Read response - DataInputStream dis=new DataInputStream(c.getInputStream()); - DataOutputStream dos=new DataOutputStream(new FileOutputStream(name)); - - byte[] buf=new byte[16384]; - - int len; - - while((len=dis.read(buf))!=-1) - dos.write(buf,0,len); - - dos.close(); - dis.close(); - } - catch (Exception e) - { - if (c!=null) c.disconnect(); - - r.put("return", new Integer(1)); - r.put("error", "Failed reading stream from remote server or writing to file ("+e.getMessage()+") ..."); - return r; - } - } - else - { - //Reading response in text - try - { - //Read response - InputStream is=c.getInputStream(); - BufferedReader f=new BufferedReader(new InputStreamReader(is)); - StringBuffer ss=new StringBuffer(); - - while((x=f.readLine())!=null) - { - ss.append(x); - ss.append('\r'); - } - - f.close(); - s=ss.toString(); - } - catch (Exception e) - { - if (c!=null) c.disconnect(); - - r.put("return", new Integer(1)); - r.put("error", "Failed reading stream from remote server ("+e.getMessage()+") ..."); - return r; - } - - if (con=="json_after_text") - { - String json_sep="*** ### --- CM JSON SEPARATOR --- ### ***"; - int li=s.lastIndexOf(json_sep); - if (li>=0) - { - s=s.substring(li+json_sep.length()); - s=s.trim(); - } - } - - if (con=="json_after_text" || con=="json") - r=new JSONObject(s); - else - r.put("stdout", s); - } - - if (c!=null) c.disconnect(); - - return r; - } - - // ******************************************************************* - public static JSONObject access(JSONObject i) throws JSONException { - /* - FGG: TBD - call local cM - - Input: i input json object - - Output: { - return - return code = 0, if successful - (error) - error text if return code > 0 - ... - } - */ - File f=null; - String fn1, fn2, fn3; - - JSONObject r=new JSONObject(); - - /* Get module name */ - String rm=""; - if (i.has("module_uoa")) rm=(String) i.get("module_uoa"); - if (rm==null || rm=="") - { - r.put("return", new Integer(1)); - r.put("error", "can't find module_uoa in action ..."); - return r; - } - - /* Generate tmp files with json and for output*/ - /* First file will be deleted automatically by cM */ - try - { - f=File.createTempFile("ck-", "-ck.tmp", null); - fn1=f.getAbsolutePath(); - - f=File.createTempFile("ck-", "-ck.tmp", null); - fn2=f.getAbsolutePath(); - - f=File.createTempFile("ck-", "-ck.tmp", null); - fn3=f.getAbsolutePath(); - } - catch (IOException ex) - { - r.put("return", new Integer(1)); - r.put("error", "can't gerenate temp files ("+ex.getMessage()+") ..."); - return r; - } - - /* Record input file */ - JSONObject rx=openme_store_json_file(i, fn1); - Integer rr=0; - if (!rx.has("return") || (Integer)rx.get("return")>0) return rx; - - /* Prepare command line */ - String cmd="cmd /c cm "+rm+" @"+fn1+" > "+fn2+" 2> "+fn3; - - String[] x=openme_run_program(cmd, null, null); - - r.put("stderr",x[0]); - r.put("stdout",x[1]); - - r=openme_load_json_file(fn2); - if (!r.has("return") || (Integer)r.get("return")>0) - { - r.put("return", new Integer(1)); - r.put("error", "output in files (STDERR file="+fn3+"; STDOUT file="+fn2+")"); - return r; - } - - /* Remove tmp files */ - f = new File(fn2); - f.delete(); - - f = new File(fn3); - f.delete(); - - return r; - } - - // ******************************************************************* - public static JSONObject read_text_file_and_convert_to_json(String file_name, String sep, boolean value_to_lower, boolean aggregate_similar) throws JSONException - { - JSONObject r=new JSONObject(); - JSONObject a=new JSONObject(); - - BufferedReader fp=null; - - try - { - fp=new BufferedReader(new FileReader(file_name)); - } - catch (IOException ex) - { - r.put("return", new Long(16)); - r.put("error", "can't open file for reading ("+ex.getMessage()+") ..."); - return r; - } - - String output=""; - try - { - String line=null; - while ((line = fp.readLine())!=null) - { - if (sep!=null && sep!="") - { - int i=line.indexOf(sep); - if (i>0) - { -// String key=line.substring(0,i).trim().toLowerCase().replace(' ', '_'); - String key=line.substring(0,i).trim(); //.replace(' ', '_'); - String value=line.substring(i+1,line.length()).trim(); - if (value_to_lower) value=value.toLowerCase(); - - if (a.has(key) && aggregate_similar) { - Object vv=a.get(key); - if (vv instanceof JSONArray) { - JSONArray vvv=(JSONArray) a.get(key); - vvv.put(value); - a.put(key, vvv); - } - else { - JSONArray vvv=new JSONArray(); - vvv.put((String) vv); - vvv.put(value); - a.put(key, vvv); - } - } - else a.put(key, value); - } - } - - output+=line+'\n'; - } - - fp.close(); - } - catch (Exception ex) - { - try - { - fp.close(); - } - catch (Exception ex1) - { - r.put("return", new Long(1)); - r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); - return r; - } - - r.put("return", new Long(1)); - r.put("error", "can't read json file ("+ex.getMessage()+") ..."); - return r; - } - - try - { - fp.close(); - } - catch (Exception ex) - { - r.put("return", new Long(1)); - r.put("error", "can't close json file ("+ex.getMessage()+") ..."); - return r; - } - - r.put("return", new Long(0)); - r.put("dict", a); - r.put("file_as_string", output); - - return r; - } - - // ******************************************************************* - public static String gen_uid() - { - UUID uuid = UUID.randomUUID(); - String s=String.valueOf(uuid); - - s=s.replace("-",""); - - s=s.substring(0,16); - - return s; - } -} +/* + +# OpenME interface for Java +# +# See LICENSE.txt for licensing details. +# See Copyright.txt for copyright details. +# +# Developer: Grigori Fursin + +*/ + +package org.ctuning.openme; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.util.UUID; + +//Main class +public class openme +{ + // ******************************************************************* + public static JSONObject openme_store_json_file(JSONObject i, String file_name) throws JSONException { + /* + Store json object in file + + Input: i - cJSON object + file_name - name of the file to store json object + + Output: { + return - return code = 0, if successful + (error) - error text if return code > 0 + } + */ + + JSONObject r=new JSONObject(); + BufferedWriter fp=null; + + try + { + fp=new BufferedWriter(new FileWriter(file_name)); + } + catch (IOException ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't open json file for writing ("+ex.getMessage()+") ..."); + return r; + } + + try + { + StringWriter out = new StringWriter(); + fp.write(i.toString()); + fp.newLine(); + } + catch (Exception ex) + { + try + { + fp.close(); + } + catch (Exception ex1) + { + r.put("return", new Integer(1)); + r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); + return r; + } + + r.put("return", new Integer(1)); + r.put("error", "can't write json file ("+ex.getMessage()+") ..."); + return r; + } + + try + { + fp.close(); + } + catch (Exception ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't close json file ("+ex.getMessage()+") ..."); + return r; + } + + r.put("return", new Integer(0)); + return r; + } + + // ******************************************************************* + public static String[] openme_run_program(String cmd, String[] env, String path) + { + /* + FGG: TBD - call local cM + + Input: cmd - command line to run + env - list of environment variables + path - directory where to start program + + Output: string list: + [0] - error text + [1] - stdout output + [2] - stderr output + */ + + File dir=null; + if (path!=null) dir=new File(path); //getCacheDir(); + + Process p=null; + String output=""; + String eoutput=""; + String err=""; + + try { + p=Runtime.getRuntime().exec(cmd,env,dir); + + BufferedReader reader=new BufferedReader( + new InputStreamReader(p.getInputStream())); + + BufferedReader stderr = new BufferedReader( + new InputStreamReader(p.getErrorStream())); + + + String line=null; + while ((line = reader.readLine())!=null) + output+=line+'\n'; + + while ((line = stderr.readLine())!=null) + eoutput+=line+'\n'; + + reader.close(); + stderr.close(); + p.waitFor(); + } catch(Exception e) { + err=e.toString(); + } + + if (p!=null) { + try { + p.getOutputStream().close(); + p.getInputStream().close(); + p.getErrorStream().close(); + } + catch (IOException e) { + err=e.toString(); + } + } + + return new String[] {err, output, eoutput}; + } + + // ******************************************************************* + public static JSONObject openme_load_json_file(String file_name) throws JSONException { + /* + Load json file and create cJSON object + + Input: file_name - name of the file to load + + Output: { + return - return code = 0, if successful + (error) - error text if return code > 0 + dict - cJSON object, if success + */ + + JSONObject r=new JSONObject(); + BufferedReader fp=null; + + try + { + fp=new BufferedReader(new FileReader(file_name)); + } + catch (IOException ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't open json file for writing ("+ex.getMessage()+") ..."); + return r; + } + + String output=""; + try + { + String line=null; + while ((line = fp.readLine())!=null) + output+=line+'\n'; + + fp.close(); + } + catch (Exception ex) + { + try + { + fp.close(); + } + catch (Exception ex1) + { + r.put("return", new Integer(1)); + r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); + return r; + } + + r.put("return", new Integer(1)); + r.put("error", "can't read json file ("+ex.getMessage()+") ..."); + return r; + } + + try + { + fp.close(); + } + catch (Exception ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't close json file ("+ex.getMessage()+") ..."); + return r; + } + + JSONObject a=new JSONObject(output); + + r.put("return", new Integer(0)); + r.put("dict", a); + + return r; + } + + // ******************************************************************* + public static JSONObject convert_array_to_uri(JSONObject i) throws JSONException { + /* + Convert cM dict to uri (convert various special parameters) + + Input: { + dict - dict to convert to uri + } + + Output: { + return - return code (check "access" function for full description) + (error) - error text (check "access" function for full description) + string - converted string + } + */ + + // Prepare return object + JSONObject r=new JSONObject(); + + if (!i.has("dict")) + { + r.put("return", new Integer(1)); + r.put("error", "'array' is not set in openme/convert_array_to_uri"); + return r; + } + JSONObject x=(JSONObject) i.get("dict"); + + String s=""; + String s1=""; + + s=x.toString(); + + try + { + s= URLEncoder.encode(s, "UTF-8"); + } + catch (Exception ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't encode string ("+ex.getMessage()+") ..."); + return r; + } + + r.put("return", new Integer(0)); + r.put("string", s); + + return r; + } + + + // ******************************************************************* + public static JSONObject remote_access(JSONObject i) throws JSONException { + /* + Input: { + remote_server_url - remote server URL + (module_uoa) - module to run + (action) - action to perform + if =='download', prepare entry/file download through Internet + + (save_to_file) - if web_action==download, + save output to this file + + (out) - if 'json', treat output as json + if 'json_after_text', strip everything before json + if 'txt', output to stdout + + ... - all other request parameters + + //FGG TBD - should add support for proxy + } + + Output: { + return - return code = 0 if successful + > 0 if error + < 0 if warning (rarely used at this moment) + (error) - error text, if return > 0 + (stdout) - if out='txt', output there + } + */ + + // Prepare return object + JSONObject r=new JSONObject(); + + URL u; + HttpURLConnection c=null; + + // Prepare request + String x=""; + String post=""; + + String con=""; + + x=""; + if (i.has("out")) x=(String) i.get("out"); + if (x!=null && x!="") + con=x; + + String url=""; + if (i.has("remote_server_url")) + { + url=(String) i.get("remote_server_url"); + i.remove("remote_server_url"); + } + if (url==null || url=="") + { + r.put("return", new Integer(1)); + r.put("error", "'remote_server_url is not defined"); + return r; + } + + String save_to_file=""; + if (i.has("save_to_file")) + { + save_to_file=(String) i.get("save_to_file"); + i.remove("save_to_file"); + } + + // Check if data download, not json and convert it to download request + boolean download=false; + + x=""; + if (i.has("action")) + { + x=(String) i.get("action"); + } + if (x=="download" || x=="show") + { + download=true; + if (post!="") post+="&"; + post+="module_uoa=web&action="+x; + + if (i.has("module_uoa")) i.remove("module_uoa"); + if (i.has("out")) i.remove("out"); + i.remove("action"); + } + + // Prepare dict to transfer through Internet + JSONObject ii=new JSONObject(); + ii.put("dict", i); + JSONObject rx=convert_array_to_uri(ii); + if ((Integer)rx.get("return")>0) return rx; + + if (post!="") post+="&"; + post+="ck_json="+((String) rx.get("string")); + + // Prepare URL request + String s=""; + try + { + u=new URL(url); + c=(HttpURLConnection) u.openConnection(); + + c.setRequestMethod("POST"); + c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + c.setRequestProperty("Content-Length", Integer.toString(post.getBytes().length)); + c.setUseCaches(false); + c.setDoInput(true); + c.setDoOutput(true); + + //Send request + DataOutputStream dos=new DataOutputStream(c.getOutputStream()); + dos.writeBytes(post); + dos.flush(); + dos.close(); + } + catch (IOException e) + { + if (c!=null) c.disconnect(); + r.put("return", new Integer(1)); + r.put("error", "Failed sending request to remote server ("+e.getMessage()+") ..."); + return r; + } + + r.put("return", new Integer(0)); + + // Check if download, not json! + if (download) + { + String name="default_download_name.dat"; + + x=""; + if (i.has("filename")) { + x = ((String) i.get("filename")); + } + if (x!=null && x!="") + { + File xf = new File(x); + name=xf.getName(); + } + + if (save_to_file!=null && save_to_file!="") name=save_to_file; + + //Reading response in binary and at the same time saving to file + try + { + //Read response + DataInputStream dis=new DataInputStream(c.getInputStream()); + DataOutputStream dos=new DataOutputStream(new FileOutputStream(name)); + + byte[] buf=new byte[16384]; + + int len; + + while((len=dis.read(buf))!=-1) + dos.write(buf,0,len); + + dos.close(); + dis.close(); + } + catch (Exception e) + { + if (c!=null) c.disconnect(); + + r.put("return", new Integer(1)); + r.put("error", "Failed reading stream from remote server or writing to file ("+e.getMessage()+") ..."); + return r; + } + } + else + { + //Reading response in text + try + { + //Read response + InputStream is=c.getInputStream(); + BufferedReader f=new BufferedReader(new InputStreamReader(is)); + StringBuffer ss=new StringBuffer(); + + while((x=f.readLine())!=null) + { + ss.append(x); + ss.append('\r'); + } + + f.close(); + s=ss.toString(); + } + catch (Exception e) + { + if (c!=null) c.disconnect(); + + r.put("return", new Integer(1)); + r.put("error", "Failed reading stream from remote server ("+e.getMessage()+") ..."); + return r; + } + + if (con=="json_after_text") + { + String json_sep="*** ### --- CM JSON SEPARATOR --- ### ***"; + int li=s.lastIndexOf(json_sep); + if (li>=0) + { + s=s.substring(li+json_sep.length()); + s=s.trim(); + } + } + + if (con=="json_after_text" || con=="json") + r=new JSONObject(s); + else + r.put("stdout", s); + } + + if (c!=null) c.disconnect(); + + return r; + } + + // ******************************************************************* + public static JSONObject access(JSONObject i) throws JSONException { + /* + FGG: TBD - call local cM + + Input: i input json object + + Output: { + return - return code = 0, if successful + (error) - error text if return code > 0 + ... + } + */ + File f=null; + String fn1, fn2, fn3; + + JSONObject r=new JSONObject(); + + /* Get module name */ + String rm=""; + if (i.has("module_uoa")) rm=(String) i.get("module_uoa"); + if (rm==null || rm=="") + { + r.put("return", new Integer(1)); + r.put("error", "can't find module_uoa in action ..."); + return r; + } + + /* Generate tmp files with json and for output*/ + /* First file will be deleted automatically by cM */ + try + { + f=File.createTempFile("ck-", "-ck.tmp", null); + fn1=f.getAbsolutePath(); + + f=File.createTempFile("ck-", "-ck.tmp", null); + fn2=f.getAbsolutePath(); + + f=File.createTempFile("ck-", "-ck.tmp", null); + fn3=f.getAbsolutePath(); + } + catch (IOException ex) + { + r.put("return", new Integer(1)); + r.put("error", "can't gerenate temp files ("+ex.getMessage()+") ..."); + return r; + } + + /* Record input file */ + JSONObject rx=openme_store_json_file(i, fn1); + Integer rr=0; + if (!rx.has("return") || (Integer)rx.get("return")>0) return rx; + + /* Prepare command line */ + String cmd="cmd /c cm "+rm+" @"+fn1+" > "+fn2+" 2> "+fn3; + + String[] x=openme_run_program(cmd, null, null); + + r.put("stderr",x[0]); + r.put("stdout",x[1]); + + r=openme_load_json_file(fn2); + if (!r.has("return") || (Integer)r.get("return")>0) + { + r.put("return", new Integer(1)); + r.put("error", "output in files (STDERR file="+fn3+"; STDOUT file="+fn2+")"); + return r; + } + + /* Remove tmp files */ + f = new File(fn2); + f.delete(); + + f = new File(fn3); + f.delete(); + + return r; + } + + // ******************************************************************* + public static JSONObject read_text_file_and_convert_to_json(String file_name, String sep, boolean value_to_lower, boolean aggregate_similar) throws JSONException + { + JSONObject r=new JSONObject(); + JSONObject a=new JSONObject(); + + BufferedReader fp=null; + + try + { + fp=new BufferedReader(new FileReader(file_name)); + } + catch (IOException ex) + { + r.put("return", new Long(16)); + r.put("error", "can't open file for reading ("+ex.getMessage()+") ..."); + return r; + } + + String output=""; + try + { + String line=null; + while ((line = fp.readLine())!=null) + { + if (sep!=null && sep!="") + { + int i=line.indexOf(sep); + if (i>0) + { +// String key=line.substring(0,i).trim().toLowerCase().replace(' ', '_'); + String key=line.substring(0,i).trim(); //.replace(' ', '_'); + String value=line.substring(i+1,line.length()).trim(); + if (value_to_lower) value=value.toLowerCase(); + + if (a.has(key) && aggregate_similar) { + Object vv=a.get(key); + if (vv instanceof JSONArray) { + JSONArray vvv=(JSONArray) a.get(key); + vvv.put(value); + a.put(key, vvv); + } + else { + JSONArray vvv=new JSONArray(); + vvv.put((String) vv); + vvv.put(value); + a.put(key, vvv); + } + } + else a.put(key, value); + } + } + + output+=line+'\n'; + } + + fp.close(); + } + catch (Exception ex) + { + try + { + fp.close(); + } + catch (Exception ex1) + { + r.put("return", new Long(1)); + r.put("error", "can't close json file ("+ex1.getMessage()+") ..."); + return r; + } + + r.put("return", new Long(1)); + r.put("error", "can't read json file ("+ex.getMessage()+") ..."); + return r; + } + + try + { + fp.close(); + } + catch (Exception ex) + { + r.put("return", new Long(1)); + r.put("error", "can't close json file ("+ex.getMessage()+") ..."); + return r; + } + + r.put("return", new Long(0)); + r.put("dict", a); + r.put("file_as_string", output); + + return r; + } + + // ******************************************************************* + public static String gen_uid() + { + UUID uuid = UUID.randomUUID(); + String s=String.valueOf(uuid); + + s=s.replace("-",""); + + s=s.substring(0,16); + + return s; + } +} diff --git a/build.gradle b/build.gradle index 2449eab..4d86fa2 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:3.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d6a5962..670d626 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Oct 21 16:18:39 CEST 2016 +#Fri Aug 03 21:47:52 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/gradlew b/gradlew index 9d82f78..e834973 100755 --- a/gradlew +++ b/gradlew @@ -1,160 +1,160 @@ -#!/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 - -# 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\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -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"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # 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 "$@" +#!/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 + +# 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\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +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"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # 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 "$@"