Skip to content

Commit 2d2690e

Browse files
committed
Revert "refactor jar strategy from fatjar to jar by plateform"
This reverts commit 2cd82a3.
1 parent 2cd82a3 commit 2d2690e

4 files changed

Lines changed: 367 additions & 544 deletions

File tree

.github/workflows/build-and-publish.yml

Lines changed: 67 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,32 @@ permissions:
1010

1111
jobs:
1212
build-natives:
13-
name: Natives ${{ matrix.platform-id }} (${{ matrix.variant }})
13+
name: Build natives for ${{ matrix.platform }}-${{ matrix.arch }}
1414
strategy:
15-
fail-fast: false
1615
matrix:
1716
include:
1817
- os: ubuntu-latest
19-
platform-id: linux-x64
18+
platform: linux
19+
arch: x64
2020
lib: libflecs.so
21-
variant: release
22-
23-
- os: ubuntu-24.04-arm
24-
platform-id: linux-aarch64
25-
lib: libflecs.so
26-
variant: release
27-
28-
- os: windows-latest
29-
platform-id: windows-x64
30-
lib: flecs.dll
31-
variant: release
32-
33-
- os: macos-latest
34-
platform-id: macos-x64
35-
lib: libflecs.dylib
36-
variant: release
37-
compiler_target: x86_64-apple-macos10.15
38-
39-
- os: macos-latest
40-
platform-id: macos-aarch64
41-
lib: libflecs.dylib
42-
variant: release
43-
44-
- os: ubuntu-latest
45-
platform-id: linux-x64
46-
lib: libflecs.so
47-
variant: debug
48-
49-
- os: ubuntu-24.04-arm
50-
platform-id: linux-aarch64
51-
lib: libflecs.so
52-
variant: debug
53-
5421
- os: windows-latest
55-
platform-id: windows-x64
22+
platform: windows
23+
arch: x64
5624
lib: flecs.dll
57-
variant: debug
58-
59-
- os: macos-latest
60-
platform-id: macos-x64
25+
- os: macos-15
26+
platform: macos
27+
arch: x64
6128
lib: libflecs.dylib
62-
variant: debug
63-
compiler_target: x86_64-apple-macos10.15
64-
6529
- os: macos-latest
66-
platform-id: macos-aarch64
30+
platform: macos
31+
arch: aarch64
6732
lib: libflecs.dylib
68-
variant: debug
6933

7034
runs-on: ${{ matrix.os }}
7135

7236
steps:
73-
- uses: actions/checkout@v4
37+
- name: Checkout code
38+
uses: actions/checkout@v4
7439

7540
- name: Set up JDK 25
7641
uses: actions/setup-java@v4
@@ -86,48 +51,45 @@ jobs:
8651
8752
- name: Install GCC (Windows)
8853
if: runner.os == 'Windows'
89-
uses: msys2/setup-msys2@v2
90-
with:
91-
msystem: MINGW64
92-
install: mingw-w64-x86_64-gcc
54+
run: choco install mingw -y
9355

9456
- name: Grant execute permission for gradlew
9557
if: runner.os != 'Windows'
9658
run: chmod +x gradlew
9759

98-
- name: Compile native (${{ matrix.variant }})
60+
- name: Build natives
61+
run: ./gradlew compileFlecsNative -PNATIVE_ARCH=${{ matrix.platform }}-${{ matrix.arch }}
9962
shell: bash
100-
run: |
101-
EXTRA_ARGS=""
102-
if [ -n "${{ matrix.compiler_target }}" ]; then
103-
EXTRA_ARGS="-PCOMPILER_TARGET=${{ matrix.compiler_target }}"
104-
fi
105-
./gradlew \
106-
:compileFlecsNative-${{ matrix.platform-id }}-${{ matrix.variant }} \
107-
-PNATIVE_ARCH=${{ matrix.platform-id }} \
108-
$EXTRA_ARGS
10963

