author Javier Armendáriz <>
Fri, 23 Nov 2018 10:32:52 +0100
changeset 35155 bc617f478775
parent 13263 cbae5849cd57
child 35226 4afbb3dfd15d
permissions -rw-r--r--
Fixed issue 39663: Build fails in Java 11 since log4j upgrade.

New log4j libraries are multi-release jars (mrjar), meaning that they can define
multiple version of classes depending on the JVM version being run. Currently
ant does not support mrjars for custom java tasks and build fails when executing
LogManager.getLogger() inside an ant task.
For this reason, a new jar is included during build to override LogManager and
StackLocator implementation to make build work in Java9+. In addition, classpath
in build script is modified to force including the build libraries first in the
classpath and use these classes instead of the ones implemented in log4j-api.
<?xml version="1.0" encoding="UTF-8" ?>
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2008-2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
<project name="openbravo-diagnostics-build" basedir="." default="build">

  <path id="diagnostic.class.path">
    <fileset dir="../../lib/build">
      <include name="*.jar" />
    <fileset dir="../../lib/">
      <exclude name="build/*" />
      <include name="**/*.jar" />

  <target name="build" depends="clean">
    <copy todir="WebContent/WEB-INF/lib">
      <fileset dir="../../lib/runtime">
        <include name="**/*.jar" />
    <javac srcdir="src" destdir="build/classes" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on">
      <classpath refid="diagnostic.class.path" />

  <target name="clean">
    <delete failonerror="false">
      <fileset dir="WebContent/WEB-INF/lib" />
      <fileset dir="build/classes" />
    <mkdir dir="WebContent/WEB-INF/lib" />
    <mkdir dir="build/classes" />
    <copy file="../../config/" todir="config" failonerror="false" />
    <copy todir="WebContent/WEB-INF">
      <fileset dir="config" />

  <target name="war">
    <delete failonerror="false" file="lib/OpenbravoDiagnostics.war" />
    <war compress="true" destfile="OpenbravoDiagnostics.war" encoding="UTF-8" webxml="WebContent/WEB-INF/web.xml">
      <zipfileset dir="WebContent">
        <exclude name="**/WEB-INF/web.xml" />
        <exclude name="**/WEB-INF/lib/servlet-api.jar" />
      <classes dir="build/classes" />