Skip to content

Commit

Permalink
Merge reworked pull request #1043 from rvdb:war-build-fix-log4j2
Browse files Browse the repository at this point in the history
Closes #1043
  • Loading branch information
adamretter committed Jun 14, 2016
2 parents 1c13579 + bf042d9 commit 4441d34
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build/scripts/dist-war-log4j.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

<!-- Convert log4j2.xml for use in war-file -->
<xsl:output method="xml"/>

<xsl:template match="Property[@name='logs']">
<Property name="logs">${web:rootDir}/WEB-INF/logs</Property>
</xsl:template>

<xsl:template match="category[@name='org.mortbay']">
</xsl:template>
Expand Down
31 changes: 28 additions & 3 deletions build/scripts/dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
<!-- import common targets -->
<import file="../../build.xml"/>
<import file="git-support.xml"/>


<!-- temorary location for files that should be added to the war -->
<property name="war.tmp" value="webapp/WEB-INF/tmp"/>
<!-- temporary location for libs that should be added to the war -->
<property name="war.tmp.libs" value="${war.tmp}/lib"/>

<!-- ================================================================== -->
<!-- Prepare webapp -->
<!-- ================================================================== -->
Expand All @@ -27,13 +32,29 @@
<xslt in="conf.xml" out="webapp/WEB-INF/conf.xml" style="${build.scripts}/dist-war-conf.xsl"/>
<xslt in="log4j2.xml" out="webapp/WEB-INF/log4j2.xml" style="${build.scripts}/dist-war-log4j.xsl"/>

<!-- fetch war specific libs -->
<path id="log4j2.core.path">
<fileset dir="${lib.core}">
<include name="log4j-core-*.jar"/>
</fileset>
</path>
<property name="log4j2.core.file" refid="log4j2.core.path"/>
<propertyregex property="log4j2.version" input="${log4j2.core.file}" regexp=".*log4j-core-(.*).jar" select="\1" />

<echo message="Detected log4j2 version: ${log4j2.version}, downloading log4j-web-${log4j2.version}.jar..."/>

<property name="log4j2.web.artifact" value="log4j-web-${log4j2.version}.jar"/>
<property name="log4j2.web.url" value="http://search.maven.org/remotecontent?filepath=org/apache/logging/log4j/log4j-web/${log4j2.version}/${log4j2.web.artifact}"/>

<mkdir dir="${war.tmp.libs}"/>
<get src="${log4j2.web.url}" dest="${war.tmp.libs}/${log4j2.web.artifact}" verbose="true" usetimestamp="true" skipexisting="true"/>
</target>

<!-- ================================================================== -->
<!-- Create .war file -->
<!-- ================================================================== -->
<target name="dist-war" depends="git.details,webapps" description="Create war file">
<war destfile="${dist}/exist-${project.version}-${git.commit}.war" webxml="webapp/WEB-INF/web.xml">
<war destfile="${dist}/exist-${project.version}-${git.commit}.war" webxml="webapp/WEB-INF/web.xml">

<!-- Add files to WEB-INF/lib -->
<lib dir=".">
Expand Down Expand Up @@ -102,7 +123,9 @@
<lib dir="extensions/modules/lib">
<include name="*.jar"/>
</lib>

<lib dir="${war.tmp.libs}">
<include name="*.jar"/>
</lib>

<!-- Add configuration files to WEB-INF -->
<webinf dir=".">
Expand All @@ -121,6 +144,7 @@
<!-- Add files context root ('/') -->
<fileset dir="webapp">
<exclude name="**/*~"/>
<exclude name="WEB-INF/tmp/**"/>
<exclude name="api/**"/>
<exclude name="WEB-INF/web.xml"/>
<exclude name="WEB-INF/data/*.dbx"/>
Expand Down Expand Up @@ -158,6 +182,7 @@
</manifest>

</war>
<delete dir="${war.tmp}"/>
</target>

<!-- ================================================================== -->
Expand Down

0 comments on commit 4441d34

Please sign in to comment.