Skip to content

Commit

Permalink
Add BND configuration for log4j-core
Browse files Browse the repository at this point in the history
The following packages are no longer exported:

 *  org.apache.logging.log4j.core.layout.internal
 *  org.apache.logging.log4j.core.message
 *  org.apache.logging.log4j.core.time.internal
 *  org.apache.logging.log4j.core.tools.picocli
 *  org.apache.logging.log4j.core.util.internal

A new JPMS module is generated, which sets the following Java modules as
optional:
 *  java.compiler,
 *  java.logging,
 *  java.naming,
 *  java.sql.
  • Loading branch information
ppkarwasz committed Sep 26, 2023
1 parent 3b0009a commit 0079b83
Show file tree
Hide file tree
Showing 59 changed files with 253 additions and 22 deletions.
37 changes: 37 additions & 0 deletions log4j-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,43 @@
<javadoc.skip>false</javadoc.skip>
<!-- TODO: fix errors an reenable SpotBugs -->
<spotbugs.skip>true</spotbugs.skip>

<!--
~ OSGi and JPMS options
-->
<bnd-multi-release>true</bnd-multi-release>
<bnd-extra-package-options>
<!-- External optional dependencies -->
com.conversantmedia.util.concurrent;resolution:=optional;
com.fasterxml.jackson.*;resolution:=optional,
com.lmax.disruptor.*;resolution:=optional,
javax.activation;resolution:=optional,
javax.jms;version="[1.1,3)";resolution:=optional,
javax.mail.*;version="[1.6,2)";resolution:=optional,
org.apache.commons.compress.*;resolution:=optional,
org.apache.commons.csv;resolution:=optional,
org.apache.kafka.*;resolution:=optional,
org.codehaus.stax2;resolution:=optional,
org.fusesource.jansi;resolution:=optional,
org.jctools.*;resolution:=optional,
org.zeromq;resolution:=optional,
<!-- `java.compiler` is optional -->
javax.annotation.processing;resolution:=optional,
javax.lang.model.*;resolution:=optional,
javax.tools;resolution:=optional,
<!-- `java.sql`, which depends on `java.logging` is optional -->
javax.sql;resolution:=optional,
java.util.logging;resolution:=optional,
<!-- `java.naming` is optional -->
javax.naming;resolution:=optional
</bnd-extra-package-options>
<bnd-extra-module-options>
<!-- OSGI is optional in JPMS -->
org.osgi.core;static=true,
<!-- BND seems to always add `java.logging` (dependency of `java.sql`) -->
java.logging;static=true,
java.sql;static=true
</bnd-extra-module-options>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
* The JDBC Appender supports writing log events to a relational database using standard JDBC connections. You will need
* a JDBC driver on your classpath for the database you wish to log to.
*/
@Export
package org.apache.logging.log4j.core.appender.db.jdbc;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
* The classes in this package and sub packages provide appenders for various types of databases and methods for
* accessing databases.
*/
@Export
package org.apache.logging.log4j.core.appender.db;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.4
*/
@Export
package org.apache.logging.log4j.core.appender.mom.jeromq;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.4
*/
@Export
package org.apache.logging.log4j.core.appender.mom.kafka;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.1
*/
@Export
package org.apache.logging.log4j.core.appender.mom;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
* {@link org.apache.logging.log4j.core.appender.nosql.NoSqlConnection NoSqlConnection}, and
* {@link org.apache.logging.log4j.core.appender.nosql.NoSqlProvider NoSqlProvider}.
*/
@Export
package org.apache.logging.log4j.core.appender.nosql;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Log4j 2 Appenders.
*/
@Export
package org.apache.logging.log4j.core.appender;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
*/
@Export
package org.apache.logging.log4j.core.appender.rewrite;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Support classes for the Rolling File Appender.
*/
@Export
package org.apache.logging.log4j.core.appender.rolling.action;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Rolling File Appender and support classes.
*/
@Export
package org.apache.logging.log4j.core.appender.rolling;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Apache Flume Appender. Requires the user specifically include Flume and its dependencies.
*/
@Export
package org.apache.logging.log4j.core.appender.routing;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Provides Asynchronous Logger classes and interfaces for low-latency logging.
*/
@Export
package org.apache.logging.log4j.core.async;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Export
package org.apache.logging.log4j.core.config.arbiters;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
*
* @since 2.4
*/
@Export
package org.apache.logging.log4j.core.config.builder.api;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
*
* @since 2.4
*/
@Export
package org.apache.logging.log4j.core.config.builder.impl;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/**
* Support for composite configurations.
*/
@Export
package org.apache.logging.log4j.core.config.composite;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Classes and interfaces supporting configuration of Log4j 2 with JSON.
*/
@Export
package org.apache.logging.log4j.core.config.json;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Configuration of Log4j 2.
*/
@Export
package org.apache.logging.log4j.core.config;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
* TypeConverter plugins for converter strings into various types. These plugins are used for parsing plugin
* attributes in plugin factory methods.
*/
@Export
package org.apache.logging.log4j.core.config.plugins.convert;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/**
* Annotations for Log4j 2 plugins.
*/
@Export
package org.apache.logging.log4j.core.config.plugins;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
Expand All @@ -39,6 +40,8 @@
import javax.tools.FileObject;
import javax.tools.StandardLocation;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAliases;
import org.apache.logging.log4j.util.Strings;
Expand All @@ -48,6 +51,7 @@
/**
* Annotation processor for pre-scanning Log4j 2 plugins.
*/
@ServiceProvider(value = Processor.class, resolution = Resolution.OPTIONAL)
@SupportedAnnotationTypes("org.apache.logging.log4j.core.config.plugins.*")
public class PluginProcessor extends AbstractProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
* Java annotation processor for pre-scanning Log4j 2 plugins. This is provided as an alternative to using the
* executable {@link org.apache.logging.log4j.core.config.plugins.util.PluginManager} class in your build process.
*/
@Export
package org.apache.logging.log4j.core.config.plugins.processor;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/**
* Utility and manager classes for Log4j 2 plugins.
*/
@Export
package org.apache.logging.log4j.core.config.plugins.util;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.1
*/
@Export
package org.apache.logging.log4j.core.config.plugins.validation.constraints;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.1
*/
@Export
package org.apache.logging.log4j.core.config.plugins.validation;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
*
* @since 2.1
*/
@Export
package org.apache.logging.log4j.core.config.plugins.validation.validators;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
* and the corresponding annotation must be annotated with
* {@link org.apache.logging.log4j.core.config.plugins.PluginVisitorStrategy}.
*/
@Export
package org.apache.logging.log4j.core.config.plugins.visitors;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Configuration using Properties files.
*/
@Export
package org.apache.logging.log4j.core.config.properties;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/**
* Configuration classes for the {@link org.apache.logging.log4j.status.StatusLogger} API.
*/
@Export
package org.apache.logging.log4j.core.config.status;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Classes and interfaces supporting configuration of Log4j 2 with XML.
*/
@Export
package org.apache.logging.log4j.core.config.xml;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Classes and interfaces supporting configuration of Log4j 2 with YAML.
*/
@Export
package org.apache.logging.log4j.core.config.yaml;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Export
package org.apache.logging.log4j.core.filter.mutable;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
* {@linkplain org.apache.logging.log4j.core.config.plugins.Plugin#elementType() element type}
* {@link org.apache.logging.log4j.core.Filter#ELEMENT_TYPE filter}.
*/
@Export
package org.apache.logging.log4j.core.filter;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
*/
package org.apache.logging.log4j.core.impl;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.logging.log4j.spi.Provider;

/**
* Binding for the Log4j API.
*/
@ServiceProvider(value = Provider.class, resolution = Resolution.OPTIONAL)
public class Log4jProvider extends Provider {
public Log4jProvider() {
super(10, "2.6.0", Log4jContextFactory.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

import java.util.Map;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.util.ContextDataProvider;
import org.apache.logging.log4j.util.StringMap;

/**
* ContextDataProvider for ThreadContext data.
*/
@ServiceProvider(value = ContextDataProvider.class, resolution = Resolution.OPTIONAL)
public class ThreadContextDataProvider implements ContextDataProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
/**
* Log4j 2 private implementation classes.
*/
@Export
package org.apache.logging.log4j.core.impl;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
* Classes and interfaces for serializing and deserializing Log4j 2 log events to XML and JSON using the Jackson
* library.
*/
@Export
package org.apache.logging.log4j.core.jackson;

import org.osgi.annotation.bundle.Export;

0 comments on commit 0079b83

Please sign in to comment.