Skip to content
Mateusz Pietryga edited this page Sep 22, 2021 · 56 revisions

Prerequisites

  • Java
    • JRE6+ required to use the library
    • JDK8+ required to build the project
    • Note: build with JDK9+ if you requrire jar compatible with JPMS
    • Note: build with JDK8-11 if you require backwards compatibility with JRE6, dropped in more recent Java editions
  • C++
  • Maven, CMake
    • Linux: sudo apt install openjdk maven cmake g++ file
    • macOS: brew install openjdk maven cmake
    • Windows:: See Windows Build Environment

Steps

mvn                 # compile for current system
mvn -P x86          # cross-compile for 32-bit x86 on current host OS(Linux/Unix, Windows) 
mvn -P x86_64       # cross-compile for 64-bit x86/amd64 on current host OS(Linux/Unix, MacOS, Windows)  
mvn -P ppc64        # cross-compile using multi-lib for PowerPC Linux/Unix
mvn -P armhf        # cross-compile using multi-lib for arm 32 bit hard floating point Linux/Unix
mvn -P aarch64      # cross-compile for arm64 based on current host OS (MacOS, Windows, Linux)
mvn -P mingw64      # cross-compile for Windows x86_64
mvn -P mingw32      # cross-compile for Windows x86
mvn -P mingwaarch64 # cross-compile for Windows ARM64
  • For cross-compile dependencies, see Cross-Compilation
  • Important: Call mvn clean between different compiler profiles.
  • Prefer to skip maven? The project is configured to allow calling cmake -DCMAKE_TOOLCHAIN_FILE=<...> directly.

Package

Without recompiling native libraries

mvn -P package,jar-with-dependencies

Advanced

machine-dependent artefact

The build will output two .jar files in the target/ directory. One archive, which is build by the maven-jar-plugin, has a classifier which maches the machine's classifier (unless you are doing a cross-compile). This one will contain a freshly compiled library, like libjssc.so for Linux or a jssc.dll if you are on Windows. They go into a directory /natives/os_bitness.

»Uber-jar« artefact

The other .jar artifact which is generated by the build doesn't use the library compiled by cmake. It uses the checked-in libraries form the directory src/main/resources-precompiled/natives/. This jar is the artefact we are going to publish to maven central. It will contain a broader varieties of OSes and architectures in just one .jar file, but the libraries checked in into this git repository need to stay updated.

Creating just the »uber-jar« artefact

If you do not need a freshly compiled library, you can just execute mvn package -P package to skip the cmake compilation and the unit tests.