Search

gradle ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŠธ ๋งŒ๋“ค๊ธฐ

gradle ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ ์Šคํฌ๋ฆฝํŠธ ๋งŒ๋“ค๊ธฐ

git clone

git clone https://github.com/ALOHA-CLASS/HelloSpringBoot.git
Bash
๋ณต์‚ฌ

build.gradle

plugins { id 'java' id 'war' id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' } group = 'com.joeun' version = '0.0.1-SNAPSHOT' java { sourceCompatibility = '17' } configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.projectlombok:lombok' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.named('test') { useJUnitPlatform() } bootWar { archiveFileName = 'hello-application.war' }
Bash
๋ณต์‚ฌ

start.sh

#!/bin/bash # ๋ณ€์ˆ˜ ์„ ์–ธ (=) ์•ž๋’ค๋กœ ๊ณต๋ฐฑโŒ PROJECT_NAME=hello-application WORKSPACE=/home/joeun/workspace REPOSITORY=/home/joeun/workspace/HelloSpringBoot DEPLOY_PATH=/home/joeun/workspace/HelloSpringBoot/build/libs # ํ”„๋กœ์ ํŠธ ๊ฒฝ๋กœ๋กœ ์ด๋™ echo "> ${REPOSITORY} ๋กœ ์ด๋™" cd $REPOSITORY # GIT PULL ์ง„ํ–‰ echo "> GIT PULL" if git pull; then echo "> git pull ์„ฑ๊ณต" else echo "> git pull ์‹คํŒจ" exit 1 fi # ๋นŒ๋“œ ์‹œ์ž‘ echo "> gradle clean build" ./gradlew clean build # ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„ pid(ํ”„๋กœ์„ธ์Šค ์•„์ด๋””) ํ™•์ธ CURRENT_PID=$(pgrep -f "${PROJECT_NAME}.war") echo "> ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„ pid : ${CURRENT_PID}" # ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„ ์žˆ๋Š”์ง€ ํ™•์ธ if [ -z "$CURRENT_PID" ]; then echo "> ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„ ์—†์Œ" else echo "> ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ์„œ๋ฒ„ ์ข…๋ฃŒ" kill -15 $CURRENT_PID sleep 5 fi # ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์žฌ๋ฐฐํฌ echo "> ์ƒˆ๋กœ์šด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฐฐํฌ" cd $DEPLOY_PATH nohup java -jar "${PROJECT_NAME}.war" &
Bash
๋ณต์‚ฌ