Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成されるJavaファイルやJSONファイルのパスを変更 #47

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
build
compiler_bin
cobol_converted
json
app/src/main/java/cobol4j/aws/web/sample.java
app/src/main/java/cobol4j/aws/web/sampleController.java
app/src/main/java/cobol4j/aws/web/sampleRecord.java
54 changes: 36 additions & 18 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,35 @@ fun getGitManagedFiles(dir: File): FileTree {
}
}

val compilerBinDir = "${project.projectDir}/compiler_bin"
val libcobjJar = "${compilerBinDir}/lib/opensourcecobol4j/libcobj.jar"
val cobj = "${compilerBinDir}/bin/cobj"
val cobjApi = "${compilerBinDir}/bin/cobj-api"

// opensource COBOL 4J のビルドタスクを追加
tasks.register<Exec>("buildCompiler") {
group = "build"
description = "Build opensource COBOL 4J"

// 作業ディレクトリを指定
workingDir = file("${project.projectDir}/opensourcecobol4j/")
val opensourcecobol4jDir = file("${project.projectDir}/opensourcecobol4j/")

// 入力ファイルと出力ファイルを指定
inputs.files(getGitManagedFiles(file("${project.projectDir}/opensourcecobol4j/")))
workingDir = opensourcecobol4jDir

// 入力ファイルを指定
inputs.files(getGitManagedFiles(opensourcecobol4jDir))

// 出力ファイルを指定
outputs.files(
file("${project.projectDir}/compiler_bin/lib/opensourcecobol4j/libcobj.jar"),
file("${project.projectDir}/compiler_bin/bin/cobj"),
file("${project.projectDir}/compiler_bin/bin/cobj-api"),
file(libcobjJar),
file(cobj),
file(cobjApi),
)

// 実行コマンドを指定
commandLine("sh", "-c", """
mkdir -p ${project.projectDir}/compiler_bin &&
./configure --prefix=${project.projectDir}/compiler_bin &&
mkdir -p ${compilerBinDir} &&
./configure --prefix=${compilerBinDir} &&
make &&
make install
""".trimIndent())
Expand All @@ -45,25 +54,34 @@ tasks.register<Exec>("buildCobol") {
group = "build"
description = "Build COBOL source files"

val cobolDir = "${project.projectDir}/cobol/"
val javaDir = "${project.projectDir}/app/src/main/java/cobol4j/aws/web/"
val jsonDir = "${project.projectDir}/json"

// 作業ディレクトリを指定
workingDir = file("${project.projectDir}/cobol/")
workingDir = file(cobolDir)

// 入力ファイルと出力ファイルを指定
inputs.files(
file("${project.projectDir}/compiler_bin/lib/opensourcecobol4j/libcobj.jar"),
file("${project.projectDir}/compiler_bin/bin/cobj"),
file("${project.projectDir}/compiler_bin/bin/cobj-api"),
fileTree("${project.projectDir}/cobol"),
file(libcobjJar),
file(cobj),
file(cobjApi),
fileTree(cobolDir),
)

// 出力ファイルを指定
outputs.files(
fileTree("${project.projectDir}/cobol_converted"),
file("${javaDir}/sample.java"),
file("${javaDir}/sampleController.java"),
file("${javaDir}/sampleRecord.java"),
file("${jsonDir}/info_sample.json"),
)

commandLine("sh", "-c", """
mkdir -p ${project.projectDir}/cobol_converted &&
${project.projectDir}/compiler_bin/bin/cobj -info-json-dir=${project.projectDir}/cobol_converted -C *.cbl &&
mv *.java ${project.projectDir}/cobol_converted &&
CLASSPATH=:${project.projectDir}/compiler_bin/lib/opensourcecobol4j/libcobj.jar ${project.projectDir}/compiler_bin/bin/cobj-api --output-dir=${project.projectDir}/cobol_converted ${project.projectDir}/cobol_converted/*.json
mkdir -p ${jsonDir} &&
${cobj} -info-json-dir=${jsonDir} -C *.cbl &&
mv *.java ${javaDir} &&
CLASSPATH=:${libcobjJar} ${cobjApi} --output-dir=${javaDir} ${jsonDir}/info_sample.json
""")
}

Expand Down
2 changes: 1 addition & 1 deletion server/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ plugins {
}

rootProject.name = "cobol4j-aws-web"
include("app")
//include("app")