Skip to content

Commit 8ad9c6c

Browse files
committed
jme3-android-native
0 parents  commit 8ad9c6c

32 files changed

Lines changed: 2554 additions & 0 deletions
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#! /bin/bash
2+
set -euo pipefail
3+
4+
## Upload a deployment
5+
## from the "org.jmonkeyengine" namespace in Sonatype's OSSRH staging area
6+
## to Sonatype's Central Publisher Portal
7+
## so the deployment can be tested and then published or dropped.
8+
9+
## IMPORTANT: The upload request must originate
10+
## from the IP address used to stage the deployment to the staging area!
11+
12+
# The required -p and -u flags on the command line
13+
# specify the password and username components of a "user token"
14+
# generated using the web interface at https://central.sonatype.com/account
15+
16+
while getopts p:u: flag
17+
do
18+
case "${flag}" in
19+
p) centralPassword=${OPTARG};;
20+
u) centralUsername=${OPTARG};;
21+
esac
22+
done
23+
24+
# Combine both components into a base64 "user token"
25+
# suitable for the Authorization header of a POST request:
26+
27+
token=$(printf %s:%s "${centralUsername}" "${centralPassword}" | base64)
28+
29+
# Send a POST request to upload the deployment:
30+
31+
server='ossrh-staging-api.central.sonatype.com'
32+
endpoint='/manual/upload/defaultRepository/org.jmonkeyengine'
33+
url="https://${server}${endpoint}"
34+
35+
statusCode=$(curl "${url}" \
36+
--no-progress-meter \
37+
--output postData1.txt \
38+
--write-out '%{response_code}' \
39+
--request POST \
40+
--header 'accept: */*' \
41+
--header "Authorization: Bearer ${token}" \
42+
--data '')
43+
44+
echo "Status code = ${statusCode}"
45+
echo 'Received data:'
46+
cat postData1.txt
47+
echo '[EOF]'
48+
49+
# Retry if the default repo isn't found (status=400).
50+
51+
if [ "${statusCode}" == "400" ]; then
52+
echo "Will retry after 30 seconds."
53+
sleep 30
54+
55+
statusCode2=$(curl "${url}" \
56+
--no-progress-meter \
57+
--output postData2.txt \
58+
--write-out '%{response_code}' \
59+
--request POST \
60+
--header 'accept: */*' \
61+
--header "Authorization: Bearer ${token}" \
62+
--data '')
63+
64+
echo "Status code = ${statusCode2}"
65+
echo 'Received data:'
66+
cat postData2.txt
67+
echo '[EOF]'
68+
fi
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
#############################################
3+
#
4+
# Usage
5+
# uploadAllToMaven path/of/dist/maven $GITHUB_PACKAGE_REPOSITORY user password
6+
#
7+
#############################################
8+
root="`dirname ${BASH_SOURCE[0]}`"
9+
10+
set -e
11+
function uploadToMaven {
12+
file="$1"
13+
destfile="$2"
14+
repourl="$3"
15+
user="$4"
16+
password="$5"
17+
srcrepo="$6"
18+
license="$7"
19+
20+
auth=""
21+
22+
if [ "$user" != "token" ];
23+
then
24+
echo "Upload with username $user and password"
25+
auth="-u$user:$password"
26+
else
27+
echo "Upload with token"
28+
auth="-H \"Authorization: token $password\""
29+
fi
30+
31+
cmd="curl -T \"$file\" $auth \
32+
\"$repourl/$destfile\" \
33+
-vvv"
34+
35+
echo "Run $cmd"
36+
eval "$cmd"
37+
}
38+
export -f uploadToMaven
39+
40+
function uploadAllToMaven {
41+
path="$1"
42+
cdir="$PWD"
43+
cd "$path"
44+
files="`find . \( -name "*.jar" -o -name "*.pom" \) -type f -print`"
45+
IFS="
46+
"
47+
set -f
48+
for art in $files; do
49+
art="${art:2}"
50+
uploadToMaven "$art" "$art" ${@:2}
51+
done
52+
set +f
53+
unset IFS
54+
55+
cd "$cdir"
56+
}

