Break dependency on Spring Boot (#407)

- Removes the use of spring-boot-dependencies to drive the
  Java platform (spring-pulsar-dependencies). This is needed
  to avoid chicken-egg problem when Spring Boot in turn has
  a dependency on Spring Pulsar.

- Move integration tests into own sub-module

- The only place that still relies on Spring Boot is in the
  integration tests and the samples.

- Update to Spring Boot 3.1.1-SNAPSHOT
This commit is contained in:
Chris Bono
2023-05-25 20:03:32 -05:00
committed by GitHub
parent 9f2b2844af
commit b0e130c8e9
23 changed files with 186 additions and 194 deletions

View File

@@ -49,20 +49,27 @@ If you want to build everything and run tests, use the `build` task:
[source,shell]
----
./gradlew clean build
./gradlew build
----
NOTE: Some tests rely on a Docker daemon to test against live services using https://www.testcontainers.org/[Testcontainers].
These tests will be skipped if a local Docker daemon is not available.
The above command will build everything and run all tests except the `PulsarFunctionAdministrationIntegrationTests` which requires the _Pulsar RabbitMQ Connector_ to be downloaded prior to running.
The above command will build everything and run all unit tests and integration tests except the `PulsarFunctionAdministrationIntegrationTests` which requires the _Pulsar RabbitMQ Connector_ to be downloaded prior to running.
To download the connector (one time only) and run the integration test, add a system property to the task as follows:
[source,shell]
----
./gradlew clean build -DdownloadRabbitConnector=true
./gradlew build -DdownloadRabbitConnector=true
----
By default, the `build` command will run unit tests followed by integration tests.
If you want skip tests, use the `-x test` and/or `-x integrationTest` options:
[source,shell]
----
./gradlew build -x test -x integrationTest
----
== Modules
There are several modules in Spring Pulsar. Here is a quick overview:

View File

@@ -6,13 +6,20 @@ plugins {
}
repositories {
gradlePluginPortal()
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
if (version.endsWith('SNAPSHOT')) {
maven { url 'https://repo.spring.io/snapshot' }
gradlePluginPortal()
}
new File(new File("$projectDir").parentFile, "gradle.properties").withInputStream {
def properties = new Properties()
properties.load(it)
ext.set("springFrameworkVersion", properties["springFrameworkVersion"])
if (properties["springFrameworkVersion"].contains("-")) {
repositories {
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/snapshot" }
}
}
jcenter()
}
sourceCompatibility = JavaVersion.VERSION_17
@@ -32,13 +39,13 @@ configurations {
}
ext {
springBootVersion = '3.0.5'
springBootVersion = '3.1.1-SNAPSHOT'
}
dependencies {
implementation localGroovy()
implementation 'commons-codec:commons-codec'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'commons-codec:commons-codec:1.15'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.4'
implementation 'io.github.gradle-nexus:publish-plugin:1.1.0'
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.34")
implementation 'io.spring.nohttp:nohttp-gradle:0.0.10'
@@ -46,26 +53,11 @@ dependencies {
implementation "org.asciidoctor:asciidoctor-gradle-jvm:3.3.2"
implementation 'org.codehaus.groovy:groovy-all:2.5.17'
implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.31.9'
implementation "org.gradle:test-retry-gradle-plugin:1.4.0"
implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1'
implementation(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
implementation(platform("org.springframework:spring-framework-bom:${springFrameworkVersion}"))
implementation 'org.springframework:spring-core'
implementation 'org.springframework:spring-web'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.apache.logging.log4j:log4j-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test', Test).configure {
onlyIf { !project.hasProperty("buildSrc.skipTests") }
useJUnitPlatform()
jvmArgs(
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED'
)
}
gradlePlugin {

View File

@@ -3,3 +3,12 @@ version=1.0.0-SNAPSHOT
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8
pulsarClientVersion=3.0.0
pulsarClientReactiveVersion=0.3.0
springBootVersion=3.1.1-SNAPSHOT
springFrameworkVersion=6.0.9
# these are temp until autoconfig moves into boot
springPulsarStarterVersion=0.2.1-SNAPSHOT
springPulsarBinderVersion=0.2.1-SNAPSHOT
springCloudStreamVersion=4.0.3

View File

@@ -0,0 +1,58 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id "de.undercouch.download" version "5.3.0"
id 'spring-pulsar.integration-test-conventions'
}
description = 'Spring Pulsar Integration Tests'
dependencies {
intTestImplementation project(':spring-pulsar-test')
intTestRuntimeOnly 'ch.qos.logback:logback-classic'
intTestRuntimeOnly 'org.junit.platform:junit-platform-launcher'
intTestImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
intTestImplementation "org.springframework.boot:spring-boot-starter-amqp:$springBootVersion"
intTestImplementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:$springPulsarStarterVersion"
intTestImplementation "org.springframework.pulsar:spring-pulsar-reactive-spring-boot-starter:$springPulsarStarterVersion"
intTestImplementation 'org.testcontainers:junit-jupiter'
intTestImplementation 'org.testcontainers:pulsar'
intTestImplementation 'org.testcontainers:rabbitmq'
}
test {
testLogging.showStandardStreams = true
}
integrationTest {
maxHeapSize '2048m'
}
task downloadRabbitConnector {
onlyIf {
System.getProperty("downloadRabbitConnector") == "true"
}
doLast {
try {
download.run {
println "Downloading Rabbit connector to 'src/intTest/resources/connectors/' (one time only if not already downloaded)..."
src 'https://archive.apache.org/dist/pulsar/pulsar-2.10.2/connectors/pulsar-io-rabbitmq-2.10.2.nar'
dest "$buildDir/../src/intTest/resources/connectors/pulsar-io-rabbitmq-2.10.2.nar"
overwrite false
}
} catch (Exception ex) {
println "Failed to download rabbit connector: $ex"
}
}
}
project.afterEvaluate {
integrationTest.dependsOn downloadRabbitConnector
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -37,3 +37,4 @@ include 'spring-pulsar-sample-apps:sample-pulsar-binder'
include 'spring-pulsar-sample-apps:sample-pulsar-reader'
include 'spring-pulsar-docs'
include 'spring-pulsar-test'
include 'integration-tests'

View File

@@ -6,31 +6,30 @@ javaPlatform {
allowDependencies()
}
ext {
googleJsr305Version = '3.0.2'
protobufJavaVersion = '3.21.5'
testcontainersVersion = '1.17.6'
pulsarVersion = '3.0.0'
pulsarClientReactiveVersion = '0.3.0'
springBootVersion = '3.0.5'
springPulsarStarterVersion = '0.2.1-SNAPSHOT'
springPulsarBinderVersion = '0.2.1-SNAPSHOT'
springCloudStreamVersion = '4.0.1'
}
dependencies {
api platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
api platform("org.testcontainers:testcontainers-bom:$testcontainersVersion")
api platform("com.fasterxml.jackson:jackson-bom:2.15.0")
api platform("io.micrometer:micrometer-bom:1.11.0")
api platform("io.micrometer:micrometer-tracing-bom:1.1.1")
api platform("io.projectreactor:reactor-bom:2022.0.7")
api platform("io.zipkin.brave:brave-bom:5.15.1")
api platform("org.assertj:assertj-bom:3.24.2")
api platform("org.awaitility:awaitility:4.2.0")
api platform("org.junit:junit-bom:5.9.3")
api platform("org.mockito:mockito-bom:5.3.1")
api platform("org.springframework:spring-framework-bom:$springFrameworkVersion")
api platform("org.testcontainers:testcontainers-bom:1.18.0")
constraints {
api "com.google.code.findbugs:jsr305:$googleJsr305Version"
api "com.google.protobuf:protobuf-java:$protobufJavaVersion"
api "org.apache.pulsar:pulsar-client-all:$pulsarVersion"
api "ch.qos.logback:logback-classic:1.4.7"
api "com.github.ben-manes.caffeine:caffeine:3.1.6"
api "com.google.code.findbugs:jsr305:3.0.2"
api "com.google.protobuf:protobuf-java:3.21.5"
api "com.jayway.jsonpath:json-path:2.8.0"
api "org.apache.pulsar:pulsar-client-all:$pulsarClientVersion"
api "org.apache.pulsar:pulsar-client-reactive-adapter:$pulsarClientReactiveVersion"
api "org.apache.pulsar:pulsar-client-reactive-producer-cache-caffeine-shaded:$pulsarClientReactiveVersion"
api "org.springframework.cloud:spring-cloud-stream:$springCloudStreamVersion"
api "org.springframework.cloud:spring-cloud-stream-test-support:$springCloudStreamVersion"
api "org.springframework.pulsar:spring-pulsar-spring-boot-starter:$springPulsarStarterVersion"
api "org.springframework.pulsar:spring-pulsar-reactive-spring-boot-starter:$springPulsarStarterVersion"
api "org.springframework.pulsar:spring-pulsar-spring-cloud-stream-binder:$springPulsarBinderVersion"
// spring-pulsar tests (OutputCaptureExtension)
api "org.springframework.boot:spring-boot-test:$springBootVersion"
api "org.springframework.retry:spring-retry:2.0.1"
}
}

View File

@@ -15,7 +15,6 @@ configurations {
dependencies {
api project (':spring-pulsar')
api 'org.springframework.boot:spring-boot-starter'
observationDocs "io.micrometer:micrometer-docs-generator:$micrometerDocsVersion"
}
@@ -86,11 +85,11 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED"
}
doFirst {
attributes "spring-boot-version": project(':spring-pulsar-dependencies').springBootVersion ?: 'current',
"spring-cloud-stream-version": project(':spring-pulsar-dependencies').springCloudStreamVersion ?: 'current',
attributes "spring-boot-version": project.springBootVersion ?: 'current',
"spring-cloud-stream-version": project.springCloudStreamVersion ?: 'current',
"spring-pulsar-version": project.version,
"spring-pulsar-binder-version": project(':spring-pulsar-dependencies').springPulsarBinderVersion ?: 'current',
"spring-pulsar-starter-version": project(':spring-pulsar-dependencies').springPulsarStarterVersion ?: 'current'
"spring-pulsar-binder-version": project.springPulsarBinderVersion ?: 'current',
"spring-pulsar-starter-version": project.springPulsarStarterVersion ?: 'current'
}
}

View File

@@ -1,6 +1,5 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'spring-pulsar.integration-test-conventions'
}
description = 'Spring Pulsar Reactive Support'
@@ -38,16 +37,8 @@ dependencies {
testImplementation 'org.springframework:spring-test'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:pulsar'
intTestImplementation 'org.springframework.pulsar:spring-pulsar-reactive-spring-boot-starter'
intTestImplementation 'org.testcontainers:junit-jupiter'
intTestImplementation 'org.testcontainers:pulsar'
}
test {
testLogging.showStandardStreams = true
}
integrationTest {
maxHeapSize '2048m'
}

View File

@@ -1,15 +1,19 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.1.1-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Spring Pulsar Sample Application (Send and Receive)'
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
implementation 'com.google.code.findbugs:jsr305'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
// observability
dependencies {
implementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:${springPulsarStarterVersion}"
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
@@ -23,11 +27,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -1,15 +1,19 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.1.1-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Spring Pulsar Sample Applications (Custom Routing)'
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
implementation 'com.google.code.findbugs:jsr305'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
// observability
dependencies {
implementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:${springPulsarStarterVersion}"
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
@@ -23,11 +27,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -1,13 +1,20 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.1.1-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Spring Cloud Stream Binder for Pulsar Sample Application'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-spring-cloud-stream-binder'
implementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
implementation "org.springframework.pulsar:spring-pulsar-spring-cloud-stream-binder:${springPulsarBinderVersion}"
implementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:${springPulsarStarterVersion}"
}
bootRun {
@@ -17,11 +24,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -1,23 +1,28 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.1.1-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
group = 'org.springframework.pulsar.sample'
description = 'Sample Signup App (Pulsar Functions)'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
implementation "org.springframework.pulsar:spring-pulsar-spring-cloud-stream-binder:${springPulsarBinderVersion}"
implementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:${springPulsarStarterVersion}"
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-data-cassandra'
implementation 'com.devskiller:jfairy:0.6.5'
implementation 'com.google.code.findbugs:jsr305'
// observability
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-tracing-bridge-brave'
implementation 'io.zipkin.reporter2:zipkin-reporter-brave'
implementation 'io.zipkin.reporter2:zipkin-sender-urlconnection'
implementation 'com.devskiller:jfairy:0.6.5'
}
bootRun {
@@ -27,11 +32,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -1,13 +1,19 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.1.1-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Spring Pulsar Sample Application (Send and Receive)'
description = 'Spring Pulsar Sample Application (Reader)'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
implementation 'com.google.code.findbugs:jsr305'
implementation "org.springframework.pulsar:spring-pulsar-spring-boot-starter:${springPulsarStarterVersion}"
}
bootRun {
@@ -17,11 +23,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -1,13 +1,19 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id 'org.springframework.boot' version '3.0.5'
id 'java'
id 'org.springframework.boot' version '3.0.8-SNAPSHOT'
id 'io.spring.dependency-management' version '1.1.0'
}
description = 'Reactive Spring Pulsar Sample Application'
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
}
dependencies {
implementation 'org.springframework.pulsar:spring-pulsar-reactive-spring-boot-starter'
implementation 'com.google.code.findbugs:jsr305'
implementation "org.springframework.pulsar:spring-pulsar-reactive-spring-boot-starter:${springPulsarStarterVersion}"
}
bootRun {
@@ -17,11 +23,3 @@ bootRun {
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
]
}
project.afterEvaluate {
project.tasks.publishArtifacts.enabled(false)
project.tasks.artifactoryPublish.enabled(false)
project.tasks.publishToOssrh.enabled(false)
project.tasks.publishMavenJavaPublicationToOssrhRepository.enabled(false)
project.tasks.publishAllPublicationsToOssrhRepository.enabled(false)
}

View File

@@ -5,6 +5,7 @@ plugins {
description = 'Spring Pulsar Test Module'
dependencies {
implementation 'org.junit.jupiter:junit-jupiter-api'
implementation 'org.testcontainers:pulsar'
implementation 'org.testcontainers:junit-jupiter'
}

View File

@@ -1,10 +1,8 @@
plugins {
id 'org.springframework.pulsar.spring-module'
id "de.undercouch.download" version "5.3.0"
id 'spring-pulsar.integration-test-conventions'
}
description = 'Spring Pulsar Support'
description = 'Spring Pulsar Core'
dependencies {
api 'io.micrometer:micrometer-observation'
@@ -43,41 +41,10 @@ dependencies {
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation 'org.mockito:mockito-junit-jupiter'
testImplementation 'org.springframework:spring-test'
// OutputCaptureExtension used by PulsarFunctionAdministrationTests
testImplementation 'org.springframework.boot:spring-boot-test'
intTestImplementation 'org.springframework.boot:spring-boot-starter-amqp'
intTestImplementation 'org.springframework.pulsar:spring-pulsar-spring-boot-starter'
intTestImplementation 'org.testcontainers:junit-jupiter'
intTestImplementation 'org.testcontainers:pulsar'
intTestImplementation 'org.testcontainers:rabbitmq'
}
test {
testLogging.showStandardStreams = true
}
integrationTest {
maxHeapSize '2048m'
}
task downloadRabbitConnector {
onlyIf {
System.getProperty("downloadRabbitConnector") == "true"
}
doLast {
try {
download.run {
println "Downloading Rabbit connector to 'src/intTest/resources/connectors/' (one time only if not already downloaded)..."
src 'https://archive.apache.org/dist/pulsar/pulsar-2.10.2/connectors/pulsar-io-rabbitmq-2.10.2.nar'
dest "$buildDir/../src/intTest/resources/connectors/pulsar-io-rabbitmq-2.10.2.nar"
overwrite false
}
} catch (Exception ex) {
println "Failed to download rabbit connector: $ex"
}
}
}
project.afterEvaluate {
integrationTest.dependsOn downloadRabbitConnector
}

View File

@@ -1,3 +0,0 @@
spring:
main:
banner-mode: log

View File

@@ -1,13 +0,0 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.testcontainers" level="ERROR"/>
<logger name="com.github.dockerjava" level="ERROR"/>
<logger name="org.springframework.pulsar.function" level="INFO"/>
</configuration>