5 Star 14 Fork 13

Apache / logging-log4j2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
BUILDING.adoc 4.14 KB
一键复制 编辑 原始数据 按行查看 历史

Requirements

  • JDK 17+

  • A modern Linux, OSX, or Windows host

Building the sources

You can build and verify the sources as follows:

./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

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

DNS lookups in tests

Note that if your /etc/hosts file does not include an entry for your computer’s hostname, then many unit tests may execute slow due to DNS lookups to translate your hostname to an IP address in InetAddress.getLocalHost(). To remedy this, you can execute the following:

printf '127.0.0.1 %s\n::1 %s\n' `hostname` `hostname` | sudo tee -a /etc/hosts

Java 8 tests

You can run tests using the target JRE (i.e., JRE 8) as follows:

  1. 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.

    An example toolchains.xml containing a JDK 8 toolchain
    <?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>
  2. Run Maven tests with the java8-tests profile:

    ./mvnw verify -Pjava8-tests,!java8-incompat-fixes

Building the website

You can build the website as follows:

./mvnw compile    # (1)
./mvnw site       # (2)
  1. Generate plugin descriptors that will be used to generate the plugin reference page. Descriptors are placed under target/plugin-descriptors.

  2. Generate the website to target/site

You can view the generated website with a browser by pointing it to target/site directory.

Development

You can follow below steps for casual development needs:

  1. Make sure you installed everything:

    ./mvnw install -DskipTests
  2. After making a change to, say, log4j-core, install your changes:

    ./mvnw install -pl :log4j-core -DskipTests
  3. Run all tests associated with log4j-core:

    ./mvnw test -pl :log4j-core-test
  4. Run a particular test:

    ./mvnw test -pl :log4j-core-test -Dtest=FooBarTest
  5. Make sure all build checks (Spotless, Spotbugs, BND, RAT, etc.) succeed:

    ./mvnw verify -DskipTests -pl :log4j-core,:log4j-core-test
Tip

You can connect your IDE to a ./mvnw test run by

  1. Run ./mvnw test -pl :log4j-core-test -Dtest=FooBarTest -Dmaven.surefire.debug

  2. Use "Run > Attach to process" in IntelliJ IDEA

F.A.Q

Compilation in IntelliJ IDEA fails with java: plug-in not found: ErrorProne

Try removing all "Override compiler parameters per-module" entries in "Settings > Build, Execution, Deployment > Compiler > Java Compiler".

Java
1
https://gitee.com/apache/logging-log4j2.git
git@gitee.com:apache/logging-log4j2.git
apache
logging-log4j2
logging-log4j2
2.x

搜索帮助