Skip to content

Commit 14fa546

Browse files
authored
Add BOM (spring-pulsar-bom) module (#535)
1 parent a52532d commit 14fa546

File tree

6 files changed

+146
-2
lines changed

6 files changed

+146
-2
lines changed

README.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ There are several modules in Spring for Apache Pulsar. Here is a quick overview:
7979
=== spring-pulsar
8080
The main library that provides the API to access Apache Pulsar.
8181

82+
=== spring-pulsar-bom
83+
Provides a Maven BOM (https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms[Bill of Materials]) that recommends a consistent version for all Spring for Apache Pulsar published modules.
84+
8285
=== spring-pulsar-cache-provider
8386
Provides the interfaces for the cache provider used by the main library to cache producers.
8487

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins {
1313
}
1414

1515
include 'spring-pulsar'
16+
include 'spring-pulsar-bom'
1617
include 'spring-pulsar-cache-provider'
1718
include 'spring-pulsar-cache-provider-caffeine'
1819
include 'spring-pulsar-reactive'
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import org.springframework.pulsar.gradle.SpringModulePlugin
2+
3+
plugins {
4+
id 'org.springframework.pulsar.spring-module'
5+
}
6+
7+
description = 'Spring Pulsar (Bill of Materials)'
8+
9+
dependencies {
10+
constraints {
11+
project.rootProject.subprojects
12+
.sort { "$it.name" }
13+
.findAll { it.name != "spring-pulsar-bom" }
14+
.each { p ->
15+
p.plugins.withType(SpringModulePlugin) {
16+
api p
17+
}
18+
}
19+
}
20+
}

spring-pulsar-docs/src/main/antora/modules/ROOT/nav.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
* Appendices
1818
** xref:appendix/version-compatibility.adoc[]
1919
** xref:appendix/override-boot-dependencies.adoc[]
20+
** xref:appendix/getting-dependencies-without-boot.adoc[]
2021
** xref:appendix/non-ga-versions.adoc[]
2122
** xref:appendix/native-image.adoc[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
[[deps-without-boot]]
2+
= Getting Dependencies without Spring Boot
3+
4+
We recommend a Spring Boot first approach when using Spring for Apache Pulsar.
5+
However, if you do not use Spring Boot, the preferred way to get the dependencies is to use the provided BOM to ensure a consistent version of modules is used throughout your entire project.
6+
The following example shows how to do so for both Maven and Gradle:
7+
8+
[tabs]
9+
======
10+
Maven::
11+
+
12+
.pom.xml
13+
[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
14+
----
15+
<dependencyManagement>
16+
<dependencies>
17+
<!-- ... other dependency elements ... -->
18+
<dependency>
19+
<groupId>org.springframework.pulsar</groupId>
20+
<artifactId>spring-pulsar-bom</artifactId>
21+
<version>{spring-pulsar-version}</version>
22+
<type>pom</type>
23+
<scope>import</scope>
24+
</dependency>
25+
</dependencies>
26+
</dependencyManagement>
27+
----
28+
29+
Gradle::
30+
+
31+
.build.gradle
32+
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
33+
----
34+
plugins {
35+
id "io.spring.dependency-management" version "1.1.4"
36+
}
37+
38+
dependencyManagement {
39+
imports {
40+
mavenBom 'org.springframework.pulsar:spring-pulsar-bom:{spring-pulsar-version}'
41+
}
42+
}
43+
----
44+
======
45+
46+
A minimal Spring for Apache Pulsar set of dependencies typically looks like the following:
47+
48+
[tabs]
49+
======
50+
Maven::
51+
+
52+
.pom.xml
53+
[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
54+
----
55+
<dependencies>
56+
<!-- ... other dependency elements ... -->
57+
<dependency>
58+
<groupId>org.springframework.pulsar</groupId>
59+
<artifactId>spring-pulsar</artifactId>
60+
</dependency>
61+
</dependencies>
62+
----
63+
64+
Gradle::
65+
+
66+
.build.gradle
67+
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
68+
----
69+
dependencies {
70+
implementation "org.springframework.pulsar:spring-pulsar"
71+
}
72+
----
73+
======
74+
75+
If you use additional features (such as Reactive), you need to also include the appropriate dependencies.
76+
77+
Spring for Apache Pulsar builds against Spring Framework {spring-framework-version} but should generally work with any newer version of Spring Framework 6.x.
78+
Many users are likely to run afoul of the fact that Spring for Apache Pulsar's transitive dependencies resolve Spring Framework {spring-framework-version}, which can cause strange classpath problems.
79+
The easiest way to resolve this is to use the `spring-framework-bom` within your `dependencyManagement` section as follows:
80+
81+
[tabs]
82+
======
83+
Maven::
84+
+
85+
.pom.xml
86+
[source,xml,indent=0,subs="verbatim,attributes",role="primary"]
87+
----
88+
<dependencyManagement>
89+
<dependencies>
90+
<!-- ... other dependency elements ... -->
91+
<dependency>
92+
<groupId>org.springframework</groupId>
93+
<artifactId>spring-framework-bom</artifactId>
94+
<version>{spring-framework-version}</version>
95+
<type>pom</type>
96+
<scope>import</scope>
97+
</dependency>
98+
</dependencies>
99+
</dependencyManagement>
100+
----
101+
102+
Gradle::
103+
+
104+
.build.gradle
105+
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
106+
----
107+
plugins {
108+
id "io.spring.dependency-management" version "1.1.4"
109+
}
110+
111+
dependencyManagement {
112+
imports {
113+
mavenBom 'org.springframework:spring-framework-bom:{spring-framework-version}'
114+
}
115+
}
116+
----
117+
======
118+
119+
The preceding example ensures that all the transitive dependencies of Spring for Apache Pulsar use the Spring {spring-framework-version} modules.

spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/listener/ReactivePulsarListenerTombstoneTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ void shouldReceiveMessagesWithTombstone() throws Exception {
238238
var pulsarProducerFactory = new DefaultPulsarProducerFactory<Foo>(pulsarClient);
239239
var fooPulsarTemplate = new PulsarTemplate<>(pulsarProducerFactory);
240240
sendTestMessages(fooPulsarTemplate, TOPIC, Schema.JSON(Foo.class), Foo::new);
241-
assertThat(latchWithHeaders.await(5, TimeUnit.SECONDS)).isTrue();
242-
assertThat(latchWithoutHeaders.await(5, TimeUnit.SECONDS)).isTrue();
241+
assertThat(latchWithHeaders.await(10, TimeUnit.SECONDS)).isTrue();
242+
assertThat(latchWithoutHeaders.await(10, TimeUnit.SECONDS)).isTrue();
243243
assertMessagesReceivedWithHeaders(receivedMessagesWithHeaders, Foo::new);
244244
assertMessagesReceivedWithoutHeaders(receivedMessagesWithoutHeaders, Foo::new);
245245
}

0 commit comments

Comments
 (0)