110-
- name: Verify native library
111-
shell: bash
64+
- name: Verify native library was built
11265
run: |
113-
FILE="build/natives/${{ matrix.platform-id }}/${{ matrix.variant }}/${{ matrix.lib }}"
114-
echo "Checking $FILE ..."
115-
if [ ! -f "$FILE" ]; then
116-
echo "❌ Not found: $FILE"; exit 1
66+
FILE_PATH="build/resources/main/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}"
67+
echo "Checking for native library at $FILE_PATH..."
68+
69+
if [ ! -f "$FILE_PATH" ]; then
70+
echo "Error: Native library not found!"
71+
exit 1
11772
fi
118-
SIZE=$(wc -c < "$FILE")
119-
echo "Size: $SIZE bytes"
120-
if [ "$SIZE" -lt 102400 ]; then
121-
echo "❌ Too small ($SIZE bytes, expected ≥ 102400)"; exit 1
73+
74+
FILE_SIZE=$(wc -c < "$FILE_PATH")
75+
MIN_SIZE=102400
76+
77+
echo "File size: $FILE_SIZE bytes"
78+
79+
if [ "$FILE_SIZE" -lt "$MIN_SIZE" ]; then
80+
echo "Error: File size is too small ($FILE_SIZE bytes). Expected at least $MIN_SIZE bytes."
81+
exit 1
12282
fi
123-
echo "✅ OK"
124-
ls -lh "$FILE"
12583
126-
- name: Upload native artifact
84+
echo "✓ File exists and size is valid."
85+
ls -la "$FILE_PATH"
86+
shell: bash
87+
88+
- name: Upload natives artifact
12789
uses: actions/upload-artifact@v4
12890
with:
129-
name: native-${{ matrix.platform-id }}-${{ matrix.variant }}
130-
path: build/natives/${{ matrix.platform-id }}/${{ matrix.variant }}/${{ matrix.lib }}
91+
name: natives-${{ matrix.platform }}-${{ matrix.arch }}
92+
path: build/resources/main/natives/${{ matrix.platform }}-${{ matrix.arch }}/${{ matrix.lib }}
13193
retention-days: 1
13294

13395
publish:
@@ -136,111 +98,63 @@ jobs:
13698
runs-on: ubuntu-latest
13799

138100
steps:
139-
- uses: actions/checkout@v4
101+
- name: Checkout code
102+
uses: actions/checkout@v4
140103

141104
- name: Set up JDK 25
142105
uses: actions/setup-java@v4
143106
with:
144107
java-version: '25'
145108
distribution: 'temurin'
146109

147-
- name: Download all native artifacts
110+
- name: Download all natives
148111
uses: actions/download-artifact@v4
149112
with:
150-
pattern: native-*
151113
path: downloaded-natives
152-
merge-multiple: false
153114

