Skip to content

Commit

Permalink
fix(log4j): add missing Log4j Core plugin descriptor (5848)
Browse files Browse the repository at this point in the history
Fix fabric8io#5847: missing Log4j Core plugin descriptor

Due to a misconfiguration of the Maven Bundle Plugin, the Log4j Core
plugin descriptor:

```
META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
```

file is missing in the generated JAR.

This PR fixes the Maven configuration and adds a simple integration test
to prevent ensure that `PluginManager` is able to detect the Kubernetes
Lookup.
---
Add changelog for fabric8io#5848
---
Remove `public` modifier from JUnit 5 test
  • Loading branch information
ppkarwasz committed Apr 10, 2024
1 parent dd53202 commit fb0683e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#### Bugs
* Fix #5845: (crd-generator) Fail generating if multiple versions are marked as stored
* Fix #5847: Missing `Log4j2Plugins.dat` descriptor in Kubernetes Lookup
* Fix #5853: [java-generator] Gracefully handle colliding enum definitions
* Fix #5860: Corrections to java-generator gradle plugin extension
* Fix #5817: NPE on EKS OIDC cluster when token needs to be refreshed
Expand Down
26 changes: 26 additions & 0 deletions log4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
<properties>
<osgi.export>io.fabric8.kubernetes.log4j.*</osgi.export>
<osgi.import>*</osgi.import>

<!-- Resources to copy into the JAR -->
<osgi.include.resources.default>
{maven-resources},
/META-INF/org/apache/logging/=${project.build.outputDirectory}/META-INF/org/apache/logging/,
/META-INF/jandex.idx=${project.build.outputDirectory}/META-INF/jandex.idx
</osgi.include.resources.default>
</properties>

<dependencies>
Expand Down Expand Up @@ -78,4 +85,23 @@
</dependency>
</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed 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.
*/
package io.fabric8.kubernetes.log4j.lookup.it;

import io.fabric8.kubernetes.log4j.lookup.KubernetesLookup;
import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
import org.apache.logging.log4j.core.config.plugins.util.PluginType;
import org.apache.logging.log4j.core.lookup.StrLookup;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class KubernetesLookupIT {

@Test
void should_find_lookup() {
PluginManager manager = new PluginManager(StrLookup.CATEGORY);
manager.collectPlugins();
PluginType<?> pluginType = manager.getPluginType("k8s");
assertThat(pluginType)
.as("check 'k8s' lookup")
.isNotNull()
.extracting(PluginType::getPluginClass)
.isEqualTo(KubernetesLookup.class);
}
}

0 comments on commit fb0683e

Please sign in to comment.