Skip to content

Commit 82c707f

Browse files
authored
Document API compatibility checks (#3175)
This documents the existence of the BND Baseline API compatibility checks and how to fix the generated errors.
1 parent 5d2b0a0 commit 82c707f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

BUILDING.adoc

+56
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,59 @@ CI=true ./mvnw ...
172172
=== Compilation in IntelliJ IDEA fails with `java: plug-in not found: ErrorProne`
173173
174174
Try removing all _"Override compiler parameters per-module"_ entries in _"Settings > Build, Execution, Deployment > Compiler > Java Compiler"_.
175+
176+
[#development-api-compatibility]
177+
=== Fixing API compatibility check failures
178+
179+
Log4j uses the
180+
https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-baseline-maven-plugin[BND Baseline Maven Plugin]
181+
to enforce its
182+
https://semver.org/[semantic versioning policy].
183+
Following the
184+
https://bnd.bndtools.org/chapters/170-versioning.html#best-practices[OSGi versioning best practices], both Log4j artifacts and packages are versioned.
185+
If you modify Log4j's public API, a BND Baseline error like the following will occur:
186+
187+
[source]
188+
----
189+
Name Type Delta New Old Suggest If Prov.
190+
org.apache.logging.foo PACKAGE UNCHANGED 2.1.0 2.1.0 ok -
191+
* org.apache.logging.foo.bar PACKAGE MINOR 2.3.4 2.3.4 2.4.0 -
192+
MINOR PACKAGE org.apache.logging.foo.bar
193+
...
194+
----
195+
196+
The solution of the error depends on the change kind (`Delta`):
197+
198+
[#development-api-compatibility-micro]
199+
`MICRO`::
200+
+
201+
For patch level changes modify the `package-info.java` file of the `org.apache.logging.foo.bar` package and update the `@Version` annotation to the number suggested by BND: increment just the patch number.
202+
+
203+
[source,java]
204+
----
205+
@Version("2.3.5")
206+
package org.apache.logging.foo.bar;
207+
----
208+
209+
[#development-api-compatibility-minor]
210+
`MINOR`::
211+
+
212+
Changes of type `MINOR` require more work:
213+
+
214+
--
215+
* Make sure that the current Log4j version is a minor upgrade over the last released version.
216+
If that is not the case (e.g., it is `2.34.5-SNAPSHOT`) modify the `<revision>` property in the main POM file (e.g., change it to `2.35.0-SNAPSHOT`).
217+
* Make sure to add a
218+
https://logging.apache.org/log4j/tools/log4j-changelog.html#changelog-entry-file[changelog entry]
219+
of type `added`, `changed` or `deprecated` to your PR.
220+
* As in the
221+
<<development-api-compatibility-micro,`MICRO` case>>
222+
modify the `package-info.java` file of the package and update the `@Version` annotation to the **next Log4j version** (`2.35.0` in the example) and **not** the minimal version number suggested by BND.
223+
The purpose of this policy is to have an alignment between package versions and the last Log4j version, where an API change occurred.
224+
--
225+
226+
[#development-api-compatibility-major]
227+
`MAJOR`::
228+
+
229+
Changes of type `MAJOR` (i.e. breaking changes) are not accepted in the `2.x` branch.
230+
If you believe it is not a breaking change (e.g., you removed a class **documented** as private), the development team will guide you on how to solve it.

0 commit comments

Comments
 (0)