Skip to content

Commit 7425ac2

Browse files
authored
Add pulsar-client-reactive-bom module (#194)
This commit introduces a BOM module to make consumption of the library more robust by avoid library version mismatches. Resolves #193
1 parent fe787c9 commit 7425ac2

File tree

5 files changed

+210
-55
lines changed

5 files changed

+210
-55
lines changed

README.adoc

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,82 @@ With Maven:
5050
</dependencies>
5151
----
5252
53+
[[pulsar-client-reactive-bom]]
54+
=== Pulsar Client Reactive BOM
55+
56+
While the above dependency is sufficient to obtain the Pulsar Reactive Java client, it is recommended to also use the provided BOM to ensure that all Pulsar dependencies are at the same expected version.
57+
In order to use the BOM, the previous directions are modified slightly as follows:
58+
59+
With Gradle:
60+
61+
[source,groovy,subs="verbatim,attributes"]
62+
----
63+
def pulsarReactiveVersion = '{latest_version}'
64+
65+
dependencies {
66+
implementation enforcedPlatform("org.apache.pulsar:pulsar-client-reactive-bom:${pulsarVersion}")
67+
implementation 'org.apache.pulsar:pulsar-client-reactive-adapter'
68+
}
69+
----
70+
71+
With Maven:
72+
73+
[source,xml,subs="verbatim,attributes"]
74+
----
75+
<!-- in your <properties> block -->
76+
<pulsar-reactive.version>{latest_version}</pulsar-reactive.version>
77+
78+
<!-- in your <dependencyManagement>/<dependencies> block -->
79+
<dependency>
80+
<groupId>org.apache.pulsar</groupId>
81+
<artifactId>pulsar-client-reactive-bom</artifactId>
82+
<version>${pulsar-reactive.version}</version>
83+
<type>pom</type>
84+
<scope>import</scope>
85+
</dependency>
86+
87+
<!-- in your <dependencies> block -->
88+
<dependency>
89+
<groupId>org.apache.pulsar</groupId>
90+
<artifactId>pulsar-client-reactive-adapter</artifactId>
91+
</dependency>
92+
----
93+
94+
=== Spring Boot
95+
When using the Spring Boot Pulsar Reactive starter there is no need to directly specify the client dependency as described above because it will be automatically added to dependencies as a transitive dependency of the `spring-boot-starter-pulsar-reactive` dependency.
96+
97+
The Spring Boot https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html[Dependency Version properties] define `pulsar-reactive.version` for controlling the Pulsar Java Reactive client version.
98+
99+
You can find more information about using Pulsar with Spring Boot in the https://docs.spring.io/spring-boot/reference/messaging/pulsar.html[Spring Boot documentation].
100+
101+
With Gradle:
102+
103+
[source,groovy,subs="verbatim,attributes"]
104+
----
105+
// Alternatively, you can set the `pulsar-reactive.version` property in the `gradle.properties` file.
106+
ext['pulsar-reactive.version'] = '{latest_version}'
107+
108+
dependencies {
109+
implementation 'org.springframework.boot:spring-boot-starter-pulsar-reactive'
110+
}
111+
----
112+
113+
With Maven:
114+
115+
[source,xml,subs="verbatim,attributes"]
116+
----
117+
<!-- in your <properties> block -->
118+
<pulsar-reactive.version>{latest_version}</pulsar-reactive.version>
119+
120+
<!-- in your <dependencies> block -->
121+
<dependency>
122+
<groupId>org.springframework.boot</groupId>
123+
<artifactId>spring-boot-starter-pulsar-reactive</artifactId>
124+
</dependency>
125+
----
126+
127+
NOTE: In both Maven and Gradle cases above, the `pulsar-reactive.version` only needs to be specified when you want to override the version of the client that Spring Boot recommends.
128+
53129
== Usage
54130
55131
=== Initializing the library
@@ -111,7 +187,9 @@ Adding Caffeine based producer cache with Maven:
111187
</dependency>
112188
</dependencies>
113189
----
114-
190+
====
191+
[small]#When using the xref:pulsar-client-reactive-bom[BOM] the above dependency version numbers can be omitted#
192+
====
115193
Usage example of cache
116194
117195
[source,java]
@@ -168,6 +246,9 @@ Adding shaded Caffeine based producer cache with Maven:
168246
</dependency>
169247
</dependencies>
170248
----
249+
====
250+
[small]#When using the xref:pulsar-client-reactive-bom[BOM] the above dependency version numbers can be omitted#
251+
====
171252
172253
173254
=== Reading messages

buildSrc/src/main/groovy/pulsar-client-reactive.library-conventions.gradle

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
plugins {
2121
id 'java-library'
22-
id 'maven-publish'
23-
id 'signing'
22+
id 'pulsar-client-reactive.publish-conventions'
2423
}
2524

2625
repositories {
@@ -39,20 +38,13 @@ compileJava {
3938
options.release = 8
4039
}
4140

41+
tasks.withType(Test) {
42+
useJUnitPlatform()
43+
}
44+
4245
publishing {
43-
repositories {
44-
maven {
45-
if (project.hasProperty("publishDebug")) {
46-
url = project.property("publishDebug")
47-
} else {
48-
name = 'asf'
49-
url = version.endsWith('-SNAPSHOT') ? 'https://repository.apache.org/content/repositories/snapshots/' : 'https://repository.apache.org/service/local/staging/deploy/maven2'
50-
credentials(PasswordCredentials)
51-
}
52-
}
53-
}
5446
publications {
55-
mavenJava(MavenPublication) { publication ->
47+
mavenJava(MavenPublication) {
5648
from components.java
5749
versionMapping {
5850
usage('java-api') {
@@ -62,46 +54,6 @@ publishing {
6254
fromResolutionResult()
6355
}
6456
}
65-
pom {
66-
afterEvaluate {
67-
name = project.name
68-
description = project.description
69-
}
70-
url = 'https://github.com/apache/pulsar-client-reactive'
71-
licenses {
72-
license {
73-
name = 'The Apache License, Version 2.0'
74-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
75-
distribution = 'repo'
76-
}
77-
}
78-
developers {
79-
developer {
80-
id = 'lhotari'
81-
name = 'Lari Hotari'
82-
83-
}
84-
developer {
85-
id = 'cbornet'
86-
name = 'Christophe Bornet'
87-
88-
}
89-
}
90-
scm {
91-
connection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git'
92-
developerConnection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git'
93-
url = 'https://github.com/apache/pulsar-client-reactive'
94-
}
95-
}
9657
}
9758
}
9859
}
99-
100-
tasks.withType(Test) {
101-
useJUnitPlatform()
102-
}
103-
104-
signing {
105-
required !project.hasProperty("publishDebug")
106-
sign publishing.publications.mavenJava
107-
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
plugins {
21+
id 'maven-publish'
22+
id 'signing'
23+
}
24+
25+
publishing {
26+
repositories {
27+
maven {
28+
if (project.hasProperty("publishDebug")) {
29+
url = project.property("publishDebug")
30+
} else {
31+
name = 'asf'
32+
url = version.endsWith('-SNAPSHOT') ? 'https://repository.apache.org/content/repositories/snapshots/' : 'https://repository.apache.org/service/local/staging/deploy/maven2'
33+
credentials(PasswordCredentials)
34+
}
35+
}
36+
}
37+
publications {
38+
mavenJava(MavenPublication) { publication ->
39+
pom {
40+
afterEvaluate {
41+
name = project.name
42+
description = project.description
43+
}
44+
url = 'https://github.com/apache/pulsar-client-reactive'
45+
licenses {
46+
license {
47+
name = 'The Apache License, Version 2.0'
48+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
49+
distribution = 'repo'
50+
}
51+
}
52+
developers {
53+
developer {
54+
id = 'lhotari'
55+
name = 'Lari Hotari'
56+
57+
}
58+
developer {
59+
id = 'cbornet'
60+
name = 'Christophe Bornet'
61+
62+
}
63+
}
64+
scm {
65+
connection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git'
66+
developerConnection = 'scm:git:https://github.com/apache/pulsar-client-reactive.git'
67+
url = 'https://github.com/apache/pulsar-client-reactive'
68+
}
69+
}
70+
}
71+
}
72+
}
73+
74+
signing {
75+
required !project.hasProperty("publishDebug")
76+
sign publishing.publications.mavenJava
77+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
plugins {
21+
id 'java-platform'
22+
id 'pulsar-client-reactive.publish-conventions'
23+
}
24+
25+
dependencies {
26+
constraints {
27+
project.rootProject.subprojects
28+
.sort { "$it.name" }
29+
.findAll { it.name != "pulsar-client-reactive-bom" }
30+
.each {
31+
api it
32+
}
33+
}
34+
}
35+
36+
publishing {
37+
publications {
38+
mavenJava(MavenPublication) {
39+
from components.javaPlatform
40+
}
41+
}
42+
}
43+
44+
description = 'Reactive Java client for Apache Pulsar (Bill of Materials)'

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
rootProject.name = 'pulsar-client-reactive'
2121
include 'pulsar-client-reactive-api'
2222
include 'pulsar-client-reactive-adapter'
23+
include 'pulsar-client-reactive-bom'
2324
include 'pulsar-client-reactive-producer-cache-caffeine'
2425
include 'pulsar-client-reactive-producer-cache-caffeine-shaded'
2526
include 'pulsar-client-reactive-jackson'

0 commit comments

Comments
 (0)