-
Notifications
You must be signed in to change notification settings - Fork 75
Working with the Code
See the CONTRIBUTING guide for information on how to contribute issues and code changes to the project.
Spring Pulsar source can be built from the command line using Gradle.
We include Gradle’s wrapper scripts (./gradlew
or gradlew.bat
) that you can run rather than needing to install Gradle locally.
The project requires Java 17 and can be built from the root directory using the standard Gradle command:
./gradlew build
Some integration tests that run as part of the Spring Pulsar build rely on a Docker daemon to test against live services using Testcontainers. These tests will be skipped if a local Docker daemon is not available.
If you have performed a checkout of this repository already, use “File” → “Open” and then select the root build.gradle
file to import the code.
Note
|
If you encounter an error around
|
The formatter plugin will allow you to format your code from within IDEA.
-
Download the latest IntelliJ IDEA plugin jar.
-
Select “IntelliJ IDEA” → “Preferences”.
-
Select “Plugins”.
-
Select the wheel and “Install Plugin from Disk…”.
-
Select the jar file you’ve downloaded.
The formatter does not cover all rules (such as order of imports) and an additional file needs to be added.
-
Select “IntelliJ IDEA” → “Preferences”.
-
Select “Editor” → “Code Style”.
-
Select the wheel and “Import Scheme” → “IntelliJ IDEA code style XML”.
-
Select
idea/codeStyleConfig.xml
from this repository.
While not strictly required, the CheckStyle-IDEA plugin hooks in the formatter rules and your local checkstyles so that any checkstyle related operations in IDEA use the rules you expect.
-
Download the latest CheckStyle-IDEA plugin.
-
Select “IntelliJ IDEA” → “Preferences”.
-
Select “Plugins”.
-
Select the wheel and “Install Plugin from Disk…”.
-
Select the zip file you’ve downloaded.
-
Download the latest spring-javaformat-checkstyle jar
-
Download the latest spring-javaformat-config jar
-
Select “IntelliJ IDEA” → “Preferences” → “Tools” → “Checkstyle”.
-
Specify the appropriate Checkstyle version (currently
9.3
) -
Add the downloaded
spring-javaformat-checkstyle-0.0.35.jar
andspring-javaformat-config-0.0.35.jar
to the “Third-Party Checks” -
Select “+” on “Configuration File” to add configuration file
-
Use Description: "Spring Pulsar checkstyle"
-
Select "Use a local checkstyle file" and navigate to "src/checkstyle/checkstyle.xml"
-
Enter "config_loc" of "src/checkstyle" if prompted
-
Select "Next"
-
The reference documentation is stored in this repository, see spring-pulsar-docs/src/main/antora/modules/ROOT/pages
.
We use Asciidoc and you can build the documentation locally using this command:
./gradlew spring-pulsar-docs:build
Note
|
The generated HTML documentation is available from spring-pulsar-docs/build/site/index.html .
|
After changing some code you may encounter formatting violations during a build. These errors generally look like the following exmample:
$ ./gradlew build -x test
> Task :spring-pulsar:checkFormatMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':spring-pulsar:checkFormatMain'.
> Formatting violations found in the following files:
* src/main/java/org/springframework/pulsar/core/PulsarTemplate.java
Run `format` to fix.
As the error message suggests, you can run the following command to automatically fix most of these violations:
./gradlew format
If there are still violations after running format
then you must manually fix the reported issue(s).
More information on formatting can be found in the CONTRIBUTING guide.
After adding new dependencies you may encounter prohibited dependency violations during a build. These errors generally look like the following example:
$ ./gradlew build -x test
> Task :spring-pulsar-docs:checkCompileClasspathForProhibitedDependencies FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':spring-pulsar-docs:checkCompileClasspathForProhibitedDependencies'.
> Found prohibited dependencies:
javax.activation:javax.activation-api
The build ensures that the classpaths do not contain any "prohibited" dependencies. In the above example, it flagged javax.activation:javax.activation-api
as the culprit.
You can use the Gradle dependency insight report to identify the origin of the violator. For example:
$ ./gradlew spring-pulsar:dependencyInsight --dependency javax.activation:javax.activation-api
> Task :spring-pulsar:dependencyInsight
javax.activation:javax.activation-api:1.2.0
variant "compile" [
org.gradle.status = release (not requested)
org.gradle.usage = java-api
org.gradle.libraryelements = jar (compatible with: classes)
org.gradle.category = library
Requested attributes not found in the selected variant:
org.gradle.dependency.bundling = external
org.gradle.jvm.environment = standard-jvm
org.gradle.jvm.version = 17
]
javax.activation:javax.activation-api:1.2.0
\--- javax.xml.bind:jaxb-api:2.3.1
+--- compileClasspath
\--- org.apache.pulsar:pulsar-client-admin:2.10.1
+--- compileClasspath (requested org.apache.pulsar:pulsar-client-admin)
\--- project :spring-pulsar-dependencies
\--- compileClasspath
(*) - dependencies omitted (listed previously)
In this case, we can see that the javax.xml.bind:jaxb-api:2.3.1
is transitively bringing in the dependency.
Most likely this is the recently added dependency that is causing the violation.
The typical solution is to exclude the transitive violator such as:
api ('javax.xml.bind:jaxb-api:2.3.1') {
exclude group: 'javax.activation', module: 'javax.activation-api'
}
Some files in the git repository may exceed the Windows maximum file path (260 characters), depending on where you clone the repository.
If you get Filename too long
errors, set the core.longPaths=true
git option:
git clone -c core.longPaths=true https://github.com/spring-projects-experimental/spring-pulsar