Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraalVM 21.2.0 support #459

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,17 @@ Java version 7 or later installed. Check the version by typing `java

# Installation

Before installing ScriptCraft you must first install SpigotMC which is
a special version of Minecraft Server that makes it easy to customize
the game.
Before installing ScriptCraft you must first install

1. Java and JavaScript engine
2. SpigotMC which is a special version of Minecraft Server that makes it easy to customize the game.

## Installing Java and JavaScript

Unfortunately, the most used Java distribution (Oracle JDK or OpenJDK) does NOT include any more the JavaScript engine (called Nashorn), starting from [release 15](https://openjdk.java.net/jeps/372) (and deprecated since [release 11](https://docs.oracle.com/en/java/javase/11/docs/api/jdk.scripting.nashorn/module-summary.html)).
The most suited replacement is [GraalVM](https://www.graalvm.org/), still from Oracle. You can dowload the package from the [GraalVM web site](https://www.graalvm.org/) and [install it](https://www.graalvm.org/docs/getting-started/) according to your Operating System. Note that this may require some manual setup (e.g. under Windows, adding the binaries path to the PATH environmental variable).
Note that if you already have a working Java installation (e.g. OpenJDK) the two may clash, so you may end up with Java from OpenJDK and JavaScript from GraalVM. This is untested.


## Installing and Running SpigotMC

Expand All @@ -102,13 +110,27 @@ Follow these steps to download and install SpigotMC.

## Installing ScriptCraft

### Install pre-compiled ScriptCraft

Follow these steps to download and install ScriptCraft.

1. Download the [scriptcraft.jar][dl] plugin and save it to the `plugins` directory and restart the server by typing `java -jar spigot-1.10.2.jar`.
**REMARK: the compiled scriptcraft.jar may fail with the newer Java/JavaScript version, in particular with GraalVM, due to subtle incompatibitities, see e.g. the [migration guide from Nashorn to GraalJS](https://docs.oracle.com/en/graalvm/enterprise/20/docs/reference-manual/js/NashornMigrationGuide/)**. In this case (errors when loading the plugin during the server start-up) you may need to use a newer scriptcraft.jar (you can try the '[scriptcraft.jar](https://github.com/ediloren/ScriptCraft/blob/development/target/scriptcraft.jar)' file you can find in the 'target' directory in this repository), or compile it yourself, see next paragraph.
2. At the server prompt type `js 1 + 1` and hit enter. The result `2` should be displayed.

Congratulations - you've just installed your Custom Minecraft Server and are ready to begin writing your first mod!

### Install ScriptCraft from sources

Download the latest sources from the current repository (the one hosting this readme). You can dowload them as Zip file or, if you know how to use **git**, you can clone the repository.

These sources contain some patches that have been tested with GraalVM with Java release 21.2.0 under Windows10 and SpigotMC server. They are not guaranteed to work in other environments but may help fixing compatibility issues also in those cases.

The sources are built using [Ant](https://ant.apache.org/). You must first install Ant. Be sure to follow the [installation instructions](https://ant.apache.org/manual/index.html) as it needs some manual configuration.

Now you should be able to build ScriptCraft out of the box issuing the 'ant' command from a shell in the base directory where you cloned / unzipped your sources.
Ant will create a folder called 'target' in which you will find the file scriptcraft.jar at the end of the build process.

# Post Install

Once installed, a new scriptcraft/plugins directory is automatically
Expand Down
67 changes: 34 additions & 33 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
<sequential>
<echo message="cp=${build}:${lib.canary}:${lib.bukkit}"></echo>
<echo message="src=@{src} out=@{out} err=@{err}"></echo>
<java classname="jscript"
<java classname="jscript"
failonerror="true"
fork="true" output="@{out}" error="@{err}">
<classpath>
<pathelement path="${build}"/>
<pathelement path="${build}"/>
<pathelement path="@{lib}"/>
</classpath>
<arg value="@{src}"/>
Expand All @@ -57,15 +57,16 @@
</target>

<target name="test" depends="package" description="Perform unit tests">

</target>


<target name="compile-plugins" depends="init" description="compile canary plugin source">
<javac includeantruntime="false"
source="1.6"
target="1.6"
destdir="${build}"
<target name="compile-plugins" depends="init" description="compile canary plugin source">
<!-- 1.6 is no longer supported, need to use 1.7 or later -->
<javac includeantruntime="false"
source="1.9"
target="1.9"
destdir="${build}"
debug="true">
<src path="${src.canary}"/>
<src path="${src.bukkit}"/>
Expand All @@ -75,7 +76,7 @@
</classpath>
</javac>
</target>

<target name="gendocs"
depends="construct-ypgpm, construct-api-ref"
description="Generate API documentation">
Expand All @@ -91,24 +92,24 @@

<target name="generate-api-ref-entries" depends="copy-js,compile-docs,init">

<jscript src="src/docs/js/generateApiDocs.js"
<jscript src="src/docs/js/generateApiDocs.js"
out="${dist}/apiref.md"
lib="${lib.bukkit}"
err="${dist}/gen-api-error.log">
<arg value="${dist}/js"/>
<arg value="${dist}/js"/>
</jscript>

<jscript src="src/docs/js/generateItemsDocBukkit.js"
<jscript src="src/docs/js/generateItemsDocBukkit.js"
out="${dist}/items-bukkit.md"
lib="${lib.bukkit}"
err="${dist}/gen-items-error.log" />

<jscript src="src/docs/js/generateSoundsDocBukkit.js"
out="${dist}/sounds-bukkit.md"
<jscript src="src/docs/js/generateSoundsDocBukkit.js"
out="${dist}/sounds-bukkit.md"
lib="${lib.bukkit}"
err="${dist}/gen-sounds-error.log" />

<jscript src="src/docs/js/generateEntitiesDocBukkit.js"
<jscript src="src/docs/js/generateEntitiesDocBukkit.js"
out="${dist}/entities-bukkit.md"
lib="${lib.bukkit}"
err="${dist}/gen-entities-error.log" />
Expand All @@ -125,7 +126,7 @@

<target name="gen-events-helper-canary" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/>
<jscript src="src/docs/js/generateEventsHelper.js"
<jscript src="src/docs/js/generateEventsHelper.js"
out="${dist}/js/lib/events-helper-canary.js"
lib="${lib.canary}"
err="${dist}/gen-events-canary-error.log">
Expand All @@ -138,7 +139,7 @@

<target name="gen-events-helper-bukkit" depends="compile-docs,init">
<mkdir dir="${dist}/js/lib"/>
<jscript src="src/docs/js/generateEventsHelper.js"
<jscript src="src/docs/js/generateEventsHelper.js"
out="${dist}/js/lib/events-helper-bukkit.js"
lib="${lib.bukkit}"
err="${dist}/gen-events-bukkit-error.log">
Expand All @@ -152,7 +153,7 @@
<target name="construct-api-ref" depends="gen-toc-apiref,init">

<concat destfile="docs/API-Reference.md">
<header filtering="no" trimleading="yes">&lt;!--
<header filtering="no" trimleading="yes">&lt;!--
IMPORTANT NOTE FOR CONTRIBUTORS
-------------------------------
Contributors: This file is generated from comments in javascript source files src/main/js/*
Expand All @@ -169,11 +170,11 @@ Walter Higgins
</header>
<fileset file="${dist}/toc-apiref.md" />
<fileset file="${dist}/apiref-con.md" />
</concat>
</concat>
</target>

<target name="gen-toc-apiref" depends="compile-docs,generate-api-ref-entries, init" description="Generate Table of Contents for API Reference">
<jscript src="src/docs/js/generateTOC.js"
<jscript src="src/docs/js/generateTOC.js"
out="${dist}/toc-apiref.md"
lib="${lib.bukkit}"
err="${dist}/gen-toc-error.log">
Expand All @@ -182,8 +183,8 @@ Walter Higgins
</target>

<target name="gen-toc-ypgpm" depends="compile-docs,init" description="Generate Table of Contents for Young Programmers Guide">
<jscript src="src/docs/js/generateTOC.js"
out="${dist}/toc-ypgpm.md"
<jscript src="src/docs/js/generateTOC.js"
out="${dist}/toc-ypgpm.md"
lib="${lib.bukkit}"
err="${dist}/gen-ypgpm-error.log">
<arg value="src/docs/templates/ypgpm.md"/>
Expand All @@ -193,7 +194,7 @@ Walter Higgins
<!-- Piece together the Young persons' guide from template and generated table of contents -->
<target name="construct-ypgpm" depends="gen-toc-ypgpm,init">
<concat destfile="docs/YoungPersonsGuideToProgrammingMinecraft.md">
<header filtering="no" trimleading="yes">&lt;!--
<header filtering="no" trimleading="yes">&lt;!--
IMPORTANT NOTE FOR CONTRIBUTORS
-------------------------------
Contributors: This file is generated from source file src/docs/templates/ypgpm.md
Expand All @@ -203,7 +204,7 @@ Walter Higgins
</header>
<fileset file="${dist}/toc-ypgpm.md" />
<fileset file="src/docs/templates/ypgpm.md" />
</concat>
</concat>
</target>

<target name="zip_js" depends="zip_lib, zip_modules, zip_plugins">
Expand All @@ -217,8 +218,8 @@ Walter Higgins

<target name="zip_lib" depends="copy-js">
<delete file="${build}/lib.zip"/>
<zip destfile="${build}/lib.zip"
basedir="${dist}/js"
<zip destfile="${build}/lib.zip"
basedir="${dist}/js"
excludes="modules/**, plugins/**,">
</zip>
</target>
Expand All @@ -241,20 +242,20 @@ Walter Higgins

<target name="zip_modules" depends="copy-js, get_underscore, get_babel">
<delete file="${build}/modules.zip"/>
<zip destfile="${build}/modules.zip"
basedir="${dist}/js"
<zip destfile="${build}/modules.zip"
basedir="${dist}/js"
excludes="lib/**, plugins/**,">
</zip>
</target>

<target name="zip_plugins" depends="copy-js">
<delete file="${build}/plugins.zip"/>
<zip destfile="${build}/plugins.zip"
<zip destfile="${build}/plugins.zip"
basedir="${dist}/js"
excludes="lib/**, modules/**">
</zip>
</target>

<target name="package" depends="gendocs,zip_js,compile-plugins" description="generate the distribution" >
<!-- ensure plugin.yml is always copied -->
<delete file="${build}/plugin.yml" />
Expand All @@ -268,10 +269,10 @@ Walter Higgins
<replace file="${build}/Canary.inf" value="${scriptcraft-version}-${DSTAMP}">
<replacetoken>[[version]]</replacetoken>
</replace>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<mkdir dir="${dist}/${DSTAMP}" />

<jar jarfile="${dist}/${DSTAMP}/scriptcraft.jar" basedir="${build}"/>
<copy file="${dist}/${DSTAMP}/scriptcraft.jar" tofile="${dist}/scriptcraft.jar"/>
</target>
Expand Down
Loading