Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Most of the ideas in this project are borrowed from the Spring for Apache Kafka

**Apache Pulsar** - 2.10.0

**Spring Boot** - 3.0.0

**Spring Framework** - 6.0.0

```
./gradlew clean build
```
Expand Down
132 changes: 99 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
buildscript {
// repositories {
// mavenCentral()
// maven { url 'https://plugins.gradle.org/m2' }
// maven { url 'https://repo.spring.io/plugins-release' }
// mavenLocal()
// }
repositories {
mavenCentral()
gradlePluginPortal()
Expand All @@ -17,7 +11,7 @@ plugins {
id 'project-report'
id 'idea'
id 'org.sonarqube' version '2.8'
// id 'org.ajoberstar.grgit' version '4.0.1' apply false
id 'org.ajoberstar.grgit' version '4.0.1' apply false
id 'io.spring.nohttp' version '0.0.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE' apply false
id 'com.jfrog.artifactory' version '4.18.2' apply false
Expand All @@ -28,36 +22,46 @@ plugins {

apply plugin: 'io.spring.nohttp'

//def gitPresent = new File('.git').exists()
def gitPresent = new File('.git').exists()

//if(gitPresent) {
// apply plugin: 'org.ajoberstar.grgit'
//}
if (gitPresent) {
apply plugin: 'org.ajoberstar.grgit'
}

description = 'Spring for Apache Pulsar'

ext {
// if (gitPresent) {
// modifiedFiles =
// files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
// }
linkHomepage = 'https://github.com/spring-projects-experimental/spring-pulsar'
linkIssue = 'https://github.com/spring-projects-experimental/spring-pulsar/issues'
linkScmUrl = 'https://github.com/spring-projects-experimental/spring-pulsar'
linkScmConnection = 'https://github.com/spring-projects-experimental/spring-pulsar.git'
linkScmDevConnection = '[email protected]:spring-projects-experimental/spring-pulsar.git'
docResourcesVersion = '0.2.5'

javadocLinks = [
'https://docs.oracle.com/en/java/javase/17/docs/api/',
'https://docs.spring.io/spring-framework/docs/current/javadoc-api/'
] as String[]

if (gitPresent) {
modifiedFiles =
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') }
}

assertjVersion = '3.21.0'
awaitilityVersion = '4.1.1'
assertjVersion = '3.22.0'
awaitilityVersion = '4.2.0'
googleJsr305Version = '3.0.2'
hamcrestVersion = '2.2'
hibernateValidationVersion = '6.2.3.Final'
jacksonBomVersion = '2.13.2.20220328'
hibernateValidationVersion = '7.0.4.Final'
jacksonBomVersion = '2.13.3'
jaywayJsonPathVersion = '2.6.0'
junit4Version = '4.13.2'
junitJupiterVersion = '5.8.2'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can instead pull in the junit bom under dependency mgmt which would get rid of some of these version specified I believe. Same as what spring-framework does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i just followed what Spring-Kafka does. We can do that. Feel free to make that change once this PR is merged.

pulsarVersion = '2.10.0'
log4jVersion = '2.17.2'
// micrometerVersion = '2.0.0-SNAPSHOT'
mockitoVersion = '4.0.0'
mockitoVersion = '4.5.1'
reactorVersion = '2020.0.17'
springBootVersion = '3.0.0-SNAPSHOT' // docs module
springRetryVersion = '1.3.2'
springRetryVersion = '1.3.3'
springVersion = '6.0.0-SNAPSHOT'

idPrefix = 'pulsar'
Expand Down Expand Up @@ -105,11 +109,11 @@ allprojects {
subprojects { subproject ->
apply plugin: 'java-library'
apply plugin: 'java'
// apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'jacoco'
// apply plugin: 'checkstyle'
apply plugin: 'checkstyle'

java {
withJavadocJar()
Expand Down Expand Up @@ -162,12 +166,9 @@ subprojects { subproject ->
testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the actual dependencies, should we specify the versions in dependencyManagement section and then just specify group/artifiact in the actual dependencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may not have to - i followed what SK does.

optionalApi "org.assertj:assertj-core:$assertjVersion"



testImplementation("org.testcontainers:pulsar:1.17.2") {
exclude module: 'log4j-to-slf4j'
}

}

// enable all compiler warnings; individual projects may customize further
Expand Down Expand Up @@ -208,15 +209,68 @@ subprojects { subproject ->
}
}

publishing {
publications {
mavenJava(MavenPublication) {
suppressAllPomMetadataWarnings()
from components.java
pom.withXml {
def pomDeps = asNode().dependencies.first()
subproject.configurations.providedImplementation.allDependencies.each { dep ->
pomDeps.remove(pomDeps.'*'.find { it.artifactId.text() == dep.name })
pomDeps.appendNode('dependency').with {
it.appendNode('groupId', dep.group)
it.appendNode('artifactId', dep.name)
it.appendNode('version', dep.version)
it.appendNode('scope', 'provided')
}
}
}
}
}
}

task updateCopyrights {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition!

onlyIf { gitPresent && !System.getenv('GITHUB_ACTION') }
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
inputs.files.each { file ->
def line
file.withReader { reader ->
while (line = reader.readLine()) {
def matcher = line =~ /Copyright (20\d\d)-?(20\d\d)?/
if (matcher.count) {
def beginningYear = matcher[0][1]
if (now != beginningYear && now != matcher[0][2]) {
def years = "$beginningYear-$now"
def sourceCode = file.text
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
file.write(sourceCode)
println "Copyright updated for file: $file"
}
break
}
}
}
}
}
}


jar {
manifest {
attributes(
'Implementation-Version': archiveVersion,
// 'Created-By': "JDK ${System.properties['java.version']} (${System.properties['java.specification.vendor']})",
'Created-By': "JDK ${System.properties['java.version']} (${System.properties['java.specification.vendor']})",
'Implementation-Title': subproject.name,
'Implementation-Vendor-Id': subproject.group,
'Implementation-Vendor': 'Pivotal Software, Inc.',
// 'Implementation-URL': linkHomepage,
'Implementation-URL': linkHomepage,
'Automatic-Module-Name': subproject.name.replace('-', '.') // for Jigsaw
)
}
Expand All @@ -227,6 +281,10 @@ subprojects { subproject ->
into 'META-INF'
expand(copyright: new Date().format('yyyy'), version: project.version)
}
from("${rootProject.projectDir}") {
include 'LICENSE.txt'
into 'META-INF'
}
}

tasks.withType(Javadoc) {
Expand Down Expand Up @@ -262,13 +320,10 @@ project ('spring-pulsar') {
optionalApi "com.jayway.jsonpath:json-path:$jaywayJsonPathVersion"

optionalApi 'io.projectreactor:reactor-core'
// optionalApi "io.micrometer:micrometer-core:$micrometerVersion"

testImplementation 'io.projectreactor:reactor-test'
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation "org.hibernate.validator:hibernate-validator:$hibernateValidationVersion"

testImplementation project (':spring-pulsar-boot-autoconfigure')
}
}

Expand Down Expand Up @@ -296,3 +351,14 @@ project ('spring-pulsar-sample-apps') {
}
}

sonarqube {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition! I saw this and the copyrights in spring-integration and was wanting to add it here as well. You beat me to it. :)

properties {
property 'sonar.links.homepage', linkHomepage
property 'sonar.links.ci', linkCi
property 'sonar.links.issue', linkIssue
property 'sonar.links.scm', linkScmUrl
property 'sonar.links.scm_dev', linkScmDevConnection
}
}


52 changes: 52 additions & 0 deletions publish-maven.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'

publishing {
publications {
mavenJava(MavenPublication) {
pom {
afterEvaluate {
name = project.description
description = project.description
}
url = linkScmUrl
// organization {
// name = 'Spring IO'
// url = 'https://spring.io/projects/spring-pulsar'
// }
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
scm {
url = linkScmUrl
connection = linkScmConnection
developerConnection = linkScmDevConnection
}
// developers {
//
// }
issueManagement {
system = 'GitHub'
url = linkIssue
}
}
versionMapping {
usage('java-api') {
fromResolutionResult()
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}

artifactoryPublish {
dependsOn build
publications(publishing.publications.mavenJava)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.springframework.pulsar.listener.PulsarContainerProperties;

/**
* Configuration for Pulsar annotation-driven support.
*
* @author Soby Chacko
*/
@Configuration(proxyBeanMethods = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.pulsar.core.DefaultPulsarConsumerFactory;
import org.springframework.pulsar.core.DefaultPulsarProducerFactory;
import org.springframework.pulsar.config.PulsarClientConfiguration;
import org.springframework.pulsar.config.PulsarClientFactoryBean;
import org.springframework.pulsar.core.DefaultPulsarConsumerFactory;
import org.springframework.pulsar.core.DefaultPulsarProducerFactory;
import org.springframework.pulsar.core.PulsarConsumerFactory;
import org.springframework.pulsar.core.PulsarProducerFactory;
import org.springframework.pulsar.core.PulsarTemplate;

/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration Auto-configuration} for Apache Pulsar.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit/Question] I wonder if it is sufficient to just link to org.springframework.boot.autoconfigure.Autoconfiguration now that its a 1st class thing in SB3?

Also, does this have to be fully specified like it is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can do it that way. Feel free to do that as part of the cleanup that you will do in the boot module.

*
* @author Soby Chacko
*/
@AutoConfiguration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@
import org.apache.pulsar.client.api.RegexSubscriptionMode;
import org.apache.pulsar.client.api.SubscriptionInitialPosition;
import org.apache.pulsar.client.api.SubscriptionType;
import org.apache.pulsar.common.schema.SchemaType;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;

/**
* Configuration properties for Spring for Apache Pulsar.
* <p>
* Users should refer to Pulsar documentation for complete descriptions of these
* properties.
*
* @author Soby Chacko
*/
@ConfigurationProperties(prefix = "spring.pulsar")
Expand Down Expand Up @@ -380,31 +384,31 @@ public static class Producer {
private ProducerAccessMode producerAccessMode = ProducerAccessMode.Shared;

public String getTopicName() {
return topicName;
return this.topicName;
}

public void setTopicName(String topicName) {
this.topicName = topicName;
}

public String getProducerName() {
return producerName;
return this.producerName;
}

public void setProducerName(String producerName) {
this.producerName = producerName;
}

public long getSendTimeoutMs() {
return sendTimeoutMs;
return this.sendTimeoutMs;
}

public void setSendTimeoutMs(long sendTimeoutMs) {
this.sendTimeoutMs = sendTimeoutMs;
}

public boolean isBlockIfQueueFull() {
return blockIfQueueFull;
return this.blockIfQueueFull;
}

public void setBlockIfQueueFull(boolean blockIfQueueFull) {
Expand Down Expand Up @@ -569,7 +573,7 @@ public static class Client {

private int requestTimeoutMs = 60000;

private long initialBackoffIntervalNanos = TimeUnit.MILLISECONDS.toNanos(100);;
private long initialBackoffIntervalNanos = TimeUnit.MILLISECONDS.toNanos(100);

private long maxBackoffIntervalNanos = TimeUnit.SECONDS.toNanos(30);

Expand Down
Loading