Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document API compatibility checks #3175

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
56 changes: 56 additions & 0 deletions BUILDING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,59 @@ CI=true ./mvnw ...
=== Compilation in IntelliJ IDEA fails with `java: plug-in not found: ErrorProne`

Try removing all _"Override compiler parameters per-module"_ entries in _"Settings > Build, Execution, Deployment > Compiler > Java Compiler"_.

[#development-api-compatibility]
=== Fixing API compatibility check failures

Log4j uses the
https://github.com/bndtools/bnd/tree/master/maven-plugins/bnd-baseline-maven-plugin[BND Baseline Maven Plugin]
to enforce its
https://semver.org/[semantic versioning policy].
Following the
https://bnd.bndtools.org/chapters/170-versioning.html#best-practices[OSGi versioning best practices], both Log4j artifacts and packages are versioned.
If you modify Log4j's public API, a BND Baseline error like the following will occur:

[source]
----
Name Type Delta New Old Suggest If Prov.
org.apache.logging.foo PACKAGE UNCHANGED 2.1.0 2.1.0 ok -
* org.apache.logging.foo.bar PACKAGE MINOR 2.3.4 2.3.4 2.4.0 -
MINOR PACKAGE org.apache.logging.foo.bar
...
----

The solution of the error depends on the change kind (`Delta`):

[#development-api-compatibility-micro]
`MICRO`::
+
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.
+
[source,java]
----
@Version("2.3.5")
package org.apache.logging.foo.bar;
----

[#development-api-compatibility-minor]
`MINOR`::
+
Changes of type `MINOR` require more work:
+
--
* Make sure that the current Log4j version is a minor upgrade over the last released version.
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`).
* Make sure to add a
https://logging.apache.org/log4j/tools/log4j-changelog.html#changelog-entry-file[changelog entry]
of type `added`, `changed` or `deprecated` to your PR.
* As in the
<<development-api-compatibility-micro,`MICRO` case>>
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.
The purpose of this policy is to have an alignment between package versions and the last Log4j version, where an API change occurred.
--

[#development-api-compatibility-major]
`MAJOR`::
+
Changes of type `MAJOR` (i.e. breaking changes) are not accepted in the `2.x` branch.
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.