diff --git a/build.gradle.kts b/build.gradle.kts index 060b7d2..9d74e64 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -110,7 +110,7 @@ bintray { repo = "open-source" name = "nodejvm" setLicenses("Apache-2.0") - vcsUrl = "https://github.com/mikehearn/graviton-browser.git" + vcsUrl = "https://github.com/mikehearn/nodejvm.git" version.apply { name = project.version.toString() desc = "NodeJS interop for GraalVM" diff --git a/dat-sample/build.gradle.kts b/dat-sample/build.gradle.kts index 364628f..f8e61ba 100644 --- a/dat-sample/build.gradle.kts +++ b/dat-sample/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.net.URI plugins { java @@ -16,11 +17,18 @@ application { repositories { mavenCentral() + jcenter() + maven { + url = URI("https://dl.bintray.com/mikehearn/open-source") + } } dependencies { implementation(kotlin("stdlib-jdk8")) - implementation(rootProject) // This would be: implementation("net.plan99.nodejs:nodejs-interop:1.0") in a real project + implementation(rootProject) + + // In your programs, you'd write something like: + // implementation("net.plan99:nodejvm:1.1") } configure { diff --git a/docsite/docs/running-polyglot-programs.md b/docsite/docs/running-polyglot-programs.md index 03a5150..1451927 100644 --- a/docsite/docs/running-polyglot-programs.md +++ b/docsite/docs/running-polyglot-programs.md @@ -4,6 +4,9 @@ Download the latest release from the [releases page](https://github.com/mikehear Now add the `nodejvm` directory to your path, or copy the contents to somewhere on your path. +Make sure you've got GraalVM and set the location as either `JAVA_HOME` or `GRAALVM_PATH`. Or make sure +its `bin` directory is on your path. + Start your Java programs as normal but run `nodejvm` instead of `java`, e.g. `nodejvm -cp "libs/*.jar" my.main.Class arg1 arg2` @@ -25,9 +28,27 @@ gradle build spinners-sample:shadowJar ../build/nodejvm/nodejvm -jar build/libs/spinners-sample-*-all.jar ``` -## From Gradle +## From your own Gradle projects + +Firstly, add my Maven repository for the interop API JAR (this step will become obsolete soon as it'll be in JCenter): + +``` +import java.net.URI + +repositories { + maven { + url = URI("https://dl.bintray.com/mikehearn/open-source") + } +} + +dependencies { + implementation("net.plan99:nodejvm:1.1") +} +``` + +(these all use Kotlin DSL syntax) -The easiest way is to adjust your JavaCompile tasks to run `nodejvm` instead of `java`: +Then adjust your JavaCompile tasks to run `nodejvm` instead of `java`: ``` tasks.withType { diff --git a/src/main/java/net/plan99/nodejs/java/NodeJS.java b/src/main/java/net/plan99/nodejs/java/NodeJS.java index ff30d95..62ef2ea 100644 --- a/src/main/java/net/plan99/nodejs/java/NodeJS.java +++ b/src/main/java/net/plan99/nodejs/java/NodeJS.java @@ -8,18 +8,14 @@ import org.jetbrains.annotations.NotNull; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.net.JarURLConnection; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; @@ -34,8 +30,6 @@ * Provides an interface to the NodeJS runtime for Java developers. You can only access the NodeJS world * when running on the event loop thread, which means you must use the various runJS methods on this class * to get onto the correct thread before using eval. - * - * @suppress */ @SuppressWarnings("WeakerAccess") public class NodeJS {