loki4j / loki-logback-appender

Fast and lightweight implementation of Logback appender for Grafana Loki
https://loki4j.github.io/loki-logback-appender/
BSD 2-Clause "Simplified" License
300 stars 26 forks source link

Java 8 support #9

Closed nehaev closed 3 years ago

nehaev commented 3 years ago

Initially the project was build around java.net.http.HttpClient and the idea to provide Loki appender with no extra dependencies. The API of HttpClient was stabilized in Java 11, that's why Loki4j was initially targeted to Java 11+.

Now that support for Apache HttpClient is added, we can think of Java 8 support as well. What if we provide a separate build for Java 8 with everything included except the part that directly depends on Java 11 (i.e. LokiJavaHttpAppender)?

How to compile the code written in Java 11 syntax to target Java 8? I'm aware of two options:

Re-writing the code from the only one officially supported LTS Java platform in favor of legacy Java platform (still popular though) doesn't sound right. Jabel worth nothing to try, so it seems like a way to go unless any significant issues with it reported.

How to deliver a version for Java 8? There are several options:

MR jars have some significant drawbacks:

Classifier is not super popular artifact coordinate, but still its usage as a platform selector is a legitimate use case. A quote from Maven POM reference:

The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number. As a motivation for this element, consider for example a project that offers an artifact targeting Java 11 but at the same time also an artifact that still supports Java 1.8. The first artifact could be equipped with the classifier jdk11 and the second one with jdk8 such that clients can choose which one to use.

In Gradle publish variants are also distinguished by classifier.

Having different artifactId for Java 8 seems even better (easier to find it in Maven Central), but it's harder to implement using Gradle publish plugin. I haven't yet found a proper way of doing this.

So at the moment the most reasonable options seem to be the following:

nehaev commented 3 years ago

In the end I figured out how publish different artifactId for Java 8 in Gradle. So I stick with the following options: