Skip to content

Commit f8f9249

Browse files
jvzppkarwasz
andauthored
Document API compatibility checks (#3175) (#3858)
This documents the existence of the BND Baseline API compatibility checks and how to fix the generated errors. Co-authored-by: Piotr P. Karwasz <[email protected]>
1 parent 0aeb58c commit f8f9249

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

BUILDING.adoc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,59 @@ Try removing all _"Override compiler parameters per-module"_ entries in _"Settin
144144
=== Compilation in IntelliJ IDEA fails with `java: package org.apache.logging.log4j.plugins.test.validation.plugins does not exist`
145145
146146
We don't know how to fix this.
147+
148+
[#development-api-compatibility]
149+
=== Fixing API compatibility check failures
150+
151+
Log4j uses the
152+
https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-baseline-maven-plugin[BND Baseline Maven Plugin]
153+
to enforce its
154+
https://semver.org/[semantic versioning policy].
155+
Following the
156+
https://bnd.bndtools.org/chapters/170-versioning.html#best-practices[OSGi versioning best practices], both Log4j artifacts and packages are versioned.
157+
If you modify Log4j's public API, a BND Baseline error like the following will occur:
158+
159+
[source]
160+
----
161+
Name Type Delta New Old Suggest If Prov.
162+
org.apache.logging.foo PACKAGE UNCHANGED 2.1.0 2.1.0 ok -
163+
* org.apache.logging.foo.bar PACKAGE MINOR 2.3.4 2.3.4 2.4.0 -
164+
MINOR PACKAGE org.apache.logging.foo.bar
165+
...
166+
----
167+
168+
The solution of the error depends on the change kind (`Delta`):
169+
170+
[#development-api-compatibility-micro]
171+
`MICRO`::
172+
+
173+
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.
174+
+
175+
[source,java]
176+
----
177+
@Version("2.3.5")
178+
package org.apache.logging.foo.bar;
179+
----
180+
181+
[#development-api-compatibility-minor]
182+
`MINOR`::
183+
+
184+
Changes of type `MINOR` require more work:
185+
+
186+
--
187+
* Make sure that the current Log4j version is a minor upgrade over the last released version.
188+
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`).
189+
* Make sure to add a
190+
https://logging.apache.org/log4j/tools/log4j-changelog.html#changelog-entry-file[changelog entry]
191+
of type `added`, `changed` or `deprecated` to your PR.
192+
* As in the
193+
<<development-api-compatibility-micro,`MICRO` case>>
194+
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.
195+
The purpose of this policy is to have an alignment between package versions and the last Log4j version, where an API change occurred.
196+
--
197+
198+
[#development-api-compatibility-major]
199+
`MAJOR`::
200+
+
201+
Changes of type `MAJOR` (i.e. breaking changes) are not accepted in the `2.x` branch.
202+
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)