Add spring boot starter module (#56)
Also: * Clean up dependencies (remove unused) * Add README in samples how to run w/ new tools/pulsar Fixes #49
This commit is contained in:
@@ -59,6 +59,7 @@ If you want to build everything, use the `build` task:
|
||||
== Modules
|
||||
There are several modules in Spring Pulsar. Here is a quick overview:
|
||||
|
||||
|
||||
=== spring-pulsar
|
||||
The main library that provides the API to access Apache Pulsar.
|
||||
|
||||
@@ -71,6 +72,9 @@ Provides reference docs and handles aggregating javadocs.
|
||||
=== spring-pulsar-spring-boot-autoconfigure
|
||||
Provides Spring Boot auto-configuration for Spring Pulsar.
|
||||
|
||||
=== spring-pulsar-spring-boot-starter
|
||||
Provides a dependency descriptor that can be included in your application to easily start using Spring Pulsar.
|
||||
|
||||
=== spring-pulsar-sample-apps
|
||||
Provides sample applications to illustrate Spring Pulsar functionality as well as provide ability for quick manual verification during development.
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ check {
|
||||
subprojects { subproject ->
|
||||
task updateCopyrights {
|
||||
onlyIf { gitPresent && !System.getenv('GITHUB_ACTION') }
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
if (gitPresent) {
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
}
|
||||
outputs.dir('build')
|
||||
doLast {
|
||||
def now = Calendar.instance.get(Calendar.YEAR) as String
|
||||
|
||||
@@ -249,9 +249,9 @@ public class JavaConventionsPlugin implements Plugin<Project> {
|
||||
configurations
|
||||
.matching((c) -> c.getName().endsWith("Classpath") || c.getName().toLowerCase().endsWith("annotationprocessor"))
|
||||
.all((c) -> c.extendsFrom(dependencyManagement));
|
||||
Dependency springBootParent = project.getDependencies().enforcedPlatform(project.getDependencies()
|
||||
Dependency pulsarDependencies = project.getDependencies().enforcedPlatform(project.getDependencies()
|
||||
.project(Collections.singletonMap("path", ":spring-pulsar-dependencies")));
|
||||
dependencyManagement.getDependencies().add(springBootParent);
|
||||
dependencyManagement.getDependencies().add(pulsarDependencies);
|
||||
project.getPlugins().withType(OptionalDependenciesPlugin.class, (optionalDependencies) -> configurations
|
||||
.getByName(OptionalDependenciesPlugin.OPTIONAL_CONFIGURATION_NAME).extendsFrom(dependencyManagement));
|
||||
}
|
||||
|
||||
@@ -24,5 +24,6 @@ rootProject.name = 'spring-pulsar-dist'
|
||||
include 'spring-pulsar'
|
||||
include 'spring-pulsar-dependencies'
|
||||
include 'spring-pulsar-spring-boot-autoconfigure'
|
||||
include 'spring-pulsar-spring-boot-starter'
|
||||
include 'spring-pulsar-sample-apps'
|
||||
include 'spring-pulsar-docs'
|
||||
|
||||
@@ -7,19 +7,19 @@ javaPlatform {
|
||||
}
|
||||
|
||||
ext {
|
||||
assertjVersion = '3.22.0'
|
||||
assertjVersion = '3.23.1'
|
||||
awaitilityVersion = '4.2.0'
|
||||
googleJsr305Version = '3.0.2'
|
||||
hamcrestVersion = '2.2'
|
||||
hibernateValidationVersion = '7.0.4.Final'
|
||||
jacksonBomVersion = '2.13.3'
|
||||
jaywayJsonPathVersion = '2.6.0'
|
||||
junitJupiterVersion = '5.8.2'
|
||||
junitJupiterVersion = '5.9.0'
|
||||
pulsarVersion = '2.10.0'
|
||||
log4jVersion = '2.17.2'
|
||||
mockitoVersion = '4.5.1'
|
||||
log4jVersion = '2.18.0'
|
||||
mockitoVersion = '4.6.1'
|
||||
reactorVersion = '2020.0.17'
|
||||
pulsarTestcontainersVersion = '1.17.2'
|
||||
pulsarTestcontainersVersion = '1.17.3'
|
||||
springBootVersion = '3.0.0-SNAPSHOT'
|
||||
springRetryVersion = '1.3.3'
|
||||
springVersion = '6.0.0-SNAPSHOT'
|
||||
@@ -27,23 +27,25 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api platform("org.springframework:spring-framework-bom:$springVersion")
|
||||
api platform("io.projectreactor:reactor-bom:$reactorVersion")
|
||||
api platform("org.junit:junit-bom:$junitJupiterVersion")
|
||||
|
||||
api platform("com.fasterxml.jackson:jackson-bom:$jacksonBomVersion")
|
||||
api platform("io.projectreactor:reactor-bom:$reactorVersion")
|
||||
api platform("org.apache.logging.log4j:log4j-bom:$log4jVersion")
|
||||
api platform("org.junit:junit-bom:$junitJupiterVersion")
|
||||
api platform("org.mockito:mockito-bom:$mockitoVersion")
|
||||
api platform("org.springframework:spring-framework-bom:$springVersion")
|
||||
|
||||
constraints {
|
||||
// spring-pulsar
|
||||
api "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
|
||||
api "com.google.code.findbugs:jsr305:$googleJsr305Version"
|
||||
api "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"
|
||||
api "org.apache.pulsar:pulsar-client:$pulsarVersion"
|
||||
api "org.apache.pulsar:pulsar-client-admin:$pulsarVersion"
|
||||
api "org.apache.pulsar:pulsar-client-admin-api:$pulsarVersion"
|
||||
api "org.springframework.retry:spring-retry:$springRetryVersion"
|
||||
api "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"
|
||||
api "org.mockito:mockito-junit-jupiter:$mockitoVersion"
|
||||
api "org.assertj:assertj-core:$assertjVersion"
|
||||
api "org.awaitility:awaitility:$awaitilityVersion"
|
||||
api "org.hamcrest:hamcrest:$hamcrestVersion"
|
||||
api "org.hibernate.validator:hibernate-validator:$hibernateValidationVersion"
|
||||
// spring-pulsar-spring-boot-autoconfigure
|
||||
api "org.springframework.boot:spring-boot-autoconfigure-processor:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot-configuration-processor:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot:$springBootVersion"
|
||||
@@ -51,12 +53,7 @@ dependencies {
|
||||
api "org.springframework.boot:spring-boot-starter:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
|
||||
api "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
|
||||
// Common to all
|
||||
api "com.google.code.findbugs:jsr305:$googleJsr305Version"
|
||||
api 'org.apiguardian:apiguardian-api:1.0.0'
|
||||
api "org.awaitility:awaitility:$awaitilityVersion"
|
||||
api "org.hamcrest:hamcrest-core:$hamcrestVersion"
|
||||
api "org.assertj:assertj-core:$assertjVersion"
|
||||
api "org.springframework.retry:spring-retry:$springRetryVersion"
|
||||
api "org.testcontainers:pulsar:$pulsarTestcontainersVersion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'org.springframework.boot:spring-boot-starter'
|
||||
api project (':spring-pulsar')
|
||||
api 'org.springframework.boot:spring-boot-starter'
|
||||
configurationProperties(project(path: ":spring-pulsar-spring-boot-autoconfigure", configuration: "configurationPropertiesMetadata"))
|
||||
}
|
||||
|
||||
|
||||
40
spring-pulsar-sample-apps/README.adoc
Normal file
40
spring-pulsar-sample-apps/README.adoc
Normal file
@@ -0,0 +1,40 @@
|
||||
= Spring Pulsar Sample Applications
|
||||
|
||||
Sample applications that can be used to demonstrate and manually verify Spring Pulsar functionality.
|
||||
|
||||
|
||||
[[build-apps]]
|
||||
== Building
|
||||
To build the applications simply execute the following command from the `spring-pulsar-sample-apps` directory:
|
||||
[source,bash]
|
||||
----
|
||||
../gradlew clean build
|
||||
----
|
||||
|
||||
[[run-apps]]
|
||||
== Running
|
||||
|
||||
=== Pre-requisites
|
||||
****
|
||||
* The components have all been built by following the <<build-apps>> steps.
|
||||
* Apache Pulsar standalone cluster available at `pulsar://localhost:6650`
|
||||
|
||||
TIP: The included link:../tools/pulsar/docker/README.adoc#_start_pulsar[Pulsar tools] can be used to easily start a standalone cluster locally on the required coordinates
|
||||
****
|
||||
|
||||
=== Steps
|
||||
Make sure the above pre-requisites are satisfied and that you are in the `spring-pulsar-sample-apps` directory and follow the steps below.
|
||||
|
||||
=== App1
|
||||
To start the link:./src/main/java/app1/SpringPulsarBootApp.java[SpringPulsarBootApp] run the following command:
|
||||
[source,bash]
|
||||
----
|
||||
../gradlew bootRun -PsampleMainClass='app1.SpringPulsarBootApp'
|
||||
----
|
||||
|
||||
=== App2
|
||||
To start the link:./src/main/java/app2/FailoverConsumerApp.java[FailoverConsumerApp] run the following command:
|
||||
[source,bash]
|
||||
----
|
||||
../gradlew bootRun -PsampleMainClass='app2.FailoverConsumerApp'
|
||||
----
|
||||
@@ -1,14 +1,24 @@
|
||||
plugins {
|
||||
id 'org.springframework.pulsar.spring-module'
|
||||
id 'org.springframework.boot' version '2.7.2'
|
||||
}
|
||||
|
||||
description = 'Spring Pulsar Sample Applications'
|
||||
|
||||
dependencies {
|
||||
api project(':spring-pulsar-spring-boot-autoconfigure')
|
||||
api project(':spring-pulsar-spring-boot-starter')
|
||||
implementation 'com.google.code.findbugs:jsr305'
|
||||
}
|
||||
|
||||
ext {
|
||||
sampleMainClass = project.hasProperty("sampleMainClass") ?
|
||||
project.getProperty("sampleMainClass") : "app1.SpringPulsarBootApp"
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = sampleMainClass
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
project.tasks.artifactoryPublish.enabled(false)
|
||||
}
|
||||
|
||||
@@ -16,13 +16,8 @@ dependencies {
|
||||
api 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'com.google.code.findbugs:jsr305'
|
||||
|
||||
// TODO remove unused dependencies
|
||||
|
||||
// TODO do I really need this??? To avoid compiler warnings about @API annotations in JUnit code
|
||||
testCompileOnly 'org.apiguardian:apiguardian-api'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.testcontainers:pulsar'
|
||||
// TODO why do I care about these?
|
||||
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
|
||||
testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.testcontainers:pulsar'
|
||||
}
|
||||
|
||||
9
spring-pulsar-spring-boot-starter/build.gradle
Normal file
9
spring-pulsar-spring-boot-starter/build.gradle
Normal file
@@ -0,0 +1,9 @@
|
||||
plugins {
|
||||
id 'org.springframework.pulsar.spring-module'
|
||||
}
|
||||
|
||||
description = 'Spring Pulsar Spring Boot Starter'
|
||||
|
||||
dependencies {
|
||||
api project (':spring-pulsar-spring-boot-autoconfigure')
|
||||
}
|
||||
@@ -5,17 +5,17 @@ plugins {
|
||||
description = 'Spring Pulsar Support'
|
||||
|
||||
dependencies {
|
||||
api 'com.github.ben-manes.caffeine:caffeine'
|
||||
api 'org.apache.pulsar:pulsar-client'
|
||||
api 'org.apache.pulsar:pulsar-client-admin'
|
||||
api 'org.apache.pulsar:pulsar-client-admin-api'
|
||||
api 'org.springframework:spring-context'
|
||||
api 'org.springframework:spring-messaging'
|
||||
api 'org.springframework:spring-tx'
|
||||
api ('org.springframework.retry:spring-retry') {
|
||||
exclude group: 'org.springframework'
|
||||
}
|
||||
api 'org.apache.pulsar:pulsar-client'
|
||||
api 'org.apache.pulsar:pulsar-client-admin'
|
||||
api 'org.apache.pulsar:pulsar-client-admin-api'
|
||||
api 'com.github.ben-manes.caffeine:caffeine'
|
||||
|
||||
implementation 'com.google.code.findbugs:jsr305'
|
||||
optional 'com.fasterxml.jackson.core:jackson-core'
|
||||
optional 'com.fasterxml.jackson.core:jackson-databind'
|
||||
optional 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
|
||||
@@ -23,28 +23,14 @@ dependencies {
|
||||
optional 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
|
||||
optional 'com.jayway.jsonpath:json-path'
|
||||
optional 'io.projectreactor:reactor-core'
|
||||
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter'
|
||||
testImplementation 'org.hibernate.validator:hibernate-validator'
|
||||
|
||||
// TODO remove unused dependencies
|
||||
|
||||
// Common to all ??
|
||||
implementation 'com.google.code.findbugs:jsr305'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
// To avoid compiler warnings about @API annotations in JUnit code
|
||||
testCompileOnly 'org.apiguardian:apiguardian-api'
|
||||
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
|
||||
testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl'
|
||||
testImplementation("org.awaitility:awaitility") {
|
||||
exclude group: 'org.hamcrest'
|
||||
}
|
||||
testImplementation 'org.hamcrest:hamcrest-core'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.testcontainers:pulsar'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.hamcrest:hamcrest'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter'
|
||||
testImplementation 'org.springframework:spring-test'
|
||||
testImplementation 'org.testcontainers:pulsar'
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ Runs a local standalone Pulsar cluster in Docker.
|
||||
* The admin is available at `http://localhost:8080`
|
||||
* Two Docker volumes (`pulsardata`, `pulsarconf`) are created to store the data, metadata, and configuration in order to not start "fresh" every time the container is restarted.
|
||||
|
||||
|
||||
[#_start_pulsar]
|
||||
==== Start
|
||||
To start the cluster run the following script from project root dir:
|
||||
[source,shell]
|
||||
|
||||
Reference in New Issue
Block a user