generated from arafkarsh/ms-springboot-324-java-22-jakarta-ee-10
-
Notifications
You must be signed in to change notification settings - Fork 2
/
compile
executable file
·79 lines (79 loc) · 4.54 KB
/
compile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
# -------------------------------------------------------------------------------------------
# @author: Araf Karsh Hamid
# -------------------------------------------------------------------------------------------
# Developer Local Compile Process
# ===========================================================================================
# 1. Clean up the target folder
# 2. Generate the Build Number (from git commit count) and Build Date
# 3. Build the Service
# 4. Copy the jar file to the Lib Folder
# 5. Start the Service using ./run script and then test it with ./test script
#
# After the Successful build and Startup of the Service, It should show the Build No. & Date
# -------------------------------------------------------------------------------------------
SERVICE=`getServiceName`
CONTAINER=`getServiceName 4`
ORG=`getServiceName 1`
echo "---------------------------------------------------------------------------------------"
echo "Compiling $ORG/$SERVICE Microservice"
echo "---------------------------------------------------------------------------------------"
echo "Changing Logback Log File Name: /tmp/$SERVICE-server.%d{yyyy-MM-dd}.%i.log"
echo "---------------------------------------------------------------------------------------"
sed -i -r "s/microservice/$SERVICE/g" src/main/resources/logback.xml
sed -i -r "s/microservice/$SERVICE/g" src/main/resources/logback-test.xml
echo "Clean up the target folder: mvn clean"
echo "---------------------------------------------------------------------------------------"
mvn clean
# -------------------------------------------------------------------------------------------
echo "Git Commit Count = "`git rev-list HEAD --count`
echo "---------------------------------------------------------------------------------------"
generateBuildNumber $SERVICE
# -------------------------------------------------------------------------------------------
echo "Build the $ORG/$SERVICE Microservice : mvn -e package"
echo "---------------------------------------------------------------------------------------"
mvn -e package
mvnCompRV=$?
# -------------------------------------------------------------------------------------------
# Remove this file
rm target/ai-service*?.?.?.jar
if [ $mvnCompRV == 0 ]
then
echo "---------------------------------------------------------------------------------------"
echo "Compiling Service > $ORG/$SERVICE :: SUCCESS"
echo "---------------------------------------------------------------------------------------"
echo "Copy the Fat and Thin jar files and the libs to the Docker Directory (src/docker)"
#cp target/*service*-spring-boot.jar src/docker/$CONTAINER-spring-boot.jar
#cp target/*service*?.?.?.jar src/docker/$CONTAINER-thin.jar
#cp target/libs/* src/docker/libs/
echo "Copy the application.properties File to the Docker Directory (src/docker)"
cp src/main/resources/application.properties src/docker/
cp src/main/resources/application-dev.properties src/docker/
cp src/main/resources/application-staging.properties src/docker/
cp src/main/resources/application-prod.properties src/docker/
cp src/main/resources/application.properties .
cp src/main/resources/application-dev.properties .
cp src/main/resources/application-staging.properties .
cp src/main/resources/application-prod.properties .
echo "---------------------------------------------------------------------------------------"
echo "Building the Cocntainer for $ORG/$SERVICE Service ..... "
echo "---------------------------------------------------------------------------------------"
cd src/docker
# build
echo "---------------------------------------------------------------------------------------"
echo "$SERVICE Microservice Build Process Completed Successfully! ........... "
echo "---------------------------------------------------------------------------------------"
echo "Start the Service using "
echo " run (Run the SpringBoot App) OR"
echo " cd src/docker"
echo " start (Start the Container)"
echo "Then to test it with"
echo " test (To Test the SpringBoot App)"
echo "---------------------------------------------------------------------------------------"
echo "After the Successful build and Startup of the Service, It should show the Build No. & Date"
echo "---------------------------------------------------------------------------------------"
else
echo "---------------------------------------------------------------------------------------"
echo "Compiling Service > $ORG/$SERVICE :: FAILED!!!"
echo "---------------------------------------------------------------------------------------"
fi