Skip to content

Building Tutorial

Will Hedgecock edited this page Jun 30, 2023 · 42 revisions

Building this library yourself is not advised (at least not for distribution) as it requires native compilation across multiple platforms. It is recommended to simply use the pre-built jSerialComm.jar library in your application. For installation instructions, please refer to the Installation wiki.

If you do choose to build this library yourself, the recommended methodology is to use a Docker image that was created for this purpose. You will first need to obtain and set up and functioning Docker installation for your platform, after which you can access the jSerialComm build toolchain housed on Docker Hub under fazecast/jserialcomm:builder. Note that this Docker image is only designed to run on x86_64/amd64 and aarch64 platforms, so if you are developing on a different architecture, you will not be able to use this toolchain directly.

To build using this toolchain, you would enter the following command at a terminal:

docker run --privileged --rm -v "JSERIALCOMM_LOCAL_DIR":/home/toolchain/jSerialComm fazecast/jserialcomm:builder

where JSERIALCOMM_LOCAL_DIR should be replaced with the full path at which your local jSerialComm repository is located (e.g., /home/myuser/workspaces/jSerialComm). Simply running this command will cause all native libraries to be built, which will be placed in their correct corresponding directories under jSerialComm/src/main/resources, as well as a full jSerialComm snapshot JAR, which will be placed under jSerialComm/build/libs.

Instead of building all native library versions along with the library JAR, you can also choose to only build for specific architectures by using the same docker command shown above, but appending an additional target flag, like so:

docker run --privileged --rm -v "JSERIALCOMM_LOCAL_DIR":/home/toolchain/jSerialComm fazecast/jserialcomm:builder TARGET

where TARGET can be any of: libs, linux, arm, powerpc, solaris, freebsd, openbsd, osx, win32, win64, winarm, or winarm64. The libs target will build all native library versions, but will not build the final library JAR. If you simply want to build your own JAR, you can cd to the root of the jSerialComm repository and enter gradle build (which requires that you have Gradle installed locally on your machine). The resulting jSerialComm library can be found in the project directory jSerialComm/build/libs/ under the name "jSerialComm-{VERSION}.jar".