Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ jobs:
with:
fetch-depth: 32

# JDK 8 and 11 is needed for the build.
# JDK 11 is used for the build.
# JDK 8 is used for the tests.
# Search `maven-toolchains-plugin` usages for details.
- name: Setup JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
with:
distribution: temurin
# The last provided Java version will be used and available globally.
# Other Java versions can be accessed through environment variables: `JAVA_HOME_<majorVersion>_<architecture>`
java-version: |
8
11
Expand All @@ -68,9 +71,10 @@ jobs:
- name: Build
timeout-minutes: 60
shell: bash
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
run: ./mvnw clean install
run: |
./mvnw \
-Pjava8-tests \
clean install

- name: Upload Surefire Reports
if: failure()
Expand All @@ -85,8 +89,6 @@ jobs:
id: report-reproducible
timeout-minutes: 10
shell: bash
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
run: |
./mvnw \
-DskipTests=true \
Expand All @@ -105,8 +107,6 @@ jobs:
- name: Build site
timeout-minutes: 10
shell: bash
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
run: ./mvnw site

merge:
Expand Down Expand Up @@ -138,12 +138,15 @@ jobs:
with:
fetch-depth: 32

# JDK 8 and 11 are needed for the build.
# JDK 11 is used for the build.
# JDK 8 is used for the tests.
# Search `maven-toolchains-plugin` usages for details.
- name: Setup JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
with:
distribution: temurin
# The last provided Java version will be used and available globally.
# Other Java versions can be accessed through environment variables: `JAVA_HOME_<majorVersion>_<architecture>`
java-version: |
8
11
Expand Down Expand Up @@ -173,6 +176,5 @@ jobs:
-DskipTests=true \
package install:install deploy:deploy
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PW: ${{ secrets.NEXUS_PW }}
9 changes: 2 additions & 7 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,17 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# JDK 8 and 11 is needed for the build.
# Search `maven-toolchains-plugin` usages for details.
# JDK 11 is used for the build.
- name: Setup JDK
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
with:
distribution: temurin
java-version: |
8
11
java-version: 11
cache: maven

- name: Build with Maven
timeout-minutes: 60
shell: bash
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
run: |
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/log4j-kafka-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jobs:
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # 3.12.0
with:
distribution: temurin
java-version: 8
java-version: |
8
11
java-package: jdk
architecture: x64
cache: maven
Expand All @@ -58,4 +60,5 @@ jobs:
--show-version --batch-mode --errors --no-transfer-progress --fail-at-end \
-Dkafka.version=${{ matrix.version }} \
-pl log4j-core-test -Dtest=Kafka*Test \
-P java8-tests \
test
10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
67 changes: 45 additions & 22 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,23 @@

# Requirements

* JDK 8 and 9+
* Apache Maven 3.x
* JDK 11+
* JDK 8 (optional)
* Apache Maven 3.x (optional)
* A modern Linux, OSX, or Windows host

<a name="toolchains"></a>
# Configuring Maven Toolchains

Maven Toolchains is used to employ multiple JDKs required for compilation.
You either need to have a user-level configuration in `~/.m2/toolchains.xml` or explicitly provide one to the Maven: `./mvnw --global-toolchains /path/to/toolchains.xml`.
See [`.github/workflows/maven-toolchains.xml`](.github/workflows/maven-toolchains.xml) used by CI for a sample Maven Toolchains configuration.
Note that this file requires `JAVA_HOME_8_X64` and `JAVA_HOME_11_X64` environment variables to be defined, though these can very well be hardcoded.

<a name="building"></a>
# Building the sources

You can build and verify the sources as follows:

./mvnw verify

```sh
./mvnw verify
```
`verify` goal runs validation and test steps next to building (i.e., compiling) the sources.
To speed up the build, you can skip verification:

./mvnw -DskipTests package

```sh
./mvnw -DskipTests package
```
If you want to install generated artifacts to your local Maven repository, replace above `verify` and/or `package` goals with `install`.

<a name="dns"></a>
Expand All @@ -50,16 +43,46 @@ Note that if your `/etc/hosts` file does not include an entry for your computer'
many unit tests may execute slow due to DNS lookups to translate your hostname to an IP address in
[`InetAddress.getLocalHost()`](http://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html#getLocalHost()).
To remedy this, you can execute the following:
```sh
printf '127.0.0.1 %s\n::1 %s\n' `hostname` `hostname` | sudo tee -a /etc/hosts
```

printf '127.0.0.1 %s\n::1 %s\n' `hostname` `hostname` | sudo tee -a /etc/hosts
<a name="java8-tests"></a>
# Java 8 tests

To test the library against the target JRE (JRE 8), you need to configure a JDK 8 toolchains as explained below and run Maven with the `java8-tests` profile:
```sh
./mvnw verify -Pjava8-tests
```

<a name="toolchains"></a>
## Configuring Maven Toolchains

Maven Toolchains is used to employ additional JDKs required for tests.
You either need to have a user-level configuration in `~/.m2/toolchains.xml` or explicitly provide one to the Maven: `./mvnw --global-toolchains /path/to/toolchains.xml`.
```xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>1.8.0_372</version>
</provides>
<configuration>
<jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
</configuration>
</toolchain>
</toolchains>
```

<a name="website"></a>
# Building the website and manual

You can build the website and manual as follows:

./mvnw site

```sh
./mvnw site
```
And view it using a simple HTTP server, e.g., the one comes with the Python:

python3 -m http.server -d target/site
```sh
python3 -m http.server -d target/site
```
57 changes: 23 additions & 34 deletions log4j-api-java9/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<docLabel>API Documentation</docLabel>
<projectDir>/api</projectDir>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.release>9</maven.compiler.release>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -65,6 +66,7 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -77,62 +79,49 @@
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
<configuration>
<jdkToolchain>
<version>[9, )</version>
</jdkToolchain>
<release>9</release>
</configuration>
</execution>
<!-- We explicitly compile tests using Java 8 to work around SUREFIRE-2073 -->
<execution>
<id>default-test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
</execution>
<!-- Of course the 'module-info.java' needs Java 9 -->
<execution>
<id>test-compile-module</id>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
<configuration>
<jdkToolchain>
<version>[9, )</version>
</jdkToolchain>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/test/java9</compileSourceRoot>
</compileSourceRoots>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
<jdkToolchain>
<version>[9, )</version>
</jdkToolchain>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>java8-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="override">
<reuseForks>false</reuseForks>
<systemPropertyVariables>
<java.awt.headless>true</java.awt.headless>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* 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 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
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.logging.log4j.util.java9;

Expand Down
22 changes: 4 additions & 18 deletions log4j-api-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
</dependencies>
<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand All @@ -117,24 +118,7 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<!-- recompile everything for target VM except the module-info.java -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -164,6 +148,7 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -172,6 +157,7 @@
<excludedGroups>performance,smoke</excludedGroups>
</configuration>
</plugin>

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