| <?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</groupId> |
| <artifactId>logging-parent</artifactId> |
| <version>11.3.0</version> |
| <relativePath /> |
| </parent> |
| |
| <groupId>org.apache.logging.log4j.samples</groupId> |
| <artifactId>log4j-samples-graalvm</artifactId> |
| <version>${revision}</version> |
| <name>Apache Log4j Samples: GraalVM native image</name> |
| |
| <properties> |
| <!-- |
| ~ Version of Log4j Core |
| ~ |
| ~ Set to latest stable 2.x release for users. |
| ~ Our workflows override this. |
| --> |
| <log4j.version>2.24.1</log4j.version> |
| |
| <!-- Some samples require JDK 9+ --> |
| <minimalJavaBuildVersion>17</minimalJavaBuildVersion> |
| <maven.compiler.release>17</maven.compiler.release> |
| <maven.compiler.source /> |
| <maven.compiler.target /> |
| |
| <!-- Skip `bnd-baseline-maven-plugin` since this is not deployed --> |
| <bnd.baseline.skip>true</bnd.baseline.skip> |
| |
| <!-- |
| ~ Skip CycloneDX since this artifact is not deployed. |
| ~ CycloneDX attempts to download non-existent snapshots from `repository.apache.org`, |
| ~ which ends up in a ban of the Github Runner IP. |
| ~ |
| ~ See: https://infra.apache.org/infra-ban.html |
| --> |
| <cyclonedx.skip>true</cyclonedx.skip> |
| |
| <revision>0.0.0-SNAPSHOT</revision> |
| |
| <!-- Dependencies (alphabetical) --> |
| <assertj.version>3.27.0</assertj.version> |
| <json-org.version>20240303</json-org.version> |
| <json-unit.version>4.1.0</json-unit.version> |
| <junit.version>5.11.4</junit.version> |
| <log4j.version>2.25.0-SNAPSHOT</log4j.version> |
| <logback.version>1.5.15</logback.version> |
| <slf4j.version>2.0.16</slf4j.version> |
| |
| <!-- IT to run for each profile --> |
| <integration-tests-include>none</integration-tests-include> |
| <profile-resources>none</profile-resources> |
| </properties> |
| |
| <dependencyManagement> |
| <dependencies> |
| |
| <dependency> |
| <groupId>org.assertj</groupId> |
| <artifactId>assertj-bom</artifactId> |
| <version>${assertj.version}</version> |
| <type>pom</type> |
| <scope>import</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.junit</groupId> |
| <artifactId>junit-bom</artifactId> |
| <version>${junit.version}</version> |
| <type>pom</type> |
| <scope>import</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-bom</artifactId> |
| <version>${log4j.version}</version> |
| <type>pom</type> |
| <scope>import</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.slf4j</groupId> |
| <artifactId>slf4j-bom</artifactId> |
| <version>${slf4j.version}</version> |
| <type>pom</type> |
| <scope>import</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>ch.qos.logback</groupId> |
| <artifactId>logback-classic</artifactId> |
| <version>${logback.version}</version> |
| </dependency> |
| |
| </dependencies> |
| </dependencyManagement> |
| |
| <dependencies> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-api</artifactId> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.assertj</groupId> |
| <artifactId>assertj-core</artifactId> |
| <scope>test</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.json</groupId> |
| <artifactId>json</artifactId> |
| <version>${json-org.version}</version> |
| </dependency> |
| |
| <dependency> |
| <groupId>net.javacrumbs.json-unit</groupId> |
| <artifactId>json-unit-assertj</artifactId> |
| <version>${json-unit.version}</version> |
| <scope>test</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.junit.jupiter</groupId> |
| <artifactId>junit-jupiter-api</artifactId> |
| <scope>test</scope> |
| </dependency> |
| |
| </dependencies> |
| |
| <build> |
| <plugins> |
| |
| <!-- |
| ~ Step 0: we add per-profile resource. |
| --> |
| <plugin> |
| <groupId>org.codehaus.mojo</groupId> |
| <artifactId>build-helper-maven-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>add-profile-resources</id> |
| <goals> |
| <goal>add-resource</goal> |
| </goals> |
| <configuration> |
| <resources> |
| <resource> |
| <directory>src/reachability-metadata/${profile-resources}/resources</directory> |
| </resource> |
| </resources> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 1: we create the application as executable JAR without dependencies. |
| --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-jar-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>default-jar</id> |
| <configuration> |
| <archive> |
| <manifest> |
| <mainClass>org.apache.logging.log4j.samples.graalvm.Main</mainClass> |
| </manifest> |
| </archive> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 2 (optional): we shade the application. |
| ~ |
| ~ This step is only necessary to create custom images containing Log4j Core in the profiles: |
| ~ * `use-log4j-core-minimal` |
| ~ * `use-log4j-core-jtl-minimal` |
| ~ |
| ~ This step is disabled by default. |
| --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-shade-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>shade-jar-with-dependencies</id> |
| <goals> |
| <goal>shade</goal> |
| </goals> |
| <phase>none</phase> |
| <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> |
| <exclude>META-INF/DEPENDENCIES</exclude> |
| </excludes> |
| </filter> |
| <!-- |
| ~ Removes the metadata embedded in official Log4j JARs. |
| ~ The metadata will be replaced with a custom version. |
| --> |
| <filter> |
| <artifact>org.apache.logging.log4j:*</artifact> |
| <excludes> |
| <exclude>META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat</exclude> |
| <exclude>META-INF/native-image/org.apache.logging.log4j/*/reflect-config.json</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" /> |
| </transformers> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 3: Creates a native executable. |
| --> |
| <plugin> |
| <groupId>org.graalvm.buildtools</groupId> |
| <artifactId>native-maven-plugin</artifactId> |
| <version>0.10.4</version> |
| <extensions>true</extensions> |
| <executions> |
| <execution> |
| <id>build-native</id> |
| <goals> |
| <goal>compile-no-fork</goal> |
| </goals> |
| <phase>package</phase> |
| <configuration> |
| <mainClass>org.apache.logging.log4j.samples.graalvm.Main</mainClass> |
| <metadataRepository> |
| <enabled>false</enabled> |
| </metadataRepository> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 4: Cleans the logs directory before running the executable. |
| --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-clean-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>remove-stale-log-files</id> |
| <goals> |
| <goal>clean</goal> |
| </goals> |
| <phase>pre-integration-test</phase> |
| <configuration> |
| <filesets> |
| <fileset> |
| <directory>target/logs</directory> |
| <includes> |
| <include>*.log</include> |
| </includes> |
| </fileset> |
| </filesets> |
| <excludeDefaultDirectories>true</excludeDefaultDirectories> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 5: Runs the native executable. |
| --> |
| <plugin> |
| <groupId>org.codehaus.mojo</groupId> |
| <artifactId>exec-maven-plugin</artifactId> |
| <version>3.5.0</version> |
| <executions> |
| <execution> |
| <id>run-executable</id> |
| <goals> |
| <goal>exec</goal> |
| </goals> |
| <phase>integration-test</phase> |
| <configuration> |
| <executable>target/log4j-samples-graalvm</executable> |
| <outputFile>target/logs/out.log</outputFile> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| |
| <!-- |
| ~ Step 6: Verifies the content of the log file. |
| --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-failsafe-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>integration-test</id> |
| <goals> |
| <goal>integration-test</goal> |
| <goal>verify</goal> |
| </goals> |
| <configuration> |
| <includes>${integration-tests-include}</includes> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| </plugins> |
| </build> |
| |
| <profiles> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ JAVA UTIL LOGGING |
| ~ ################################################################################################################ |
| ~ Enable this profile to use JUL as logging implementation. |
| --> |
| <profile> |
| <id>use-jul</id> |
| |
| <properties> |
| <integration-tests-include>**/JulIT.class</integration-tests-include> |
| <profile-resources>jul</profile-resources> |
| </properties> |
| |
| <dependencies> |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-to-jul</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| </dependencies> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ LOG4J CORE (minimal) |
| ~ ################################################################################################################ |
| ~ Enable this profile to use Log4j Core as logging implementation with a manually crafted metadata file. |
| --> |
| <profile> |
| <id>use-log4j-core-minimal</id> |
| |
| <properties> |
| <integration-tests-include>**/StandardIT.class</integration-tests-include> |
| <profile-resources>log4j-core-minimal</profile-resources> |
| </properties> |
| |
| <dependencies> |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-core</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| </dependencies> |
| |
| <!-- |
| ~ Use a different source of Log4j Core metadata. |
| --> |
| <build> |
| <plugins> |
| <!-- Filter out the full embedded configuration --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-shade-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>shade-jar-with-dependencies</id> |
| <phase>package</phase> |
| </execution> |
| </executions> |
| </plugin> |
| <!-- Creates native image based on the shaded artifact --> |
| <plugin> |
| <groupId>org.graalvm.buildtools</groupId> |
| <artifactId>native-maven-plugin</artifactId> |
| <version>0.10.4</version> |
| <extensions>true</extensions> |
| <executions> |
| <execution> |
| <id>build-native</id> |
| <configuration> |
| <classpath> |
| <jar>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</jar> |
| </classpath> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| </plugins> |
| </build> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ LOG4J CORE (full) |
| ~ ################################################################################################################ |
| ~ Enable this profile to use Log4j Core as logging implementation with a full metadata file. |
| --> |
| <profile> |
| <id>use-log4j-core</id> |
| |
| <properties> |
| <integration-tests-include>**/StandardIT.class</integration-tests-include> |
| </properties> |
| |
| <dependencies> |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-core</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| </dependencies> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ LOG4J CORE + JTL (minimal) |
| ~ ################################################################################################################ |
| ~ Enable this profile to use a handcrafted configuration Log4j Core + JSON Template Layout |
| --> |
| <profile> |
| <id>use-log4j-core-jtl-minimal</id> |
| |
| <properties> |
| <integration-tests-include>**/JsonTemplateLayoutIT.class</integration-tests-include> |
| <profile-resources>log4j-core-jtl-minimal</profile-resources> |
| </properties> |
| |
| <dependencies> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-core</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-layout-template-json</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.slf4j</groupId> |
| <artifactId>slf4j-nop</artifactId> |
| <scope>test</scope> |
| </dependency> |
| |
| </dependencies> |
| |
| <!-- |
| ~ Use a different source of Log4j Core metadata. |
| --> |
| <build> |
| <plugins> |
| <!-- Filter out the full embedded configuration --> |
| <plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-shade-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>shade-jar-with-dependencies</id> |
| <phase>package</phase> |
| </execution> |
| </executions> |
| </plugin> |
| <!-- Creates native image based on the shaded artifact --> |
| <plugin> |
| <groupId>org.graalvm.buildtools</groupId> |
| <artifactId>native-maven-plugin</artifactId> |
| <version>0.10.4</version> |
| <extensions>true</extensions> |
| <executions> |
| <execution> |
| <id>build-native</id> |
| <configuration> |
| <classpath> |
| <jar>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</jar> |
| </classpath> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| </plugins> |
| </build> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ LOG4J CORE + JTL (full) |
| ~ ################################################################################################################ |
| ~ Enable this profile to use Log4j Core + JSON Template Layout |
| --> |
| <profile> |
| <id>use-log4j-core-jtl</id> |
| |
| <properties> |
| <integration-tests-include>**/JsonTemplateLayoutIT.class</integration-tests-include> |
| <profile-resources>log4j-core-jtl</profile-resources> |
| </properties> |
| |
| <dependencies> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-core</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-layout-template-json</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>org.slf4j</groupId> |
| <artifactId>slf4j-nop</artifactId> |
| <scope>test</scope> |
| </dependency> |
| |
| </dependencies> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ LOGBACK |
| ~ ################################################################################################################ |
| ~ Enable this profile to use Logback as logging implementation. |
| --> |
| <profile> |
| <id>use-logback</id> |
| |
| <properties> |
| <integration-tests-include>**/StandardIT.class</integration-tests-include> |
| <profile-resources>logback</profile-resources> |
| </properties> |
| |
| <dependencies> |
| |
| <dependency> |
| <groupId>org.apache.logging.log4j</groupId> |
| <artifactId>log4j-to-slf4j</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| <dependency> |
| <groupId>ch.qos.logback</groupId> |
| <artifactId>logback-classic</artifactId> |
| <scope>runtime</scope> |
| </dependency> |
| |
| </dependencies> |
| |
| <!-- |
| ~ Logback needs additional metadata |
| --> |
| <build> |
| <plugins> |
| <!-- Use external reflection metadata configuration --> |
| <plugin> |
| <groupId>org.graalvm.buildtools</groupId> |
| <artifactId>native-maven-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>build-native</id> |
| <configuration> |
| <metadataRepository> |
| <enabled>true</enabled> |
| </metadataRepository> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| </plugins> |
| </build> |
| </profile> |
| |
| <!-- |
| ~ ################################################################################################################ |
| ~ SIMPLE LOGGER |
| ~ ################################################################################################################ |
| --> |
| <profile> |
| <id>use-simple</id> |
| |
| <properties> |
| <integration-tests-include>**/SimpleIT.class</integration-tests-include> |
| <profile-resources>simple</profile-resources> |
| </properties> |
| </profile> |
| |
| <!-- |
| ~ An additional Maven staging repository if the `log4j.repository.url` property is not empty. |
| --> |
| <profile> |
| <id>staging-repo</id> |
| <activation> |
| <property> |
| <name>log4j.repository.url</name> |
| <value>!</value> |
| </property> |
| </activation> |
| |
| <repositories> |
| <!-- Use primarily Maven Central --> |
| <repository> |
| <snapshots> |
| <enabled>false</enabled> |
| </snapshots> |
| <id>central</id> |
| <name>Central Repository</name> |
| <url>https://repo.maven.apache.org/maven2</url> |
| </repository> |
| <!-- The repository that contains the requested Log4j version --> |
| <repository> |
| <snapshots> |
| <enabled>false</enabled> |
| </snapshots> |
| <id>log4j-staging</id> |
| <name>Log4j Staging Repository</name> |
| <url>${log4j.repository.url}</url> |
| </repository> |
| </repositories> |
| </profile> |
| |
| </profiles> |
| </project> |