MPWAR-65: Added maven.war.expansion.excludes property to exclude files during a property expansion copy (Fixes corruption of binary files). Applied property expansion to web.xml handling for consistency. Introduced the maven.war.src.filtering property to control whether filtering is enabled or not when copying webapp resources.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@534128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a526482541
commit
28538aaa4b
@ -151,12 +151,13 @@
|
|||||||
<ant:mkdir dir="${webapp.build.webinf}"/>
|
<ant:mkdir dir="${webapp.build.webinf}"/>
|
||||||
|
|
||||||
<j:if test="${webSourcesPresent == 'true'}">
|
<j:if test="${webSourcesPresent == 'true'}">
|
||||||
<ant:copy todir="${maven.war.webapp.dir}" filtering="on"
|
<ant:copy todir="${maven.war.webapp.dir}" filtering="${maven.war.src.filtering}"
|
||||||
preservelastmodified="true"
|
preservelastmodified="true"
|
||||||
overwrite="${maven.war.resources.overwrite}">
|
overwrite="${maven.war.resources.overwrite}">
|
||||||
<ant:fileset dir="${maven.war.src}"
|
<ant:fileset dir="${maven.war.src}">
|
||||||
includes="${maven.war.src.includes}"
|
<include name="${maven.war.src.includes}"/>
|
||||||
excludes="${maven.war.src.excludes}">
|
<exclude name="${maven.war.src.excludes}"/>
|
||||||
|
<exclude name="${maven.war.expansion.excludes}"/>
|
||||||
</ant:fileset>
|
</ant:fileset>
|
||||||
<j:if test="${maven.war.property.expansion}" >
|
<j:if test="${maven.war.property.expansion}" >
|
||||||
<ant:filterchain>
|
<ant:filterchain>
|
||||||
@ -164,13 +165,27 @@
|
|||||||
</ant:filterchain>
|
</ant:filterchain>
|
||||||
</j:if>
|
</j:if>
|
||||||
</ant:copy>
|
</ant:copy>
|
||||||
|
<j:if test="${maven.war.property.expansion}" >
|
||||||
|
<ant:copy todir="${maven.war.webapp.dir}" filtering="false"
|
||||||
|
preservelastmodified="true"
|
||||||
|
overwrite="${maven.war.resources.overwrite}">
|
||||||
|
<ant:fileset dir="${maven.war.src}">
|
||||||
|
<include name="${maven.war.expansion.excludes}"/>
|
||||||
|
</ant:fileset>
|
||||||
|
</ant:copy>
|
||||||
|
</j:if>
|
||||||
</j:if>
|
</j:if>
|
||||||
|
|
||||||
<util:available file="${maven.war.webxml}">
|
<util:available file="${maven.war.webxml}">
|
||||||
<ant:copy file="${maven.war.webxml}"
|
<ant:copy file="${maven.war.webxml}"
|
||||||
tofile="${webapp.build.webinf}/web.xml"
|
tofile="${webapp.build.webinf}/web.xml"
|
||||||
filtering="on"
|
filtering="${maven.war.src.filtering}"
|
||||||
overwrite="${maven.war.webxml.overwrite}" />
|
overwrite="${maven.war.webxml.overwrite}" />
|
||||||
|
<j:if test="${maven.war.property.expansion}" >
|
||||||
|
<ant:filterchain>
|
||||||
|
<ant:expandproperties/>
|
||||||
|
</ant:filterchain>
|
||||||
|
</j:if>
|
||||||
</util:available>
|
</util:available>
|
||||||
|
|
||||||
</goal>
|
</goal>
|
||||||
|
|||||||
@ -32,6 +32,16 @@ maven.war.src=${maven.src.dir}/webapp
|
|||||||
maven.war.src.includes=**
|
maven.war.src.includes=**
|
||||||
maven.war.src.excludes=
|
maven.war.src.excludes=
|
||||||
|
|
||||||
|
# The files to excludes when filtering is used
|
||||||
|
# Note: Files are relative to maven.war.src and are copied afterwards
|
||||||
|
# without filtering (use this option for binary files namely that will
|
||||||
|
# get corrupted if expansion is applied on them).
|
||||||
|
maven.war.expansion.excludes=
|
||||||
|
|
||||||
|
# Indicates whether token filtering should take
|
||||||
|
# place during the copy. Default is true.
|
||||||
|
maven.war.src.filtering=on
|
||||||
|
|
||||||
# Whether to perform property expansion for
|
# Whether to perform property expansion for
|
||||||
# copied resources.
|
# copied resources.
|
||||||
maven.war.property.expansion=false
|
maven.war.property.expansion=false
|
||||||
|
|||||||
1
war/src/plugin-test/test05/LICENSE.txt
Normal file
1
war/src/plugin-test/test05/LICENSE.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Sample license
|
||||||
40
war/src/plugin-test/test05/maven.xml
Normal file
40
war/src/plugin-test/test05/maven.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<!--
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* http://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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<project xmlns:j="jelly:core"
|
||||||
|
xmlns:assert="assert"
|
||||||
|
xmlns:u="jelly:util">
|
||||||
|
|
||||||
|
<goal name="testPlugin" prereqs="test-war"/>
|
||||||
|
|
||||||
|
<goal name="test-war" prereqs="clean">
|
||||||
|
<attainGoal name="war"/>
|
||||||
|
<j:set var="warFile" value="${maven.build.dir}/${pom.artifactId}.war"/>
|
||||||
|
<j:set var="warDir" value="${maven.build.dir}/${pom.artifactId}"/>
|
||||||
|
<assert:assertFileExists file="${warFile}"/>
|
||||||
|
<assert:assertFileExists file="${warDir}/WEB-INF/lib/commons-logging-1.0.4.jar"/>
|
||||||
|
<assert:assertFileExists file="${warDir}/images/logo.png"/>
|
||||||
|
<!-- check for index.html content-->
|
||||||
|
<j:set var="unzipDir" value="${maven.build.dir}/unzippedWar"/>
|
||||||
|
<mkdir dir="${unzipDir}"/>
|
||||||
|
<unzip src="${warFile}" dest="${unzipDir}"/>
|
||||||
|
|
||||||
|
<assert:assertFileContains file="${unzipDir}/index.html"
|
||||||
|
match="test-maven-war-plugin-expand-excludes"/>
|
||||||
|
</goal>
|
||||||
|
</project>
|
||||||
10
war/src/plugin-test/test05/project.properties
Normal file
10
war/src/plugin-test/test05/project.properties
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#
|
||||||
|
# Expand properties
|
||||||
|
maven.war.property.expansion=true
|
||||||
|
|
||||||
|
maven.war.expansion.excludes=images/**
|
||||||
|
|
||||||
|
#
|
||||||
|
# Property being replaced
|
||||||
|
my.cool.property=${pom.artifactId}
|
||||||
56
war/src/plugin-test/test05/project.xml
Normal file
56
war/src/plugin-test/test05/project.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?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
|
||||||
|
*
|
||||||
|
* http://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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
<project>
|
||||||
|
<pomVersion>3</pomVersion>
|
||||||
|
<id>test-maven-war-plugin-expand-excludes</id>
|
||||||
|
<name>Maven War Plugin 05</name>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<currentVersion>1.0</currentVersion>
|
||||||
|
<organization>
|
||||||
|
<name>Apache Software Foundation</name>
|
||||||
|
<url>http://www.apache.org/</url>
|
||||||
|
<logo>http://maven.apache.org/images/apache-maven-project.png</logo>
|
||||||
|
</organization>
|
||||||
|
<inceptionYear>2001</inceptionYear>
|
||||||
|
<package>org.apache.maven</package>
|
||||||
|
<logo>http://maven.apache.org/images/maven.gif</logo>
|
||||||
|
<description>Test for Maven War plugin, tests maven.war.expansion.excludes</description>
|
||||||
|
<shortDescription>test for maven.war.expansion.excludes</shortDescription>
|
||||||
|
<url>http://maven.apache.org/maven-1.x/plugins/war/</url>
|
||||||
|
<siteDirectory>/www/maven.apache.org/maven-1.x/plugins/war/</siteDirectory>
|
||||||
|
<repository>
|
||||||
|
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/war/</connection>
|
||||||
|
<url>http://svn.apache.org/viewcvs.cgi/maven/maven-1/plugins/trunk/war/</url>
|
||||||
|
</repository>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<version>1.0.4</version>
|
||||||
|
<url>http://jakarta.apache.org/commons/logging.html</url>
|
||||||
|
<properties>
|
||||||
|
<war.bundle>true</war.bundle>
|
||||||
|
<war.manifest.classpath>true</war.manifest.classpath>
|
||||||
|
</properties>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
BIN
war/src/plugin-test/test05/src/webapp/images/logo.png
Normal file
BIN
war/src/plugin-test/test05/src/webapp/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
26
war/src/plugin-test/test05/src/webapp/index.html
Normal file
26
war/src/plugin-test/test05/src/webapp/index.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<!--
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* http://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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Simple WebApp Home</h1>
|
||||||
|
<p>
|
||||||
|
This is a html page for ${my.cool.property}
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -25,6 +25,11 @@
|
|||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="1.6.3-SNAPSHOT" date="in SVN">
|
<release version="1.6.3-SNAPSHOT" date="in SVN">
|
||||||
|
<action dev="snicoll" type="fix" issue="MPWAR-65">Added maven.war.expansion.excludes property
|
||||||
|
to exclude files during a property expansion copy (Fixes corruption of binary files).
|
||||||
|
Applied property expansion to web.xml handling for consistency. Introduced the maven.war.src.filtering
|
||||||
|
property to control whether filtering is enabled or not when copying webapp resources.
|
||||||
|
</action>
|
||||||
<action dev="ltheussl" type="fix" issue="MPWAR-36">Only create tld and lib folders if corresponding dependencies are present.</action>
|
<action dev="ltheussl" type="fix" issue="MPWAR-36">Only create tld and lib folders if corresponding dependencies are present.</action>
|
||||||
<action dev="ltheussl" type="fix" issue="MPWAR-45" due-to="Kim Dykeman">war:inplace should check for maven.war.src.</action>
|
<action dev="ltheussl" type="fix" issue="MPWAR-45" due-to="Kim Dykeman">war:inplace should check for maven.war.src.</action>
|
||||||
<action dev="ltheussl" type="fix">
|
<action dev="ltheussl" type="fix">
|
||||||
|
|||||||
@ -44,20 +44,40 @@
|
|||||||
<td>maven.war.src.includes</td>
|
<td>maven.war.src.includes</td>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>
|
<td>
|
||||||
Comma or space separated list of Ant path patterns specifycing
|
Comma or space separated list of Ant path patterns specifying
|
||||||
what files and directories from <code>${maven.war.src}</code>
|
what files and directories from <code>${maven.war.src}</code>
|
||||||
should be included in the web application. All files are included
|
that should be included in the web application. All files are
|
||||||
by default.
|
included by default.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>maven.war.src.excludes</td>
|
<td>maven.war.src.excludes</td>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>
|
<td>
|
||||||
Comma or space separated list of Ant path patterns specifycing
|
Comma or space separated list of Ant path patterns specifying
|
||||||
what files and directories from <code>${maven.war.src}</code>
|
what files and directories from <code>${maven.war.src}</code>
|
||||||
should be excluded from the web application. No files are excluded
|
that should be excluded from the web application. No files are
|
||||||
by default.
|
excluded by default.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.war.expansion.excludes</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
Comma or space separated list of Ant path patterns specifying
|
||||||
|
the files and directories from <code>${maven.war.src}</code> that
|
||||||
|
should be excluded from the copy when performing property expansion.
|
||||||
|
If property expansion is not enabled this property is ignored. Files
|
||||||
|
in this excludes list are copied to the webapp without property
|
||||||
|
expansion afterwards. No files are excluded by default.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>maven.war.src.filtering</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>
|
||||||
|
Indicates whether token filtering should take place during the copy.
|
||||||
|
Default is true.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user