Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
id 'org.springframework.boot' version '2.1.3.RELEASE' | ||
id 'org.jetbrains.kotlin.jvm' version '1.3.21' | ||
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.21' | ||
} | ||
|
||
apply plugin: 'io.spring.dependency-management' | ||
|
||
group = 'net.benelog.blog' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '1.8' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-batch' | ||
implementation 'org.jetbrains.kotlin:kotlin-reflect' | ||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' | ||
implementation 'com.h2database:h2:1.4.197' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.springframework.batch:spring-batch-test' | ||
} | ||
|
||
compileKotlin { | ||
kotlinOptions { | ||
freeCompilerArgs = ['-Xjsr305=strict'] | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
compileTestKotlin { | ||
kotlinOptions { | ||
freeCompilerArgs = ['-Xjsr305=strict'] | ||
jvmTarget = '1.8' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
rootProject.name = 'migration' |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/net/benelog/blog/migration/HelpJobConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.benelog.blog.migration | ||
|
||
import org.springframework.batch.core.Job | ||
import org.springframework.batch.core.Step | ||
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory | ||
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory | ||
import org.springframework.batch.core.launch.support.RunIdIncrementer | ||
import org.springframework.batch.repeat.RepeatStatus | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
|
||
@Configuration | ||
class HelpJobConfig( | ||
private val stepFactory: StepBuilderFactory, | ||
private val jobFactory: JobBuilderFactory | ||
) { | ||
@Bean | ||
fun helpJob(): Job { | ||
return jobFactory.get("helpJob") | ||
.incrementer(RunIdIncrementer()) | ||
.start(printStep()) | ||
.build() | ||
} | ||
|
||
@Bean | ||
fun printStep(): Step { | ||
return stepFactory.get("printStep") | ||
.tasklet({ cont, context -> | ||
println() | ||
println("## 안내") | ||
println("실행하려는 Job은 `-Dspring.batch.job.names=helpJob`와 같이 VM option으로 지정한다") | ||
println() | ||
RepeatStatus.FINISHED | ||
}) | ||
.build() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/net/benelog/blog/migration/MigrationApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.benelog.blog.migration | ||
|
||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing | ||
import org.springframework.boot.SpringApplication | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.jdbc.DataSourceBuilder | ||
import org.springframework.boot.runApplication | ||
import org.springframework.context.annotation.Bean | ||
import javax.sql.DataSource | ||
|
||
@SpringBootApplication | ||
@EnableBatchProcessing | ||
class MigrationApplication | ||
|
||
fun main(args: Array<String>) { | ||
val context = runApplication<MigrationApplication>(*args) | ||
val exitCode = SpringApplication.exit(context) | ||
System.exit(exitCode); | ||
} | ||
|
||
@Bean | ||
fun jobMetaDb(): DataSource { | ||
return DataSourceBuilder.create() | ||
.driverClassName("org.h2.Driver") | ||
.url("jdbc:h2:~/elgoos-migraion/job;AUTO_SERVER=TRUE") | ||
.build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
14 changes: 14 additions & 0 deletions
14
src/test/kotlin/net/benelog/blog/migration/MigrationApplicationTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.benelog.blog.migration | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.junit4.SpringRunner | ||
|
||
@RunWith(SpringRunner::class) | ||
@SpringBootTest | ||
class MigrationApplicationTests { | ||
@Test | ||
fun contextLoads() { | ||
} | ||
} |