-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·63 lines (51 loc) · 1.61 KB
/
compile.sh
File metadata and controls
executable file
·63 lines (51 loc) · 1.61 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Variables
SRC_DIR="Musica/src"
BIN_DIR="bin"
OUTPUT_DIR="output"
JAR_NAME="musica.jar"
MANIFEST_FILE="Musica/MANIFEST.MF"
MYSQL_DRIVER_JAR="mysql-connector-j-8.4.0.jar"
# Crear directorios si no existen
mkdir -p "$BIN_DIR"
mkdir -p "$OUTPUT_DIR"
# Eliminar el archivo JAR existente si existe
if [ -f "$OUTPUT_DIR/$JAR_NAME" ]; then
echo "Eliminando el archivo JAR existente: $OUTPUT_DIR/$JAR_NAME"
rm "$OUTPUT_DIR/$JAR_NAME"
fi
# Limpiar el directorio bin/ si existe
if [ -d "$BIN_DIR" ]; then
echo "Limpiando el directorio bin/"
rm -rf "$BIN_DIR/*"
fi
# Compilar los archivos .java
echo "Compilando los archivos Java..."
javac -d "$BIN_DIR" $(find "$SRC_DIR" -name "*.java")
# Verificar si la compilación fue exitosa
if [ $? -ne 0 ]; then
echo "Error en la compilación. Abortando."
exit 1
fi
# Copiar los recursos al directorio bin/
echo "Copiando recursos..."
cp -r "$SRC_DIR/canciones/swing/res" "$BIN_DIR/canciones/swing/"
# Extraer el contenido del driver de MySQL al directorio bin/
echo "Incluyendo el driver de MySQL..."
cd "$BIN_DIR"
jar xf "../Musica/libs/$MYSQL_DRIVER_JAR"
cd ..
# Crear el JAR ejecutable incluyendo todas las clases y recursos
echo "Creando el archivo JAR ejecutable..."
jar cfm "$OUTPUT_DIR/$JAR_NAME" "$MANIFEST_FILE" -C "$BIN_DIR" .
# Verificar si el JAR fue creado exitosamente
if [ $? -eq 0 ]; then
echo "El archivo JAR se ha creado exitosamente en $OUTPUT_DIR/$JAR_NAME"
else
echo "Error al crear el archivo JAR."
exit 1
fi
# Limpiar el directorio bin/
echo "Limpiando el directorio bin/"
rm -rf "$BIN_DIR"
echo "Compilación y empaquetado completados."