Skip to content
Snippets Groups Projects
Commit 3095b612 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

jinterface: move from system dependency to custom repository

Also updated README with instructions for using other versions of Erlang.
parent 6bcaeab3
No related branches found
No related tags found
No related merge requests found
......@@ -83,66 +83,38 @@ that end, the `jinterface` library must match the version of Erlang installed
in your machine. If your installation of Erlang is not OTP 26, you should indicate
the version of `jinterface` that matches the version of Erlang in your system.
1. Locate the directory in which Erlang is installed (typically `/usr/lib/erlang`).
Other common locations are `/usr/local/lib/erlang` (admin-compiled), `~/.local/lib/erlang`
(user-compiled) and `/usr/local/Cellar/erlang/VERSION/lib/erlang` (Homebrew on macOS).
2. Enter the Erlang installation directory and look for a folder `lib`, and in it,
a folder called `jinterface-VERSION`.
1. Enter an Erlang shell with `erl` and check the version that shows at startup.
2. Look up the version of `jinterface` required by your version of Erlang/OTP on
[this table](https://mist.dsic.upv.es/git/program-slicing/erlang-jinterface#usage).
3. When running `make` commands, use:
```bash
make MVN_OPTIONS="-Djinterface.version=VERSION -Djinterface.erlangRoot=ERLANG_INSTALLATION"
make MVN_OPTIONS="-Djinterface.version=VERSION"
```
The default values are `VERSION=1.14` and `ERLANG_INSTALLATION=/usr/lib/erlang`.
The default values can be seen at [e-Knife/pom.xml](e-Knife/pom.xml).
With this change, you can now build the project with past and future versions of Erlang.
#### Copy jinterface from existing installation
#### The table in step 2 doesn't have a compatible version with my system!
Your Erlang distribution will most likely be installed at `/usr/lib/erlang`,
`/usr/local/lib/erlang`, `~/.local/lib/erlang` or `/usr/local/Cellar/erlang/VERSION/lib/erlang`.
Then, the library is located in `lib/jinterface-VERSION/java_src`
In that case, you can specify the location for `jinterface` in your system by editing `e-Knife/pom.xml`:
In some distributions (such as Ubuntu), you may need to install the `erlang-jinterface`
package.
As an example:
```bash
pkg="com/ericsson/otp/erlang"
erlang="/usr/lib/erlang"
rm -rf e-Knife/src/main/java/$pkg
mv $erlang/lib/jinterface-1.12/java_src/$pkg e-Knife/src/main/java/$pkg
```
#### Download jinterface from the repository
Check the version of OTP that you have installed by running the following snippet ([credit][so1]):
```bash
erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell
```xml
<dependency>
<groupId>program-slicing</groupId>
<artifactId>erlang-jinterface</artifactId>
<scope>system</scope>
<version>VERSION</version>
<systemPath>ERLANG_ROOT_PATH/lib/jinterface-VERSION/priv/OtpErlang.jar</systemPath>
</dependency>
```
Then, download the corresponding release:
However, this means that `make` and `mvn package` commands won't include the `jinterface` jar, and you
will have to launch e-Knife with:
```bash
VERSION=22.2.7
wget https://github.com/erlang/otp/archive/OTP-$VERSION.tar.gz
```
Finally, extract `lib/jinterface-$ver/java_src` to the corresponding location:
```bash
VERSION=22.2.7
pkg="com/ericsson/otp/erlang"
ji_path="lib/jinterface-1.10.1/java_src"
dest="e-Knife/src/main/java/$pkg"
rm -rf $dest
tar -xf OTP-$VERSION.tar.gz otp-OTP-$VERSION/$ji_path/$pkg
mv otp-OTP-$VERSION/$ji_path/$pkg $dest
rm -rf otp-OTP-$VERSION/
java -cp e-Knife.jar:JINTERFACE_JAR eknife.EKnife [ARGUMENTS]
```
[so1]: https://stackoverflow.com/a/34326368
### UnsupportedClassVersionError: eknife/EKnife has been compiled by a more recent version of the Java Runtime
e-Knife requires at least Java 17. Your version may be lower. You can check it
......
......@@ -14,7 +14,6 @@
<properties>
<jinterface.version>1.14</jinterface.version>
<jinterface.erlangRoot>/usr/lib/erlang</jinterface.erlangRoot>
</properties>
<build>
......@@ -61,13 +60,18 @@
<artifactId>EDG</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.ericsson.otp</groupId>
<artifactId>jinterface</artifactId>
<scope>system</scope>
<dependency>
<groupId>program-slicing</groupId>
<artifactId>erlang-jinterface</artifactId>
<version>${jinterface.version}</version>
<systemPath>${jinterface.erlangRoot}/lib/jinterface-${jinterface.version}/priv/OtpErlang.jar</systemPath>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mist-gitlab-jinterface</id>
<url>https://mist.dsic.upv.es/git/api/v4/projects/45/packages/maven</url>
</repository>
</repositories>
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment