Skip to content

Commit 478cacd

Browse files
committed
Restore native artifact packaging
Zig cross-compilation produced LMDB libraries 31% slower than distribution packages. This restores the native artifact, now fetching pre-compiled libraries from Arch Linux, Homebrew and MSYS2 instead of compiling them ourselves. This approach reduces complexity and is practical given infrequent LMDB releases.
1 parent e29269b commit 478cacd

File tree

15 files changed

+237
-479
lines changed

15 files changed

+237
-479
lines changed

.github/workflows/maven.yml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,54 @@ on:
88

99
jobs:
1010
build:
11-
name: ${{ matrix.os }} Build
12-
runs-on: ${{ matrix.os }}
13-
14-
strategy:
15-
matrix:
16-
os: [ubuntu-latest, macos-latest, windows-latest]
11+
name: Build and Verify
12+
runs-on: ubuntu-latest
1713

1814
steps:
1915
- name: Check out Git repository
20-
uses: actions/checkout@v3
21-
with:
22-
submodules: true
16+
uses: actions/checkout@v5
17+
18+
- name: Install dependencies
19+
run: sudo apt-get update && sudo apt-get install -y zstd
2320

2421
- name: Set up Java and Maven
25-
uses: actions/setup-java@v3
22+
uses: actions/setup-java@v5
2623
with:
2724
distribution: zulu
28-
java-version: 11
25+
java-version: 25
2926
cache: maven
3027

3128
- name: Build with Maven
3229
run: mvn -B verify
3330

3431
deploy:
35-
needs: build
36-
name: ${{ matrix.os }} Deploy to OSSRH
37-
runs-on: ${{ matrix.os }}
32+
name: Deploy to Central Portal
33+
needs: [build]
3834
if: github.event_name == 'push'
39-
40-
strategy:
41-
matrix:
42-
os: [ubuntu-latest, macos-latest, windows-latest]
35+
runs-on: ubuntu-latest
4336

4437
steps:
4538
- name: Check out Git repository
46-
uses: actions/checkout@v3
47-
with:
48-
submodules: true
39+
uses: actions/checkout@v5
40+
41+
- name: Install dependencies
42+
run: sudo apt-get update && sudo apt-get install -y zstd
4943

5044
- name: Set up Java and Maven
51-
uses: actions/setup-java@v3
45+
uses: actions/setup-java@v5
5246
with:
5347
distribution: zulu
54-
java-version: 11
48+
java-version: 25
5549
cache: maven
56-
server-id: ossrh
57-
server-username: MAVEN_USERNAME
58-
server-password: MAVEN_CENTRAL_TOKEN
50+
server-id: central
51+
server-username: MAVEN_CENTRAL_USERNAME
52+
server-password: MAVEN_CENTRAL_PASSWORD
5953
gpg-private-key: ${{ secrets.gpg_private_key }}
6054
gpg-passphrase: MAVEN_GPG_PASSPHRASE
6155