.github/workflows/build.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Build jmeAndroidNatives
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
pull_request:
9+
release:
10+
types: [published]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
BuildAndroidNatives:
17+
name: Build Android natives
18+
runs-on: ubuntu-latest
19+
container:
20+
image: ghcr.io/cirruslabs/android-sdk:36-ndk
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 1
27+
28+
- name: Setup Java
29+
uses: actions/setup-java@v5
30+
with:
31+
distribution: temurin
32+
java-version: '21'
33+
34+
- name: Install CMake
35+
run: |
36+
apt-get update
37+
apt-get install -y cmake
38+
cmake --version
39+
40+
- name: Validate the Gradle wrapper
41+
uses: gradle/actions/wrapper-validation@v6.1.0
42+
43+
- name: Build
44+
run: |
45+
export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION"
46+
version_args=""
47+
if [ "$GITHUB_EVENT_NAME" = "release" ]; then
48+
version_args="-PreleaseVersion=${GITHUB_REF_NAME#v}"
49+
fi
50+
./gradlew $version_args --no-daemon assemble --console=plain --stacktrace
51+
52+
- name: Upload Maven-ready jar outputs
53+
uses: actions/upload-artifact@v7.0.1
54+
with:
55+
name: build-libs
56+
path: build/libs
57+
58+
PublishSnapshot:
59+
name: Deploy Snapshot
60+
needs: [BuildAndroidNatives]
61+
runs-on: ubuntu-latest
62+
container:
63+
image: ghcr.io/cirruslabs/android-sdk:36-ndk
64+
if: github.event_name == 'push' && (github.ref_name == 'master' || github.ref_name == 'main')
65+
permissions:
66+
contents: read
67+
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v6
71+
with:
72+
fetch-depth: 1
73+
74+
- name: Setup Java
75+
uses: actions/setup-java@v5
76+
with:
77+
distribution: temurin
78+
java-version: '21'
79+
80+
- name: Install CMake
81+
run: |
82+
apt-get update
83+
apt-get install -y cmake
84+
cmake --version
85+
86+
- name: Publish snapshot to Sonatype
87+
run: |
88+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
89+
then
90+
echo "Configure the following secrets to enable uploading to Sonatype:"
91+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
92+
else
93+
export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION"
94+
./gradlew publishMavenPublicationToSNAPSHOTRepository \
95+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
96+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
97+
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
98+
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
99+
--console=plain --stacktrace
100+
fi
101+
102+
PublishRelease:
103+
name: Deploy Release
104+
needs: [BuildAndroidNatives]
105+
runs-on: ubuntu-latest
106+
container:
107+
image: ghcr.io/cirruslabs/android-sdk:36-ndk
108+
if: github.event_name == 'release'
109+
permissions:
110+
contents: read
111+
packages: write
112+
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@v6
116+
with:
117+
fetch-depth: 1
118+
119+
- name: Setup Java
120+
uses: actions/setup-java@v5
121+
with:
122+
distribution: temurin
123+
java-version: '21'
124+
125+
- name: Install CMake
126+
run: |
127+
apt-get update
128+
apt-get install -y cmake
129+
cmake --version
130+
131+
- name: Stage release artifacts for Central
132+
run: |
133+
if [ "${{ secrets.CENTRAL_PASSWORD }}" = "" ];
134+
then
135+
echo "Configure the following secrets to enable uploading to Sonatype:"
136+
echo "CENTRAL_PASSWORD, CENTRAL_USERNAME, SIGNING_KEY, SIGNING_PASSWORD"
137+
else
138+
export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION"
139+
./gradlew publishMavenPublicationToCentralRepository \
140+
-PcentralPassword=${{ secrets.CENTRAL_PASSWORD }} \
141+
-PcentralUsername=${{ secrets.CENTRAL_USERNAME }} \
142+
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
143+
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
144+
-PreleaseVersion=${GITHUB_REF_NAME#v} \
145+
--console=plain --stacktrace
146+
.github/actions/tools/uploadToCentral.sh \
147+
-p '${{ secrets.CENTRAL_PASSWORD }}' \
148+
-u '${{ secrets.CENTRAL_USERNAME }}'
149+
fi
150+
151+
- name: Publish to GitHub Packages
152+
run: |
153+
export ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION"
154+
if [ "${{ secrets.SIGNING_PASSWORD }}" = "" ];
155+
then
156+
./gradlew publishMavenPublicationToDistRepository \
157+
-PreleaseVersion=${GITHUB_REF_NAME#v} \
158+
--console=plain --stacktrace
159+
else
160+
./gradlew publishMavenPublicationToDistRepository \
161+
-PsigningKey='${{ secrets.SIGNING_KEY }}' \
162+
-PsigningPassword='${{ secrets.SIGNING_PASSWORD }}' \
163+
-PreleaseVersion=${GITHUB_REF_NAME#v} \
164+
--console=plain --stacktrace
165+
fi
166+
167+
source .github/actions/tools/uploadToMaven.sh
168+
registry="https://maven.pkg.github.com/$GITHUB_REPOSITORY"
169+
echo "Deploy to github package registry $registry"
170+
uploadAllToMaven build/dist/maven/ "$registry" "token" "${{ secrets.GITHUB_TOKEN }}"

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gradle/
2+
build/
3+
out/
4+
*.iml
5+
/.idea/
6+
7+
# Native build scratch space; checked-in fallback binaries live under prebuilt/android.
8+
/.cxx/

LICENSE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2009-2026 jMonkeyEngine.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions
5+
are met:
6+
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in
12+
the documentation and/or other materials provided with the
13+
distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived
17+
from this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30+
OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# jmeAndroidNatives
2+
3+
Android native libraries used by jMonkeyEngine.
4+
5+
This project is extracted from the old `jme3-android-native` module so the Android natives can have their own build and release cycle. The published Maven artifact intentionally keeps the existing artifact id:
6+
7+
```groovy
8+
implementation "org.jmonkeyengine:jme3-android-native:<version>"
9+
```
10+
11+
`./gradlew assemble` builds the native libraries from source and packages them into the jar. An Android NDK and CMake must be available.
12+
13+
Native build targets are configured in `gradle.properties`:
14+
15+
```properties
16+
androidAbis = arm64-v8a,x86_64
17+
androidPlatform = android-21
18+
```
19+
20+
Non-release builds use `baseVersion` from `gradle.properties` with `-SNAPSHOT` appended. GitHub release jobs pass `-PreleaseVersion` from the release tag.
21+
22+
The JNI headers in `src/native/headers` are the ABI contract with `jme3-android`.

0 commit comments

Comments
 (0)