|
| 1 | +plugins { |
| 2 | + id 'org.springframework.boot' version '3.4.0' |
| 3 | + id 'io.spring.dependency-management' version '1.1.6' |
| 4 | + id 'com.diffplug.spotless' version '6.22.0' |
| 5 | + id 'nu.studer.jooq' version '9.0' |
| 6 | + id 'java' |
| 7 | + id 'project-report' |
| 8 | +} |
| 9 | + |
| 10 | +group = 'com.example.batch' |
| 11 | +version = '0.0.1-SNAPSHOT' |
| 12 | +description = 'SpringBatchDbAndCsv' |
| 13 | +java { |
| 14 | + sourceCompatibility = JavaVersion.VERSION_21 |
| 15 | + targetCompatibility = JavaVersion.VERSION_21 |
| 16 | +} |
| 17 | + |
| 18 | +repositories { |
| 19 | + mavenCentral() |
| 20 | +} |
| 21 | + |
| 22 | +// Spring Bootプラグインが管理するライブラリに対してバージョン番号を明示的に指定しない。 |
| 23 | +// Do not explicitly specify version numbers for libraries managed by the Spring Boot plugin. |
| 24 | +// https://docs.spring.io/spring-boot/appendix/dependency-versions/coordinates.html |
| 25 | +dependencies { |
| 26 | + implementation 'org.springframework.boot:spring-boot-starter-batch' |
| 27 | + implementation 'org.springframework.boot:spring-boot-starter-jooq' |
| 28 | + implementation 'org.apache.commons:commons-lang3' |
| 29 | + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv' |
| 30 | + implementation 'com.mysql:mysql-connector-j' |
| 31 | + |
| 32 | + // jOOQ dependencies |
| 33 | + implementation 'org.jooq:jooq' |
| 34 | + jooqGenerator 'org.jooq:jooq-meta' |
| 35 | + jooqGenerator 'org.jooq:jooq-codegen' |
| 36 | + jooqGenerator 'com.mysql:mysql-connector-j' |
| 37 | + |
| 38 | + runtimeOnly 'com.h2database:h2' |
| 39 | + annotationProcessor 'org.projectlombok:lombok' |
| 40 | + compileOnly 'org.projectlombok:lombok' |
| 41 | + |
| 42 | + testImplementation 'org.springframework.boot:spring-boot-starter-test' |
| 43 | + testImplementation 'org.springframework.batch:spring-batch-test' |
| 44 | +} |
| 45 | + |
| 46 | +tasks.withType(JavaCompile) { |
| 47 | + options.encoding = 'UTF-8' |
| 48 | +} |
| 49 | + |
| 50 | +tasks.named('test') { |
| 51 | + useJUnitPlatform() |
| 52 | +} |
| 53 | + |
| 54 | +// https://github.com/diffplug/spotless |
| 55 | +spotless { |
| 56 | + java { |
| 57 | + target project.fileTree(project.projectDir) { |
| 58 | + include '**/*.java' |
| 59 | + exclude '**/generated-src/**' |
| 60 | + exclude '**/build/**' |
| 61 | + } |
| 62 | + googleJavaFormat() |
| 63 | + trimTrailingWhitespace() |
| 64 | + endWithNewline() |
| 65 | + removeUnusedImports() |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +jooq { |
| 70 | + configurations { |
| 71 | + main { // 生成コードの設定 |
| 72 | + generationTool { |
| 73 | + jdbc { |
| 74 | + driver = 'com.mysql.cj.jdbc.Driver' |
| 75 | + url = 'jdbc:mysql://localhost:3306/sampledb' |
| 76 | + user = 'sampleuser' |
| 77 | + password = 'samplepassword' |
| 78 | + } |
| 79 | + generator { |
| 80 | + name = 'org.jooq.codegen.DefaultGenerator' |
| 81 | + strategy { |
| 82 | + name = 'org.jooq.codegen.DefaultGeneratorStrategy' |
| 83 | + } |
| 84 | + database { |
| 85 | + name = 'org.jooq.meta.mysql.MySQLDatabase' |
| 86 | + inputSchema = 'sampledb' // スキーマ名を指定 |
| 87 | + } |
| 88 | + target { |
| 89 | + packageName = 'com.example.batch.jooq' // 生成コードのパッケージ |
| 90 | + directory = "build/generated-src/jooq/main"// 生成先ディレクトリ |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | +tasks.named('build') { |
| 99 | + dependsOn 'generateJooq' |
| 100 | +} |
| 101 | + |
| 102 | +defaultTasks 'tasks', 'spotlessApply', 'clean', 'check', 'projectReport', 'bootJar' |
0 commit comments