Add custom tasks to run samples (#105)

- bootRunApp1
- bootRunApp2
This commit is contained in:
Chris Bono
2022-09-11 12:36:33 -05:00
committed by GitHub
parent fbc4773dbd
commit d4dfcee77c
2 changed files with 18 additions and 7 deletions

View File

@@ -29,12 +29,12 @@ Make sure the above pre-requisites are satisfied and that you are in the `spring
To start the link:./src/main/java/app1/SpringPulsarBootApp.java[SpringPulsarBootApp] run the following command:
[source,bash]
----
../gradlew bootRun -PsampleMainClass='app1.SpringPulsarBootApp'
../gradlew bootRunApp1
----
=== App2
To start the link:./src/main/java/app2/FailoverConsumerApp.java[FailoverConsumerApp] run the following command:
[source,bash]
----
../gradlew bootRun -PsampleMainClass='app2.FailoverConsumerApp'
../gradlew bootRunApp2
----

View File

@@ -10,13 +10,24 @@ dependencies {
implementation 'com.google.code.findbugs:jsr305'
}
ext {
sampleMainClass = project.hasProperty("sampleMainClass") ?
project.getProperty("sampleMainClass") : "app1.SpringPulsarBootApp"
springBoot {
mainClass = 'app1.SpringPulsarBootApp' // default app to run
}
springBoot {
mainClass = sampleMainClass
task bootRunApp1(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
group = 'application'
mainClass = 'app1.SpringPulsarBootApp'
doFirst() {
classpath = sourceSets.main.runtimeClasspath
}
}
task bootRunApp2(type: org.springframework.boot.gradle.tasks.run.BootRun, dependsOn: 'build') {
group = 'application'
mainClass = 'app2.FailoverConsumerApp'
doFirst() {
classpath = sourceSets.main.runtimeClasspath
}
}
project.afterEvaluate {