Fixed issue 39663: Build fails in Java 11 since log4j upgrade.
authorJavier Armendáriz <javier.armendariz@openbravo.com>
Fri, 23 Nov 2018 10:32:52 +0100
changeset 35120 bc617f478775
parent 35119 641c5b66d580
child 35121 a7bf0aacd4be
child 35155 033b978c040b
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.
build.xml
lib/build/log4j-api-no-mrjar-2.11.1.jar
src-db/database/build-create.xml
src-db/database/build.xml
src-util/diagnostic/build-create.xml
--- a/build.xml	Fri Nov 23 11:45:53 2018 +0100
+++ b/build.xml	Fri Nov 23 10:32:52 2018 +0100
@@ -245,7 +245,11 @@
     <pathelement path="${base.config}" />
     <pathelement path="${build}" />
     <pathelement path="${base.src}" />
+    <fileset dir="${base.lib}/build">
+      <include name="*.jar" />
+    </fileset>
     <fileset dir="${base.lib}">
+      <exclude name="build/*" />
       <include name="**/*.jar" />
     </fileset>
     <fileset dir="${build.core.lib}">
Binary file lib/build/log4j-api-no-mrjar-2.11.1.jar has changed
--- a/src-db/database/build-create.xml	Fri Nov 23 11:45:53 2018 +0100
+++ b/src-db/database/build-create.xml	Fri Nov 23 10:32:52 2018 +0100
@@ -35,7 +35,11 @@
       <include name="**/*.jar" />
     </fileset>
     <pathelement path="${build}" />
+    <fileset dir="${base.lib}/build">
+      <include name="*.jar" />
+    </fileset>
     <fileset dir="${base.lib}">
+      <exclude name="build/*" />
       <include name="**/*.jar" />
     </fileset>
     <pathelement path="${base.config}" />
--- a/src-db/database/build.xml	Fri Nov 23 11:45:53 2018 +0100
+++ b/src-db/database/build.xml	Fri Nov 23 10:32:52 2018 +0100
@@ -46,7 +46,11 @@
       <exclude name="**/dbsourcemanagerlight.jar" />
     </fileset>
     <pathelement path="${build}" />
+    <fileset dir="${base.lib}/build">
+      <include name="*.jar" />
+    </fileset>
     <fileset dir="${base.lib}">
+      <exclude name="build/*" />
       <include name="**/*.jar" />
     </fileset>
     <pathelement path="${base.config}" />
--- a/src-util/diagnostic/build-create.xml	Fri Nov 23 11:45:53 2018 +0100
+++ b/src-util/diagnostic/build-create.xml	Fri Nov 23 10:32:52 2018 +0100
@@ -20,7 +20,11 @@
 <project name="openbravo-diagnostics-build" basedir="." default="build">
 
   <path id="diagnostic.class.path">
+    <fileset dir="../../lib/build">
+      <include name="*.jar" />
+    </fileset>
     <fileset dir="../../lib/">
+      <exclude name="build/*" />
       <include name="**/*.jar" />
     </fileset>
   </path>