Skip to content

Commit

Permalink
Add a tool to manipulate plugin descriptors (#139)
Browse files Browse the repository at this point in the history
The tool is based on picocli and supports the following commands:

* `toJson`: converts a `Log4j2Plugins.dat` to a JSON representation.
* `fromJson`: converts the JSON representation of a plugin descriptor to its `Log4j2Plugins.dat` form.
* `filterReflectConfig`: filters a GraalVM `reflect-config.json` file by removing the classes that are not contained in a `Log4j2Plugins.json` file.
  • Loading branch information
ppkarwasz authored Nov 7, 2024
1 parent bdd205e commit bf7f0b0
Show file tree
Hide file tree
Showing 17 changed files with 1,410 additions and 81 deletions.
11 changes: 6 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Checked by Spotless (LF line endings)
*.java text eol=lf
*.xml text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
# All text files with LF line endings
* text=auto eol=lf
# Maven Wrapper cmd script
/mvnw.cmd eol=crlf
# Maven Wrapper need LF line endings
/.mvn/wrapper/maven-wrapper.properties eol=lf
17 changes: 17 additions & 0 deletions log4j-codegen/.picocli-application-activator
Original file line number Diff line number Diff line change
@@ -0,0 +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.
#
This file activates the `picocli` profile
68 changes: 1 addition & 67 deletions log4j-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@
<scope>provided</scope>
</dependency>

<!-- Compile dependencies: the artifact is shaded, so limit these to the maximum -->
<!-- Compile dependencies: the artifact is shaded, so limit these. -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>

<!-- Test dependencies -->
Expand All @@ -89,69 +88,4 @@

</dependencies>

<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths combine.children="append">
<path>
<groupId>info.picocli</groupId>
<artifactId>picocli-codegen</artifactId>
<version>${picocli.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>shade-jar-with-dependencies</id>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/versions/*/module-info.class</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>
17 changes: 17 additions & 0 deletions log4j-converter-plugin-descriptor/.picocli-application-activator
Original file line number Diff line number Diff line change
@@ -0,0 +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.
#
This file activates the `picocli` profile
125 changes: 125 additions & 0 deletions log4j-converter-plugin-descriptor/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-parent</artifactId>
<version>${revision}</version>
<relativePath>../log4j-transform-parent</relativePath>
</parent>

<artifactId>log4j-converter-plugin-descriptor</artifactId>
<name>Apache Log4j plugin descriptor tools</name>
<description>Tools to manipulate `Log4j2Plugins.dat` plugin descriptors and synchronize them with GraalVM reachability metadata.</description>

<properties>
<!-- Disabling `bnd-baseline-maven-plugin`, since we don't have a release yet to compare against. -->
<bnd.baseline.fail.on.missing>false</bnd.baseline.fail.on.missing>

<Main-Class>org.apache.logging.log4j.converter.plugins.PluginCacheConverter</Main-Class>

<!-- Dependency versions -->
<jackson.version>2.18.0</jackson.version>
</properties>

<dependencies>

<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<scope>provided</scope>
</dependency>

<!-- Compile dependencies: the artifact is shaded, so limit these. -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>

<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-shaded-resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<inlineDescriptors>
<assembly>
<id>shaded-resources</id>
<formats>
<format>jar</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>src/main/shaded-resources</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
</inlineDescriptors>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>shade-jar-with-dependencies</id>
<configuration>
<extraJars>
<jar>${project.build.directory}/${project.build.finalName}-shaded-resources.jar</jar>
</extraJars>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
Loading

0 comments on commit bf7f0b0

Please sign in to comment.