154-
- name: Place natives in build/natives/
155-
shell: bash
115+
- name: Debug downloaded artifacts
116+
run: |
117+
echo "Downloaded artifacts structure:"
118+
find downloaded-natives -type f
119+
120+
- name: Organize natives
156121
run: |
157-
echo "=== Downloaded artifacts ==="
158-
find downloaded-natives -type f | sort
159-
160-
for artifact_dir in downloaded-natives/native-*/; do
161-
basename=$(basename "$artifact_dir")
162-
rest=${basename#native-}
163-
variant=${rest##*-}
164-
platform=${rest%-$variant}
165-
166-
dest="build/natives/$platform/$variant"
167-
mkdir -p "$dest"
168-
cp "$artifact_dir"/* "$dest/"
169-
echo "✅ $platform/$variant → $dest"
122+
mkdir -p src/main/resources/natives
123+
124+
for artifact_dir in downloaded-natives/natives-*/; do
125+
platform_arch=$(basename "$artifact_dir" | sed 's/^natives-//')
126+
echo "Processing $platform_arch..."
127+
mkdir -p "src/main/resources/natives/$platform_arch"
128+
cp "$artifact_dir"/* "src/main/resources/natives/$platform_arch/"
170129
done
171130
172-
echo ""
173-
echo "=== Final tree ==="
174-
find build/natives -type f | sort
131+
echo "Final native libraries structure:"
132+
find src/main/resources/natives -type f
175133
176134
- name: Grant execute permission for gradlew
177135
run: chmod +x gradlew
178136

179-
- name: Build JAR (API + processor, sans natifs embarqués)
180-
run: ./gradlew :jar :sourcesJar :javadocJar -PskipNative
181-
182-
- name: Build all native JARs
183-
run: |
184-
./gradlew \
185-
:jarNatives-linux-x64-release \
186-
:jarNatives-linux-aarch64-release \
187-
:jarNatives-windows-x64-release \
188-
:jarNatives-macos-x64-release \
189-
:jarNatives-macos-aarch64-release \
190-
:jarNatives-linux-x64-debug \
191-
:jarNatives-linux-aarch64-debug \
192-
:jarNatives-windows-x64-debug \
193-
:jarNatives-macos-x64-debug \
194-
:jarNatives-macos-aarch64-debug \
195-
-PskipNative
137+
- name: Build final JAR with all natives
138+
run: ./gradlew jar -x compileFlecsNative
196139

197140
- name: Verify JAR contents
198-
shell: bash
199141
run: |
200142
VERSION=${GITHUB_REF_NAME#v}
201-
JAR="build/libs/flecs-java-$VERSION.jar"
202-
203-
echo "=== Main JAR: $JAR ==="
204-
jar tf "$JAR" | grep "natives/" | sort || echo "✅ Aucun natif embarqué (attendu)"
205-
143+
echo "Verifying JAR for version $VERSION..."
206144
echo ""
207-
echo "=== Native JARs ==="
208-
for f in build/libs/flecs-java-$VERSION-natives-*.jar; do
209-
[ -f "$f" ] || { echo "Aucun jar natif trouvé"; break; }
210-
echo "--- $(basename "$f") ---"
211-
jar tf "$f" | grep "natives/"
212-
done
213-
145+
echo "All natives in JAR:"
146+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/" | sort
214147
echo ""
215-
echo "Verifying all expected classifiers..."
216-
EXPECTED=(
217-
"natives-linux-x64"
218-
"natives-linux-aarch64"
219-
"natives-windows-x64"
220-
"natives-macos-x64"
221-
"natives-macos-aarch64"
222-
"natives-linux-x64-debug"
223-
"natives-linux-aarch64-debug"
224-
"natives-windows-x64-debug"
225-
"natives-macos-x64-debug"
226-
"natives-macos-aarch64-debug"
227-
)
228-
ALL_OK=true
229-
for classifier in "${EXPECTED[@]}"; do
230-
f="build/libs/flecs-java-$VERSION-$classifier.jar"
231-
if [ -f "$f" ]; then
232-
echo "✅ $classifier"
233-
else
234-
echo "❌ $classifier — MISSING"
235-
ALL_OK=false
236-
fi
237-
done
238-
$ALL_OK || exit 1
148+
149+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/linux-x64/libflecs.so" && echo "✓ Linux x64" || echo "✗ Linux x64 MISSING"
150+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/windows-x64/flecs.dll" && echo "✓ Windows x64" || echo "✗ Windows x64 MISSING"
151+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-x64/libflecs.dylib" && echo "✓ macOS x64" || echo "✗ macOS x64 MISSING"
152+
jar tf build/libs/flecs-java-$VERSION.jar | grep "natives/macos-aarch64/libflecs.dylib" && echo "✓ macOS ARM64" || echo "✗ macOS ARM64 MISSING"
239153
240154
- name: Publish to Maven Central
241155
env:
242156
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
243157
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
244158
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
245159
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
246-
run: ./gradlew :publishToSonatype :closeAndReleaseSonatypeStagingRepository -PskipNative
160+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository

0 commit comments

Comments
 (0)