Mandrel Packaging
June 8, 2023 ยท View on GitHub
This repo contains all the necessary scripts and tools to build Mandrel.
Building mandrelJDK locally
export JAVA_HOME=/opt/jvms/openjdk-11.0.8_10
$JAVA_HOME/bin/java -ea build.java --mx-home ~/code/mx --mandrel-repo ~/code/mandrel
where:
JAVA_HOMEis the path to the OpenJDK you want to use for building mandrel.--mx-homeis the path where you cloned https://github.com/graalvm/mx. Defaults to/opt/mx.--mandrel-repois the path where you cloned https://github.com/graalvm/mandrel. Defaults to/tmp/mandrel.
This should print something similar to:
INFO [build] Building!
build: Checking SubstrateVM requirements for building ...
build: Checking SubstrateVM requirements for building ...
build: Checking SubstrateVM requirements for building ...
build: Checking SubstrateVM requirements for building ...
INFO [build] Creating JDK!
INFO [build] Congratulations you successfully built Mandrel 20.1.0.1.Final-3-g9abceb5ac7d based on Java 11.0.8+10
INFO [build] You can find your newly built native-image enabled JDK under ./mandrel-java11-20.1.0.1.Final-3-g9abceb5ac7d
More options
Generic
--verboseenables verbose logging.--skip-cleanskips cleaning before building.--skip-javaskips building java bits.--skip-nativeskips building native bits.--archive-suffixdefines the suffix for creating an archive with the new JDK. By default no archive is built. Accepted values aretar.gzandtarxz(slower but with better compresion).--dependenciesoverridesmxdependencies, e.g.,--dependencies id=ASM_7.1,version=7.1.0.redhat-00001,sha1=41bc48bf913569bd001cc132624f811d91004af4,sourceSha1=8c938bc977786f0f3964b394e28f31e726769bac
Mandrel related
--mandrel-homesets the path where you want mandrel to be installed, after completion you will be able to use this asJAVA_HOMEor/andGRAALVM_HOMEin your projects (e.g. quarkus). By default mandrel is built in the current directory and the version-based path gets printed at the end.--mandrel-versiondefines the version to be shown when runningnative-image --version(e.g. 20.1.0). Defaults to the result ofgit describeorgit rev-parse --short HEADinmandrel-repo.
Maven-related
--maven-installgenerates maven artifacts and installs them to the local maven repository.--maven-deploygenerates maven artifacts, installs them to the local maven repository and deploys them.--maven-versionspecifies the version (e.g.,20.1.0.2-0-redhat-00000) to be used in the maven artifacts (required by--maven-installand--maven-deploy).--maven-proxyspecifies a maven proxy to use.--maven-repo-idspecifies the maven repository ID for deploying maven artifacts. Required by--maven-deploy.--maven-urlspecifies the maven url for deploying maven artifacts. Required by--maven-deploy.--maven-local-repositoryspecifies the local repository. Defaults to~/.m2/repository.--maven-homespecifies the maven installation path in case one wants to use a different maven version than the one provided by the system.
Building mandrelJDK java parts separately from native parts
If your build infrastructure requires building java parts separately from native parts you can use the following steps.
Step 1: Build the java parts
$JAVA_HOME/bin/java -ea build.java --mx-home ~/code/mx --mandrel-repo ~/code/mandrel --mandrel-home /tmp/java_step --skip-native
Step 2: Build the java parts
/tmp/java_step/bin/java -ea build.java --mx-home ~/code/mx --mandrel-repo ~/code/mandrel --skip-java --skip-clean
After the last step you can delete the intermediate JDK with:
rm -rf /tmp/java_step
Building mandrelJDK on a Mac using a custom build of OpenJDK
Mandrel can be built on a Mac using a custom build of OpenJDK that contains static libraries.
If you want to base Mandrel on a custom JDK, it's important to build the JDK's macOS bundles first, and then extract them into a directory structure that mirrors pre-built JDKs. For example:
$ make bundles
$ cd build/<conf-name>/bundles
$ tar -xzvpf *_bin.tar.gz
$ tar -xzvpf *_bin-static-libs.tar.gz
$ ./<jdk-folder>/Contents/Home/bin/java --version
...
OpenJDK 64-Bit Server VM (...)
Mandrel should then be built setting JAVA_HOME to the macOS-specific java home directory.
E.g.
export JAVA_HOME=<path-to-jdk-source>/build/<conf-name>/bundles/<jdk-folder>/Contents/Home
$JAVA_HOME/bin/java -ea build.java --mx-home ~/code/mx --mandrel-repo ~/code/mandrel