This is an automated email from the ASF dual-hosted git repository.

pkarwasz pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 613b520f65 Fix Apache Rat errors
613b520f65 is described below

commit 613b520f650af4dbc74d42f62b9931bfb71569d4
Author: Piotr P. Karwasz <piotr.git...@karwasz.org>
AuthorDate: Mon Nov 27 17:13:28 2023 +0100

    Fix Apache Rat errors
---
 ...pache.logging.log4j.core.net.MailManagerFactory | 16 ++++++++++
 log4j-osgi-test/pom.xml                            |  2 ++
 .../logging/log4j/osgi/tests/junit/OsgiRule.java   | 34 ++++++++++++++--------
 log4j-osgi-test/src/test/resources/log4j2.custom   | 18 +++++++++++-
 log4j-osgi-test/src/test/resources/osgi.properties | 21 +++++++++++++
 pom.xml                                            |  2 +-
 6 files changed, 79 insertions(+), 14 deletions(-)

diff --git 
a/log4j-jakarta-smtp/src/main/resources/META-INF/services/org.apache.logging.log4j.core.net.MailManagerFactory
 
b/log4j-jakarta-smtp/src/main/resources/META-INF/services/org.apache.logging.log4j.core.net.MailManagerFactory
index 8b89a565e9..df9bb2f2d0 100644
--- 
a/log4j-jakarta-smtp/src/main/resources/META-INF/services/org.apache.logging.log4j.core.net.MailManagerFactory
+++ 
b/log4j-jakarta-smtp/src/main/resources/META-INF/services/org.apache.logging.log4j.core.net.MailManagerFactory
@@ -1 +1,17 @@
+#
+# 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.
+#
 org.apache.logging.log4j.smtp.SmtpManager$SMTPManagerFactory
\ No newline at end of file
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index fbbb6b56f1..a9c4317790 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -198,6 +198,8 @@
             <!-- PAX logging has a copy of Log4j2 API-->
             <pax.exam.logging>false</pax.exam.logging>
             
<java.protocol.handler.pkgs>org.ops4j.pax.url</java.protocol.handler.pkgs>
+            <!-- Used in `osgi.properties -->
+            
<felix.cache.rootdir>${project.build.directory}</felix.cache.rootdir>
           </systemPropertyVariables>
         </configuration>
       </plugin>
diff --git 
a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
 
b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
index 8fc77aaf92..bef1bece8f 100644
--- 
a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
+++ 
b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/junit/OsgiRule.java
@@ -16,8 +16,11 @@
  */
 package org.apache.logging.log4j.osgi.tests.junit;
 
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
+import java.util.stream.Collectors;
 import org.junit.rules.ExternalResource;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.launch.Framework;
@@ -50,18 +53,25 @@ public class OsgiRule extends ExternalResource {
 
     @Override
     protected void before() throws Throwable {
-        final Map<String, String> configMap = new HashMap<>(2);
-        // Cleans framework before first init. Subsequent init invocations do 
not clean framework.
-        configMap.put("org.osgi.framework.storage.clean", "onFirstInit");
-        configMap.put("felix.log.level", "4");
-        configMap.put("eclipse.log.level", "ALL");
-        // Hack to get the build working on Windows. Could try newer versions 
of Felix.
-        configMap.put("felix.cache.locking", "false");
-        // Delegates loading of endorsed libraries to JVM classloader
-        // config.put("org.osgi.framework.bootdelegation", 
"javax.*,org.w3c.*,org.xml.*");
-        framework = factory.newFramework(configMap);
-        framework.init();
-        framework.start();
+        try (final InputStream is = 
OsgiRule.class.getResourceAsStream("/osgi.properties")) {
+            final Properties props = new Properties();
+            props.load(is);
+            final Map<String, String> configMap = props.entrySet().stream()
+                    .collect(Collectors.toMap(
+                            e -> String.valueOf(e.getKey()),
+                            e -> String.valueOf(e.getValue()),
+                            (prev, next) -> next,
+                            HashMap::new));
+            System.getProperties().forEach((k, v) -> {
+                final String key = String.valueOf(k);
+                if (key.startsWith("felix") || key.startsWith("org.osgi")) {
+                    configMap.put(key, String.valueOf(v));
+                }
+            });
+            framework = factory.newFramework(configMap);
+            framework.init();
+            framework.start();
+        }
     }
 
     public Framework getFramework() {
diff --git a/log4j-osgi-test/src/test/resources/log4j2.custom 
b/log4j-osgi-test/src/test/resources/log4j2.custom
index 36435a1e28..5238d0fde8 100644
--- a/log4j-osgi-test/src/test/resources/log4j2.custom
+++ b/log4j-osgi-test/src/test/resources/log4j2.custom
@@ -1 +1,17 @@
-# This file enables the CustomConfigurationFactory
\ No newline at end of file
+#
+# 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.
+#
+This file enables the CustomConfigurationFactory
\ No newline at end of file
diff --git a/log4j-osgi-test/src/test/resources/osgi.properties 
b/log4j-osgi-test/src/test/resources/osgi.properties
new file mode 100644
index 0000000000..f5365f6afa
--- /dev/null
+++ b/log4j-osgi-test/src/test/resources/osgi.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+org.osgi.framework.storage.clean = onFirstInit
+felix.log.level = 4
+eclipse.log.level = ALL
+# Hack to get the build working on Windows. Could try newer versions of Felix.
+felix.cache.locking = false
diff --git a/pom.xml b/pom.xml
index e81d41f111..a25c74be3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -572,7 +572,6 @@
             <exclude>**/.toDelete</exclude>
             <exclude>velocity.log</exclude>
             <!-- Other -->
-            <exclude>felix-cache/**</exclude>
             <exclude>**/README.md</exclude>
             <exclude>SECURITY.md</exclude>
             <exclude>**/*.yml</exclude>
@@ -910,6 +909,7 @@
         </plugins>
       </build>
     </profile>
+
   </profiles>
 
 </project>

Reply via email to