-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_java_engine_gradle.sh
More file actions
executable file
·46 lines (34 loc) · 1.41 KB
/
build_java_engine_gradle.sh
File metadata and controls
executable file
·46 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# Reliable build script for the Spoon-powered refactor engine.
#
# Author: Vaibhav-api-code
# Co-Author: Claude Code (https://claude.ai/code)
# Created: 2025-07-08
# Updated: 2025-07-23
# License: Mozilla Public License 2.0 (MPL-2.0)
set -Eeuo pipefail
trap 'echo "🔥 Build failed at line $LINENO" >&2' ERR
SCRIPT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
cd "${SCRIPT_DIR}"
LOG() { printf '• %s\n' "$*"; }
GRADLE_CMD=${GRADLE_CMD:-gradle}
LOG "Building Java refactoring engine with ${GRADLE_CMD} …"
if ! command -v "${GRADLE_CMD}" &>/dev/null; then
echo "Error: ${GRADLE_CMD} not found. Install Gradle or point GRADLE_CMD to ./gradlew" >&2
exit 1
fi
mkdir -p src/main/java
cp JavaRefactorWithSpoonV2.java src/main/java/
cp SpoonVariableRenamer.java src/main/java/ 2>/dev/null || true
"${GRADLE_CMD}" --quiet clean spoonJar
# Locate the freshly built JAR (Gradle may append version/hash)
JAR_PATH="$(find build/libs -maxdepth 1 -type f -name 'spoon-refactor-engine-*.jar' | head -n1 || true)"
if [[ -z "${JAR_PATH}" ]]; then
echo "Error: JAR not produced!" >&2
exit 1
fi
cp -f "${JAR_PATH}" spoon-refactor-engine.jar
LOG "✓ Built and staged ⇒ spoon-refactor-engine.jar"