Skip to content

Commit

Permalink
Merge pull request #3 from JoJoonBalSsa/build_jar
Browse files Browse the repository at this point in the history
jar building with gradle added
  • Loading branch information
namaek2 authored Aug 4, 2024
2 parents e32f7ea + 5a934c3 commit 932068f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/main/kotlin/io/namaek2/plugins/services/RunPyScripts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RunPyScripts(private var javaFilesPath: String, private var outputFolder :
copyScripts()
if(compareFileHashes()) {
executePythonScript()
runGradle()
}
deleteTempFiles()
}
Expand Down Expand Up @@ -146,6 +147,42 @@ class RunPyScripts(private var javaFilesPath: String, private var outputFolder :
}
}

private fun runGradle() {
try {
// 프로세스 빌더를 생성합니다.
val processBuilder = ProcessBuilder("gradle", "jar")

processBuilder.directory(File(outputFolder))

// 프로세스의 출력을 캡처할 수 있도록 리디렉션합니다.
processBuilder.redirectErrorStream(true)

try {
// 프로세스를 시작합니다.
val process = processBuilder.start()
println("jar build started")
// 프로세스의 출력을 읽습니다.
val reader = BufferedReader(InputStreamReader(process.inputStream))
var line: String?
while (reader.readLine().also { line = it } != null) {
println("gradle output: $line")
}

// 프로세스가 종료될 때까지 대기합니다.
val exitCode = process.waitFor()
if (exitCode == 0) {
println("jar builded successfully")
} else {
println("Error in jar building : $exitCode")
}
} catch (e: InterruptedException) {
e.printStackTrace()
}
} catch (e: Exception) {
println("Error in jar building process: ${e.message}")
}
}

private fun deleteTempFiles() {
for (scriptName in scriptNames) {
val tempPath = File(tempFilePath + "/$scriptName.py")

Check notice on line 188 in src/main/kotlin/io/namaek2/plugins/services/RunPyScripts.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

String concatenation that can be converted to string template

'String' concatenation can be converted to a template
Expand Down

0 comments on commit 932068f

Please sign in to comment.