src-util/diagnostic/build-create.xml
author Javier Armendáriz <javier.armendariz@openbravo.com>
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.
asier@2001
     1
<?xml version="1.0" encoding="UTF-8" ?>
asier@2001
     2
<!--
asier@2001
     3
*************************************************************************
asier@2001
     4
* The contents of this file are subject to the Openbravo  Public  License
priya@9085
     5
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
asier@2001
     6
* Version 1.1  with a permitted attribution clause; you may not  use this
asier@2001
     7
* file except in compliance with the License. You  may  obtain  a copy of
asier@2001
     8
* the License at http://www.openbravo.com/legal/license.html
asier@2001
     9
* Software distributed under the License  is  distributed  on  an "AS IS"
asier@2001
    10
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@2001
    11
* License for the specific  language  governing  rights  and  limitations
asier@2001
    12
* under the License.
asier@2001
    13
* The Original Code is Openbravo ERP.
ggi@6702
    14
* The Initial Developer of the Original Code is Openbravo SLU
asier@13263
    15
* All portions are Copyright (C) 2008-2011 Openbravo SLU
asier@2001
    16
* All Rights Reserved.
asier@2001
    17
* Contributor(s):  ______________________________________.
asier@2001
    18
************************************************************************
asier@2001
    19
-->
asier@2004
    20
<project name="openbravo-diagnostics-build" basedir="." default="build">
asier@2001
    21
asier@2001
    22
  <path id="diagnostic.class.path">
javier@35155
    23
    <fileset dir="../../lib/build">
javier@35155
    24
      <include name="*.jar" />
javier@35155
    25
    </fileset>
asier@13263
    26
    <fileset dir="../../lib/">
javier@35155
    27
      <exclude name="build/*" />
martin@2871
    28
      <include name="**/*.jar" />
asier@2001
    29
    </fileset>
asier@2001
    30
  </path>
martin@2871
    31
asier@2001
    32
  <target name="build" depends="clean">
martin@2871
    33
    <copy todir="WebContent/WEB-INF/lib">
antonio@6907
    34
      <fileset dir="../../lib/runtime">
martin@2871
    35
        <include name="**/*.jar" />
martin@2871
    36
      </fileset>
asier@2001
    37
    </copy>
asier@2001
    38
    <javac srcdir="src" destdir="build/classes" encoding="UTF-8" debug="true" debuglevel="lines,vars,source" deprecation="on">
martin@2871
    39
      <classpath refid="diagnostic.class.path" />
martin@2871
    40
    </javac>
asier@2001
    41
  </target>
martin@2871
    42
asier@2001
    43
  <target name="clean">
asier@2008
    44
    <delete failonerror="false">
martin@2871
    45
      <fileset dir="WebContent/WEB-INF/lib" />
martin@2871
    46
      <fileset dir="build/classes" />
asier@2001
    47
    </delete>
martin@2871
    48
    <mkdir dir="WebContent/WEB-INF/lib" />
martin@2871
    49
    <mkdir dir="build/classes" />
antonio@6907
    50
    <copy file="../../config/Openbravo.properties" todir="config" failonerror="false" />
asier@2001
    51
    <copy todir="WebContent/WEB-INF">
martin@2871
    52
      <fileset dir="config" />
asier@2001
    53
    </copy>
asier@2001
    54
  </target>
martin@2871
    55
asier@2001
    56
  <target name="war">
asier@2001
    57
    <delete failonerror="false" file="lib/OpenbravoDiagnostics.war" />
asier@2001
    58
    <war compress="true" destfile="OpenbravoDiagnostics.war" encoding="UTF-8" webxml="WebContent/WEB-INF/web.xml">
asier@2001
    59
      <zipfileset dir="WebContent">
asier@2001
    60
        <exclude name="**/WEB-INF/web.xml" />
asier@2001
    61
        <exclude name="**/WEB-INF/lib/servlet-api.jar" />
asier@2001
    62
      </zipfileset>
martin@2871
    63
      <classes dir="build/classes" />
asier@2001
    64
    </war>
asier@2001
    65
  </target>
antonio@6907
    66
</project>