Examples can now be run at command line by Gradle

* Update README to reflect use of Gradle for build.
* Add gradle tasks to run the NIO and Netty examples.
* Ensure both examples exit quickly.
This commit is contained in:
Stuart Stock
2018-01-27 21:20:49 -06:00
parent 7a15d0143a
commit 580dd62153
4 changed files with 67 additions and 20 deletions

View File

@ -1,16 +1,49 @@
//
// Gradle build for Nearenough
//
// Copyright (c) 2017-2018 int08h LLC. All rights reserved.
//
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
dependencies {
// local snapshot of Ed25519
compile files('lib/eddsa-0.1.0.jar')
compile 'io.netty:netty-all:4.1.16.Final'
compile 'io.netty:netty-all:4.1.20.Final'
testCompile 'junit:junit:4.12'
}
// Suppress "Illegal reflective access" warnings on Java 9
def shouldAddOpens = JavaVersion.current().java9Compatible
// Runs the NIO example
task nioExample(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'nearenough.examples.NioClient'
if (shouldAddOpens) {
jvmArgs = ['--add-opens', 'java.base/java.nio=ALL-UNNAMED']
}
}
// Runs the NIO example
task nettyExample(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'nearenough.examples.NettyClient'
if (shouldAddOpens) {
jvmArgs = [
'--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED',
'--add-opens', 'java.base/java.nio=ALL-UNNAMED'
]
}
}