Skip to content

Commit d11f1a8

Browse files
committed
feat: add JAR exclusion handling in native build script
1 parent 6b64706 commit d11f1a8

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

β€Žbindings/python/scripts/build-native.shβ€Ž

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ NC='\033[0m'
2020
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2121
PY_BINDINGS_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
2222
DIST_DIR="$PY_BINDINGS_DIR/dist"
23+
JAR_EXCLUSIONS_FILE="$SCRIPT_DIR/jar_exclusions.txt"
2324

2425
# Parameters
2526
PLATFORM="${1:-}"
@@ -37,6 +38,39 @@ echo -e "${CYAN}πŸ”¨ Native build for platform: ${YELLOW}${PLATFORM}${NC}"
3738
echo -e "${CYAN}πŸ“¦ Package: ${YELLOW}${PACKAGE_NAME}${NC}"
3839
echo -e "${CYAN}πŸ“Œ ArcadeDB tag: ${YELLOW}${ARCADEDB_TAG}${NC}"
3940

41+
count_jars() {
42+
find "$1" -maxdepth 1 -name "*.jar" -type f | wc -l | awk '{print $1}'
43+
}
44+
45+
apply_jar_exclusions() {
46+
local jars_dir="$1"
47+
local exclusions_file="$2"
48+
local pattern
49+
local jar_path
50+
51+
if [[ ! -f "$exclusions_file" ]]; then
52+
echo -e "${RED}❌ JAR exclusion file not found: ${exclusions_file}${NC}"
53+
exit 1
54+
fi
55+
56+
echo -e "${CYAN}πŸ—‘οΈ Removing excluded JARs...${NC}"
57+
echo -e "${CYAN}πŸ“‹ JAR count before exclusion: ${YELLOW}$(count_jars "$jars_dir")${NC}"
58+
59+
while IFS= read -r pattern; do
60+
if [[ -z "$pattern" ]] || [[ "${pattern#\#}" != "$pattern" ]]; then
61+
continue
62+
fi
63+
64+
while IFS= read -r jar_path; do
65+
[[ -n "$jar_path" ]] || continue
66+
echo -e " - Removing: ${jar_path}"
67+
rm -f "$jar_path"
68+
done < <(find "$jars_dir" -maxdepth 1 -name "$pattern" -type f)
69+
done < "$exclusions_file"
70+
71+
echo -e "${CYAN}πŸ“‹ JAR count after exclusion: ${YELLOW}$(count_jars "$jars_dir")${NC}"
72+
}
73+
4074
# Check for Java (needed for jlink and JPype build)
4175
if ! command -v java &> /dev/null; then
4276
echo -e "${RED}❌ Java not found${NC}"
@@ -122,6 +156,9 @@ else
122156
echo -e "${GREEN}βœ… JARs downloaded to: $JARS_DIR${NC}"
123157
fi
124158

159+
# Always filter excluded jars, even when reusing an existing jars directory from a prior build.
160+
apply_jar_exclusions "$JARS_DIR" "$JAR_EXCLUSIONS_FILE"
161+
125162
# Step 2: Build minimal JRE with jlink
126163
echo -e "${CYAN}πŸ”¨ Building minimal JRE with jlink...${NC}"
127164

@@ -182,7 +219,7 @@ echo -e "${GREEN}βœ… JRE built${NC}"
182219
JRE_SIZE=$(du -sh "$PY_BINDINGS_DIR/temp_jre" | cut -f1)
183220
echo -e "${CYAN}πŸ“Š JRE size: ${YELLOW}${JRE_SIZE}${NC}"
184221

185-
# Step 3: Copy JRE to package (JARs already filtered and in place from artifact)
222+
# Step 3: Copy JRE to package (JARs already filtered in place)
186223
echo -e "${CYAN}πŸ“¦ Preparing package...${NC}"
187224

188225
# Build and copy JRE

0 commit comments

Comments
Β (0)