Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Log4j2 build listener #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="apache-ant" default="main" basedir=".">
<project name="apache-ant" default="main" basedir="." xmlns:if="ant:if">

<!-- Give user a chance to override without editing this file
(and without typing -D on each invocation) -->
Expand Down Expand Up @@ -260,6 +260,10 @@
<filename name="${ant.package}/listener/Log4jListener*"/>
</selector>

<selector id="needs.apache-log4j2">
<filename name="${ant.package}/listener/Log4j2Listener*"/>
</selector>

<selector id="needs.commons-logging">
<filename name="${ant.package}/listener/CommonsLoggingListener*"/>
</selector>
Expand Down Expand Up @@ -357,6 +361,7 @@
<selector refid="needs.apache-bcel"/>
<selector refid="needs.apache-bsf"/>
<selector refid="needs.apache-log4j"/>
<selector refid="needs.apache-log4j2"/>
<selector refid="needs.apache-oro"/>
<selector refid="needs.apache-regexp"/>
<selector refid="needs.apache-resolver"/>
Expand Down Expand Up @@ -496,6 +501,9 @@
<available property="log4j.present"
classname="org.apache.log4j.Logger"
classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
<available property="log4j2.present"
classname="org.apache.logging.log4j.Logger"
classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
<available property="commons.logging.present"
classname="org.apache.commons.logging.LogFactory"
classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
Expand Down Expand Up @@ -730,6 +738,7 @@
<selector refid="needs.apache-oro" unless="apache.oro.present"/>
<selector refid="needs.apache-bcel" unless="bcel.present"/>
<selector refid="needs.apache-log4j" unless="log4j.present"/>
<selector refid="needs.apache-log4j2" unless="log4j2.present"/>
<selector refid="needs.commons-logging" unless="commons.logging.present"/>
<selector refid="needs.apache-bsf" unless="bsf.present"/>
<selector refid="needs.javamail" unless="javamail.present"/>
Expand Down Expand Up @@ -894,6 +903,7 @@
<optional-jar dep="apache-oro"/>
<optional-jar dep="apache-bcel"/>
<optional-jar dep="apache-log4j"/>
<optional-jar dep="apache-log4j2" if:set="log4j2.present"/>
<optional-jar dep="commons-logging"/>
<optional-jar dep="apache-bsf"/>
<optional-jar dep="javamail"/>
Expand Down Expand Up @@ -990,6 +1000,7 @@
<optional-src-jar dep="apache-oro"/>
<optional-src-jar dep="apache-bcel"/>
<optional-src-jar dep="apache-log4j"/>
<optional-src-jar dep="apache-log4j2"/>
<optional-src-jar dep="commons-logging"/>
<optional-src-jar dep="apache-bsf"/>
<optional-src-jar dep="javamail"/>
Expand Down Expand Up @@ -2094,6 +2105,10 @@ ${antunit.reports}
classloader -->
<exclude name="${ant.package}/util/ClasspathUtilsTest.java"
if="tests.and.ant.share.classloader"/>

<!-- test needs Log4j2 -->
<exclude name="${ant.package}/listener/Log4j2Listener*"
unless="log4j2.present"/>
</fileset>
</batchtest>
</test-junit>
Expand Down
2 changes: 2 additions & 0 deletions fetch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ Set -Ddest=LOCATION on the command line
description="load logging libraries (Commons and Log4j)"
depends="init">
<f2 project="log4j"/>
<f2 project="org.apache.logging.log4j" archive="log4j-api"/>
<f2 project="org.apache.logging.log4j" archive="log4j-core"/>
<f2 project="commons-logging" archive="commons-logging-api"/>
</target>

Expand Down
3 changes: 3 additions & 0 deletions lib/libraries.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ jsch.version=0.1.55
jython.version=2.7.2
# log4j 1.2.15 requires JMS and a few other Sun jars that are not in the m2 repo
log4j.version=1.2.14
log4j-api.version=2.18.0
# Used only in tests
log4j-core.version=2.18.0
oro.version=2.0.8
servlet-api.version=2.3
which.version=1.0
Expand Down
5 changes: 5 additions & 0 deletions manual/listeners.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ <h2 id="builtin">Built-in Listeners/Loggers</h2>
<td>Colorifies the build output.</td>
<td>BuildLogger</td>
</tr>
<tr>
<td><code><a href="#Log4j2Listener">org.apache.tools.ant.listener.Log4j2Listener</a></code></td>
<td>Passes events to Apache Log4j2 for highly customizable logging.</td>
<td>BuildListener</td>
</tr>
<tr>
<td><code><a href="#Log4jListener">org.apache.tools.ant.listener.Log4jListener</a></code></td>
<td>Passes events to Apache Log4j for highly customizable
Expand Down
93 changes: 93 additions & 0 deletions src/etc/poms/ant-apache-log4j2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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

https://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 POM has been created manually by the Ant Development Team.
Please contact us if you are not satisfied with the data contained in this POM.
URL : https://ant.apache.org
-->
<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 https://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.10.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>https://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-log4j2</artifactId>
<version>1.10.13-SNAPSHOT</version>
<name>Apache Ant + Log4J2</name>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.13-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.18.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>org/apache/tools/ant/listener/Log4j2Listener*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>true</index>
<manifest>
<addExtensions>true</addExtensions>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>../../../..</directory>
<targetPath>META-INF</targetPath>
<includes>
<include>LICENSE</include>
<include>NOTICE</include>
</includes>
</resource>
</resources>
<sourceDirectory>../../../../src/main</sourceDirectory>
<testSourceDirectory>../../../../src/testcases</testSourceDirectory>
<outputDirectory>../../../../target/${project.artifactId}/classes</outputDirectory>
<testOutputDirectory>../../../../target/${project.artifactId}/testcases</testOutputDirectory>
<directory>../../../../target/${project.artifactId}</directory>
</build>
</project>