Files
eru/build.sh

112 lines
2.9 KiB
Bash

#!/bin/bash
# Build script for BCV Exchange Rate Plugin - iDempiere v10
# Run this on the server where iDempiere v10 is installed
set -e
# Configuration
IDEMPIERE_HOME="${IDEMPIERE_HOME:-/opt/idempiere-server}"
PLUGIN_DIR="$(dirname "$0")"
DIST_DIR="$PLUGIN_DIR/dist"
BUILD_DIR="$PLUGIN_DIR/build"
echo "=== BCV Exchange Rate Plugin Build ==="
echo "iDempiere Home: $IDEMPIERE_HOME"
# Find required JARs
BASE_JAR=$(find "$IDEMPIERE_HOME/plugins" -name "org.adempiere.base_*.jar" | head -1)
JSON_JAR=$(find "$IDEMPIERE_HOME/plugins" -name "json_*.jar" | head -1)
OSGI_JAR=$(find "$IDEMPIERE_HOME/plugins" -name "org.osgi.framework_*.jar" | head -1)
COMPONENT_ANNOTATIONS_JAR=$(find "$IDEMPIERE_HOME/plugins" -name "org.osgi.service.component.annotations_*.jar" | head -1)
# Check required JARs
if [ -z "$BASE_JAR" ]; then
echo "ERROR: org.adempiere.base JAR not found"
exit 1
fi
if [ -z "$JSON_JAR" ]; then
echo "ERROR: json JAR not found"
exit 1
fi
# If OSGi framework JAR not found, try to use the annotations from the base JAR
if [ -z "$OSGI_JAR" ]; then
echo "WARNING: org.osgi.framework JAR not found, checking if it's in base JAR"
fi
echo "Base JAR: $BASE_JAR"
echo "JSON JAR: $JSON_JAR"
# Create directories
mkdir -p "$DIST_DIR"
mkdir -p "$BUILD_DIR"
# Find Java
JAVA_HOME="${JAVA_HOME:-$(dirname $(dirname $(readlink -f $(which java))))}"
JAVAC="$JAVA_HOME/bin/javac"
JAR="$JAVA_HOME/bin/jar"
if [ ! -f "$JAVAC" ]; then
echo "ERROR: javac not found. Please set JAVA_HOME"
exit 1
fi
echo "Using javac: $JAVAC"
# Build classpath
CLASSPATH="$BASE_JAR:$JSON_JAR"
if [ -n "$OSGI_JAR" ]; then
CLASSPATH="$CLASSPATH:$OSGI_JAR"
fi
if [ -n "$COMPONENT_ANNOTATIONS_JAR" ]; then
CLASSPATH="$CLASSPATH:$COMPONENT_ANNOTATIONS_JAR"
fi
# Find all Java source files
SOURCES=$(find "$PLUGIN_DIR/src" -name "*.java")
SOURCE_COUNT=$(echo "$SOURCES" | wc -l)
echo "Found $SOURCE_COUNT source files"
# Compile
echo "Compiling..."
$JAVAC -cp "$CLASSPATH" \
-d "$BUILD_DIR" \
-source 11 -target 11 \
$SOURCES
if [ $? -ne 0 ]; then
echo "ERROR: Compilation failed"
exit 1
fi
echo "Compilation successful"
# Create JAR
echo "Creating JAR..."
$JAR cfm "$DIST_DIR/com.venezuela.bcvrate.jar" "$PLUGIN_DIR/META-INF/MANIFEST.MF" \
-C "$BUILD_DIR" .
if [ $? -ne 0 ]; then
echo "ERROR: JAR creation failed"
exit 1
fi
JAR_SIZE=$(du -h "$DIST_DIR/com.venezuela.bcvrate.jar" | cut -f1)
echo "JAR created: $DIST_DIR/com.venezuela.bcvrate.jar ($JAR_SIZE)"
# Copy to iDempiere plugins directory
echo "Copying to iDempiere plugins..."
cp "$DIST_DIR/com.venezuela.bcvrate.jar" "$IDEMPIERE_HOME/plugins/"
echo ""
echo "=== Build Complete ==="
echo "JAR installed at: $IDEMPIERE_HOME/plugins/com.venezuela.bcvrate.jar"
echo ""
echo "Next steps:"
echo "1. Restart iDempiere server"
echo "2. Check bundle status in Felix console: felix:ls | grep bcvrate"
echo "3. Create AD_Process via UI (if not done)"
echo "4. Add process to menu"
echo "5. Test the process"