From d8dc024e34f4578acab2bec4b4ee38b5ae77a4cc Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 7 Nov 2018 15:18:26 -0800 Subject: [PATCH 01/11] Support rightmesh license --- build.gradle | 33 ++++++++++++++++++++++++++------ src/main/java/HelloJavaMesh.java | 8 ++++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index b77ab53..a3b2177 100644 --- a/build.gradle +++ b/build.gradle @@ -22,9 +22,18 @@ plugins { apply plugin: 'io.left.rightmesh.rightmesh-plugin' build.dependsOn("rightmesh") +rightmesh { + outputs.dir file("src/main/assets") +} + repositories { - jcenter() + google() + mavenLocal() mavenCentral() + jcenter() + maven { + url "https://dl.bintray.com/ethereum/maven/" + } maven { url "https://research.rightmesh.io/artifactory/libs-local" credentials { @@ -35,11 +44,7 @@ repositories { } dependencies { - compile ('io.left.rightmesh:rightmesh-java-library:0.9.0') -} - -repositories { - jcenter() + compile('io.left.rightmesh:lib-rightmesh-jre:BEN-SNAPSHOT') } dependencies { @@ -48,5 +53,21 @@ dependencies { testCompile 'junit:junit:4.12' } +startScripts { + classpath += files('src/main/assets') +} + +distributions { + main { + baseName = 'HelloJavaMesh' + contents { + from('src/main') { + include 'assets/**' + into 'lib' + } + } + } +} + mainClassName = 'HelloJavaMesh' applicationDefaultJvmArgs = ["-noverify"] diff --git a/src/main/java/HelloJavaMesh.java b/src/main/java/HelloJavaMesh.java index 7213d59..996398b 100644 --- a/src/main/java/HelloJavaMesh.java +++ b/src/main/java/HelloJavaMesh.java @@ -3,6 +3,9 @@ import io.left.rightmesh.mesh.MeshManager; import java.io.Console; +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashSet; import static io.left.rightmesh.mesh.MeshManager.DATA_RECEIVED; @@ -42,8 +45,9 @@ public void start() { return; } - // Start up a non-superpeer RightMesh instance. - mm = new JavaMeshManager(false); + //start up a non-superpeer right mesh + System.out.println("WWWWWW"); + mm = new JavaMeshManager(false, getClass().getClassLoader().getResource("rightmesh.json").getFile()); // Bind to a Mesh Port. mm.bind(HELLO_PORT); From 986ca38424ea1977270f7062554cedd297775a19 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 7 Nov 2018 15:55:59 -0800 Subject: [PATCH 02/11] libjre now supports loading from resources --- build.gradle | 14 +++----------- src/main/java/HelloJavaMesh.java | 6 +----- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index a3b2177..580c28f 100644 --- a/build.gradle +++ b/build.gradle @@ -53,18 +53,10 @@ dependencies { testCompile 'junit:junit:4.12' } -startScripts { - classpath += files('src/main/assets') -} - -distributions { +sourceSets { main { - baseName = 'HelloJavaMesh' - contents { - from('src/main') { - include 'assets/**' - into 'lib' - } + resources { + srcDir 'src/main/assets' } } } diff --git a/src/main/java/HelloJavaMesh.java b/src/main/java/HelloJavaMesh.java index 996398b..7129d1b 100644 --- a/src/main/java/HelloJavaMesh.java +++ b/src/main/java/HelloJavaMesh.java @@ -3,9 +3,6 @@ import io.left.rightmesh.mesh.MeshManager; import java.io.Console; -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashSet; import static io.left.rightmesh.mesh.MeshManager.DATA_RECEIVED; @@ -46,8 +43,7 @@ public void start() { } //start up a non-superpeer right mesh - System.out.println("WWWWWW"); - mm = new JavaMeshManager(false, getClass().getClassLoader().getResource("rightmesh.json").getFile()); + mm = new JavaMeshManager(false, "rightmesh.json"); // Bind to a Mesh Port. mm.bind(HELLO_PORT); From 651244d6fc103295734283050c2629e94ebf6dbd Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 7 Nov 2018 15:56:42 -0800 Subject: [PATCH 03/11] Merge buildscript dependencies blocks --- build.gradle | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle b/build.gradle index 580c28f..e41f229 100644 --- a/build.gradle +++ b/build.gradle @@ -45,9 +45,6 @@ repositories { dependencies { compile('io.left.rightmesh:lib-rightmesh-jre:BEN-SNAPSHOT') -} - -dependencies { compile 'com.google.guava:guava:23.0' testCompile 'junit:junit:4.12' From e442d3ab4548141b1b0830d6b8d23a2b5ccbffdb Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 7 Nov 2018 17:54:13 -0800 Subject: [PATCH 04/11] Cleaning, plus output dep on rm plugin --- build.gradle | 7 +++---- src/main/java/HelloJavaMesh.java | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index e41f229..d423511 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,5 @@ buildscript { repositories { - jcenter() - mavenCentral() maven { url "https://research.rightmesh.io/artifactory/libs-local" credentials { @@ -23,7 +21,7 @@ apply plugin: 'io.left.rightmesh.rightmesh-plugin' build.dependsOn("rightmesh") rightmesh { - outputs.dir file("src/main/assets") + outputs.dir file("src/main/assets/") } repositories { @@ -31,6 +29,7 @@ repositories { mavenLocal() mavenCentral() jcenter() + maven { url 'https://jitpack.io' } maven { url "https://dl.bintray.com/ethereum/maven/" } @@ -53,7 +52,7 @@ dependencies { sourceSets { main { resources { - srcDir 'src/main/assets' + srcDirs rightmesh.outputs.files } } } diff --git a/src/main/java/HelloJavaMesh.java b/src/main/java/HelloJavaMesh.java index 7129d1b..47893d9 100644 --- a/src/main/java/HelloJavaMesh.java +++ b/src/main/java/HelloJavaMesh.java @@ -12,7 +12,7 @@ /* * "Hello RightMesh" for Java - a simple application example for using RightMesh in pure Java. */ -public class HelloJavaMesh { +public class HelloJavaMesh { private static final int HELLO_PORT = 9876; private JavaMeshManager mm; private HashSet users; From a09962443514d02568dfc17c51079fde3a6f70de Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Thu, 8 Nov 2018 23:28:27 -0800 Subject: [PATCH 05/11] Clean up buildscript Use Keefer's new rightmesh dsl Use processResources task Use descriptive credential names This build should now be compatible with code split and latest plugin; update the deps when those are released on artifactory.rm --- build.gradle | 38 +++++++++++++------------------------- settings.gradle | 26 ++++++++++---------------- 2 files changed, 23 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index d423511..583a0c1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,18 @@ buildscript { repositories { - maven { - url "https://research.rightmesh.io/artifactory/libs-local" - credentials { - username artifactory_app_username - password artifactory_app_password - } - } - } - dependencies { - classpath 'io.left.rightmesh:rightmesh-plugin:1.6' + mavenCentral() + jcenter() } } - plugins { id 'application' + id 'io.left.rightmesh.rightmesh-plugin' version '1.8.1-SNAPSHOT' } -apply plugin: 'io.left.rightmesh.rightmesh-plugin' -build.dependsOn("rightmesh") - rightmesh { - outputs.dir file("src/main/assets/") + appKey = rightmesh_hellojavamesh_key + username = rightmesh_devportal_username + password = rightmesh_devportal_password } repositories { @@ -34,27 +25,24 @@ repositories { url "https://dl.bintray.com/ethereum/maven/" } maven { - url "https://research.rightmesh.io/artifactory/libs-local" + url "https://artifactory.rightmesh.io/artifactory/maven" credentials { - username artifactory_app_username - password artifactory_app_password + username rightmesh_artifactory_username + password rightmesh_artifactory_password } } } dependencies { - compile('io.left.rightmesh:lib-rightmesh-jre:BEN-SNAPSHOT') + compile 'io.left.rightmesh:lib-rightmesh-jre:BEN-SNAPSHOT' compile 'com.google.guava:guava:23.0' testCompile 'junit:junit:4.12' } -sourceSets { - main { - resources { - srcDirs rightmesh.outputs.files - } - } +processResources { + dependsOn rightmesh + from rightmesh.outputFile } mainClassName = 'HelloJavaMesh' diff --git a/settings.gradle b/settings.gradle index 824017c..e6ae676 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,18 +1,12 @@ -/* - * This settings file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * In a single project build this file can be empty or even removed. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user guide at https://docs.gradle.org/4.3/userguide/multi_project_builds.html - */ - -/* -// To declare projects as part of a multi-project build use the 'include' method -include 'shared' -include 'api' -include 'services:webservice' -*/ +pluginManagement.repositories { + mavenLocal() + maven { + url 'https://artifactory.rightmesh.io/artifactory/maven' + credentials { + username rightmesh_artifactory_username + password rightmesh_artifactory_password + } + } +} rootProject.name = 'HelloJavaMesh' From 1ded5ad668ed43ab1878dd01a8b23208e0a62b25 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Tue, 13 Nov 2018 08:54:08 -0800 Subject: [PATCH 06/11] Use published artifact --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 583a0c1..f469255 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ repositories { } dependencies { - compile 'io.left.rightmesh:lib-rightmesh-jre:BEN-SNAPSHOT' + compile 'io.left.rightmesh:lib-rightmesh-jre:0.10.0' compile 'com.google.guava:guava:23.0' testCompile 'junit:junit:4.12' From 3870146675bba009dc6f2296cb59f5dd02191f23 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Tue, 13 Nov 2018 08:57:39 -0800 Subject: [PATCH 07/11] Fully upgrade plugin --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f469255..95d7271 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { } plugins { id 'application' - id 'io.left.rightmesh.rightmesh-plugin' version '1.8.1-SNAPSHOT' + id 'io.left.rightmesh.rightmesh-plugin' version '1.8.1' } rightmesh { From 258ea601599698adc6a7fbdb24acd2f1d173ebc3 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 14 Nov 2018 11:18:21 -0800 Subject: [PATCH 08/11] Remove outdated readme info --- README.md | 57 +++++++------------------------------------------------ 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index fe5743f..b9f8f2b 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,16 @@ # Hello Java Mesh -This is the simplest example app using the java version of the RightMesh +This is the simplest example app using the java version of the RightMesh library. It is meant to operate on Linux / Windows / Raspberry PI etc, -which support java. This app can interoperate with the Android version: +or any other platform supporting Java. +This app can interoperate with the Android version: https://github.com/RightMesh/HelloMesh ## Adding the RightMesh library -Update the [gradle.build](build.gradle) file with the following: -```applicationDefaultJvmArgs = ["-noverify"] -buildscript { - ext { - artifactory_app_username = "insertyourusername" - artifactory_app_password = "insertyourpasswordhash" - artifactory_app_key = "insertyourkey" - } - repositories { - maven { - url "http://research.rightmesh.io/artifactory/libs-local" - credentials { - username artifactory_app_username - password artifactory_app_password - } - } - mavenCentral() - jcenter() - } - dependencies { - classpath 'io.left.rightmesh:rightmesh-plugin:1.3' - } -} -apply plugin: 'io.left.rightmesh.rightmesh-plugin' -build.dependsOn("rightmesh") +Refer to [build.gradle](build.gradle) for an example of integrating +RightMesh into your own application. -repositories { - mavenCentral() - jcenter() - maven { - url "http://research.rightmesh.io/artifactory/libs-local" - credentials { - username artifactory_app_username - password artifactory_app_password - } - } -} - -dependencies { - compile ('io.left.rightmesh:rightmesh-java-library:0.4.0') -} -``` - -## Building +## Using this app `./gradlew installDist` - -## Running `./gradlew run` or `./build/install/HelloJavaMesh/bin/HelloJavaMesh` ## Notes on running @@ -59,7 +18,5 @@ At this time, the java library does not automatically join the RM network so it is up to the developer to manually join the network with the device the java code is running on. For testing purposes you should be able to join any mobile phone network starting with RM-XXXXXX with the password -`m3sht3st`. BT connectivity is not supported at this time. If the device -running java has an Internet connection, it can also discover devices -through the Internet as of version 0.4.0. +`m3sht3st`. BT connectivity is not supported at this time. From cab3dcbba69e0f31eb221a30ec09f0e2168f532b Mon Sep 17 00:00:00 2001 From: Frazer Seymour Date: Wed, 14 Nov 2018 14:03:20 -0800 Subject: [PATCH 09/11] Update README.md Co-Authored-By: fractalic --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b9f8f2b..c8f54d1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ RightMesh into your own application. `./gradlew run` or `./build/install/HelloJavaMesh/bin/HelloJavaMesh` ## Notes on running + +If you have an Internet connection, HelloJavaMesh will connect to a RightMesh Superpeer and discover peers around the world who are also connected to a superpeer. + At this time, the java library does not automatically join the RM network so it is up to the developer to manually join the network with the device the java code is running on. For testing purposes you should be able to From b14d3a12ef20ba2e01339fc85641f739ba2030e6 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 14 Nov 2018 11:24:14 -0800 Subject: [PATCH 10/11] Add license to start of source --- src/main/java/HelloJavaMesh.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/HelloJavaMesh.java b/src/main/java/HelloJavaMesh.java index 47893d9..3f3c983 100644 --- a/src/main/java/HelloJavaMesh.java +++ b/src/main/java/HelloJavaMesh.java @@ -1,3 +1,20 @@ +/** HelloMesh: A sample RightMesh app for Java platforms. + Copyright (C) 2018 RightMesh AG + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + import io.left.rightmesh.id.MeshId; import io.left.rightmesh.mesh.JavaMeshManager; import io.left.rightmesh.mesh.MeshManager; From 422e6f24989de3792d910d84e1b1b46ec93cf567 Mon Sep 17 00:00:00 2001 From: Ben Hughes Date: Wed, 14 Nov 2018 14:17:02 -0800 Subject: [PATCH 11/11] Add Frazer's readme wording --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c8f54d1..b668ff7 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,14 @@ RightMesh into your own application. `./gradlew run` or `./build/install/HelloJavaMesh/bin/HelloJavaMesh` ## Notes on running +If you have an Internet connection, HelloJavaMesh will connect to a RightMesh +Superpeer and discover peers around the world who are also connected +to a superpeer. -If you have an Internet connection, HelloJavaMesh will connect to a RightMesh Superpeer and discover peers around the world who are also connected to a superpeer. - -At this time, the java library does not automatically join the RM network -so it is up to the developer to manually join the network with the device -the java code is running on. For testing purposes you should be able to -join any mobile phone network starting with RM-XXXXXX with the password +At this time, the Java library does not automatically join the local mesh +network so it is up to the developer to manually join the network with the +device the Java code is running on. For testing purposes you should be able to +join any WiFi network being broadcast by a phone running RightMesh with an +SSID following the pattern RM-XXXXXX using the password `m3sht3st`. BT connectivity is not supported at this time.