diff --git a/README.md b/README.md index fe5743f..b668ff7 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,27 @@ # 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 -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. +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 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. diff --git a/build.gradle b/build.gradle index b77ab53..95d7271 100644 --- a/build.gradle +++ b/build.gradle @@ -1,52 +1,49 @@ buildscript { repositories { - jcenter() mavenCentral() - 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' + jcenter() } } - plugins { id 'application' + id 'io.left.rightmesh.rightmesh-plugin' version '1.8.1' } -apply plugin: 'io.left.rightmesh.rightmesh-plugin' -build.dependsOn("rightmesh") +rightmesh { + appKey = rightmesh_hellojavamesh_key + username = rightmesh_devportal_username + password = rightmesh_devportal_password +} repositories { - jcenter() + google() + mavenLocal() mavenCentral() + jcenter() + maven { url 'https://jitpack.io' } + maven { + 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:rightmesh-java-library:0.9.0') -} - -repositories { - jcenter() -} - -dependencies { + compile 'io.left.rightmesh:lib-rightmesh-jre:0.10.0' compile 'com.google.guava:guava:23.0' testCompile 'junit:junit:4.12' } +processResources { + dependsOn rightmesh + from rightmesh.outputFile +} + mainClassName = 'HelloJavaMesh' applicationDefaultJvmArgs = ["-noverify"] 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' diff --git a/src/main/java/HelloJavaMesh.java b/src/main/java/HelloJavaMesh.java index 7213d59..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; @@ -12,7 +29,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; @@ -42,8 +59,8 @@ public void start() { return; } - // Start up a non-superpeer RightMesh instance. - mm = new JavaMeshManager(false); + //start up a non-superpeer right mesh + mm = new JavaMeshManager(false, "rightmesh.json"); // Bind to a Mesh Port. mm.bind(HELLO_PORT);