logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Upgrading to 2.24.1 produces a compile time warning: BaselineIgnore not found

Open lbergelson opened this issue 1 year ago • 1 comments

Description

We're trying to update from 2.17.1 -> 2.24.1 but we've encountered compile warnings due to missing annotations. It looks like essentially the same same issue as https://github.com/apache/logging-log4j2/issues/2144 and https://github.com/apache/logging-log4j2/issues/2232

Configuration

Version:. 2.24.1 Operating system: OSX Sonoma 14.4 JDK: openjdk 17.0.12 2024-07-16 OpenJDK Runtime Environment Homebrew (build 17.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)

Logs

/gradlew compileTestjava

Task :compileJava /Users/louisb/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.24.1/7ebeb12c20606373005af4232cd0ecca72613dda/log4j-api-2.24.1.jar(/org/apache/logging/log4j/Level.class): warning: Cannot find annotation method 'value()' in type 'BaselineIgnore': class file for aQute.bnd.annotation.baseline.BaselineIgnore not found

Reproduction

Update log4j to 2.24.1 in our build.gradle

    platform('org.apache.logging.log4j:log4j-bom:2.24.1)
    implementation 'org.apache.logging.log4j:log4j-api'
    implementation 'org.apache.logging.log4j:log4j-core'

This was very surprising to me. Have you considered changing the annotation dependencies to be included. Or they processed out of the published jar?

We need to include log4j-core at compile time, because we want to change the default logging level at runtime based on command line input from the user. If there is a way to do this through the API we would be happy to switch.

I've solved the warning by adding 2 additional dependencies

    implementation 'biz.aQute.bnd:biz.aQute.bnd.annotation'
    implementation 'org.osgi:org.osgi.annotation.bundle'

Just adding biz.aQute.bnd:biz.aQute.bnd.annotation causes additional failures because it includes OSGI bundle annotations which are not included in it's dependency list.

I feel like I'm doing something wrong but I'm not really sure what I should be doing instead.

lbergelson avatar Oct 18 '24 17:10 lbergelson