6256
- name: Publish Maven package
63-
run: mvn -Possrh-deploy -B deploy
57+
run: mvn -B -Pcentral-deploy deploy -DskipTests
6458
env:
6559
MAVEN_GPG_PASSPHRASE: ${{ secrets.gpg_passphrase }}
66-
MAVEN_USERNAME: ${{ secrets.nexus_username }}
67-
MAVEN_CENTRAL_TOKEN: ${{ secrets.nexus_password }}
60+
MAVEN_CENTRAL_USERNAME: ${{ secrets.central_username }}
61+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.central_password }}

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,28 @@
1-
# THIS PROJECT IS ARCHIVED
2-
3-
**Cross compilation is now performed in the
4-
[LmdbJava](https://github.com/lmdbjava/lmdbjava) project.**
5-
61
[![Maven Build and Deployment](https://github.com/lmdbjava/native/workflows/Maven%20Build%20and%20Deployment/badge.svg)](https://github.com/lmdbjava/native/actions)
7-
[![Maven Central](https://img.shields.io/maven-central/v/org.lmdbjava/lmdbjava-native-parent.svg?maxAge=3600)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.lmdbjava%22%20AND%20a%3A%22lmdbjava-native-parent%22)
2+
[![Maven Central](https://img.shields.io/maven-central/v/org.lmdbjava/native.svg?maxAge=3600)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.lmdbjava%22%20AND%20a%3A%22native%22)
83
[![License](https://img.shields.io/badge/license-OpenLDAP-blue.svg?maxAge=2592000)](http://www.openldap.org/software/release/license.html)
94

105
# LMDB Native Libraries
116

12-
This repository creates standard builds of the [LMDB](http://symas.com/mdb/)
13-
native library. It packages the built libraries into operating system-specific
14-
JARs (with POMs). This allows [LmdbJava](https://github.com/lmdbjava/lmdbjava)
15-
(or other interested Java projects) to depend on these JARs using the normal
16-
Maven dependency resolution process.
17-
18-
**If you are simply wishing to use LMDB from Java, please use the
19-
[LmdbJava](https://github.com/lmdbjava/lmdbjava) project.**
20-
21-
This project is intended to be executed by GitHub Actions, as Linux, Windows and
22-
macOS operating systems are all required. Linux is used for compiling the Linux
23-
modules, whereas Windows and macOS compile their modules.
24-
25-
### Versioning
7+
Provides pre-compiled LMDB native libraries for Linux, macOS and Windows. These libraries are fetched from distribution package managers (Arch Linux, Homebrew, MSYS2) and packaged into a single JAR for easy dependency resolution.
268

27-
This project uses the `major.minor.patch-qualifier` version numbering typical
28-
of Maven projects. The major, minor and patch directly reflect the upstream
29-
LMDB library version, as expressed by `lmdb.h` `MDB_VERSION_*` definitions.
30-
The qualifier resets to `1` on a new major, minor or patch release.
9+
**If you are using LMDB from Java, use the [LmdbJava](https://github.com/lmdbjava/lmdbjava) project instead.** This artifact is a dependency of LmdbJava.
3110

32-
### Repository
11+
Available from [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.lmdbjava%22%20AND%20a%3A%22native%22) and [Central Portal Snapshots](https://central.sonatype.com/repository/maven-snapshots/org/lmdbjava/native).
3312

34-
[LmdbJava](https://github.com/lmdbjava/lmdbjava) shades inside its JAR all of
35-
the system libraries produced by this project. As such, end users typically have
36-
no need to refer to any artifacts produced by this project.
13+
### Version Management
3714

38-
### Snapshots
15+
Update all dependency and plugin versions:
16+
```bash
17+
mvn versions:update-properties
18+
```
3919

40-
GitHub Actions automatically publishes snapshot releases to the
41-
[OSS Sonatype Snapshots Repository](https://oss.sonatype.org/content/repositories/snapshots/org/lmdbjava/lmdbjava-native-parent/).
42-
43-
### Support
44-
45-
Please [open a GitHub issue](https://github.com/lmdbjava/native/issues) if you
46-
have any questions.
47-
48-
### Contributing
49-
50-
Contributions are welcome! Please see the LmdbJava project's
51-
[Contributing Guidelines](https://github.com/lmdbjava/lmdbjava/blob/master/CONTRIBUTING.md).
20+
Update the LMDB version by editing `LMDB_VERSION` in `fetch-native-libs.sh`.
5221

5322
### Releasing
5423

55-
Please see the [Acegi Standard Project Release Instructions](https://github.com/acegi/acegi-standard-project#performing-a-release).
24+
GitHub Actions will perform an official release whenever a developer executes `mvn release:clean release:prepare`.
5625

5726
### License
58-
LMDB (and this repository for simplicity) is licensed under
59-
[The OpenLDAP Public License](http://www.openldap.org/software/release/license.html).
27+
28+
LMDB (and this repository for simplicity) is licensed under [The OpenLDAP Public License](http://www.openldap.org/software/release/license.html).

fetch-native-libs.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
#
3+
# Copyright © 2016-2025 The LmdbJava Open Source Project
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
set -euo pipefail
19+
20+
LMDB_VERSION="0.9.33"
21+
DEST="${DEST:-src/main/resources/org/lmdbjava/native}"
22+
TMP=$(mktemp -d)
23+
trap "rm -rf $TMP" EXIT
24+
25+
mkdir -p "$DEST"
26+
27+
# Arch Linux x86_64
28+
if [ ! -f "$DEST/x86_64-linux-gnu.so" ]; then
29+
curl -sL "https://archive.archlinux.org/packages/l/lmdb/lmdb-${LMDB_VERSION}-1-x86_64.pkg.tar.zst" -o "$TMP/x64.tar.zst"
30+
zstd -d "$TMP/x64.tar.zst" -o "$TMP/x64.tar"
31+
tar xf "$TMP/x64.tar" -C "$TMP" usr/lib/liblmdb.so --strip-components=2
32+
mv -f "$TMP/liblmdb.so" "$DEST/x86_64-linux-gnu.so"
33+
fi
34+
35+
# Arch Linux ARM aarch64
36+
if [ ! -f "$DEST/aarch64-linux-gnu.so" ]; then
37+
curl -sL "http://mirror.archlinuxarm.org/aarch64/extra/lmdb-${LMDB_VERSION}-1-aarch64.pkg.tar.xz" -o "$TMP/arm64.tar.xz"
38+
tar xf "$TMP/arm64.tar.xz" -C "$TMP" usr/lib/liblmdb.so --strip-components=2
39+
mv -f "$TMP/liblmdb.so" "$DEST/aarch64-linux-gnu.so"
40+
fi
41+
42+
# Homebrew macOS x86_64
43+
if [ ! -f "$DEST/x86_64-macos-none.so" ]; then
44+
curl -sL "https://mirrors.sustech.edu.cn/homebrew-bottles/bottles/lmdb-${LMDB_VERSION}.sonoma.bottle.tar.gz" -o "$TMP/brew-x64.tar.gz"
45+
tar xzf "$TMP/brew-x64.tar.gz" -C "$TMP" lmdb/${LMDB_VERSION}/lib/liblmdb.dylib --strip-components=3
46+
mv -f "$TMP/liblmdb.dylib" "$DEST/x86_64-macos-none.so"
47+
fi
48+
49+
# Homebrew macOS arm64
50+
if [ ! -f "$DEST/aarch64-macos-none.so" ]; then
51+
curl -sL "https://mirrors.sustech.edu.cn/homebrew-bottles/bottles/lmdb-${LMDB_VERSION}.arm64_sonoma.bottle.tar.gz" -o "$TMP/brew-arm.tar.gz"
52+
tar xzf "$TMP/brew-arm.tar.gz" -C "$TMP" lmdb/${LMDB_VERSION}/lib/liblmdb.dylib --strip-components=3
53+
mv -f "$TMP/liblmdb.dylib" "$DEST/aarch64-macos-none.so"
54+
fi
55+
56+
# MSYS2 Windows x86_64
57+
if [ ! -f "$DEST/x86_64-windows-gnu.dll" ]; then
58+
curl -sL "https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-lmdb-${LMDB_VERSION}-1-any.pkg.tar.zst" -o "$TMP/win.tar.zst"
59+
zstd -d "$TMP/win.tar.zst" -o "$TMP/win.tar"
60+
tar xf "$TMP/win.tar" -C "$TMP" mingw64/bin/liblmdb.dll --strip-components=2
61+
mv -f "$TMP/liblmdb.dll" "$DEST/x86_64-windows-gnu.dll"
62+
fi
63+
64+
ls -lh "$DEST"

linux-x86_64/pom.xml

Lines changed: 0 additions & 64 deletions
This file was deleted.

linux-x86_64/src/main/java/org/lmdbjava/Holder.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

linux-x86_64/src/main/java/org/lmdbjava/package-info.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

lmdb

Lines changed: 0 additions & 1 deletion
This file was deleted.

osx-x86_64/pom.xml

Lines changed: 0 additions & 72 deletions
This file was deleted.

osx-x86_64/src/main/java/org/lmdbjava/Holder.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)