diff -Nru maven-filtering-1.1/debian/build.properties maven-filtering-3.1.1/debian/build.properties --- maven-filtering-1.1/debian/build.properties 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/build.properties 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -javadoc.dir=target/api -build.directory=target -maven.test.skip=true diff -Nru maven-filtering-1.1/debian/changelog maven-filtering-3.1.1/debian/changelog --- maven-filtering-1.1/debian/changelog 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/changelog 2017-07-17 15:55:17.000000000 +0000 @@ -1,3 +1,20 @@ +maven-filtering (3.1.1-1) unstable; urgency=medium + + * Team upload. + * New upstream release + - Build depend on libplexus-component-metadata-java instead + of libplexus-maven-plugin-java + - Build depend on junit4 instead of junit + - New build dependency on libassertj-core-java and libmockito-java + - Depend on libmaven3-core-java instead of libmaven2-core-java + * Build with maven-debian-helper instead of maven-ant-helper + * Moved the package to Git + * Standards-Version updated to 4.0.0 + * Switch to debhelper level 10 + * Converted debian/copyright to the Copyright Format 1.0 + + -- Emmanuel Bourg Mon, 17 Jul 2017 17:55:17 +0200 + maven-filtering (1.1-1) unstable; urgency=low * Team upload. diff -Nru maven-filtering-1.1/debian/compat maven-filtering-3.1.1/debian/compat --- maven-filtering-1.1/debian/compat 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/compat 2017-07-17 15:23:40.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru maven-filtering-1.1/debian/components.xml maven-filtering-3.1.1/debian/components.xml --- maven-filtering-1.1/debian/components.xml 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/components.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ - - - - org.apache.maven.shared.filtering.MavenResourcesFiltering - default - org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering - - - - org.sonatype.plexus.build.incremental.BuildContext - buildContext - - - org.apache.maven.shared.filtering.MavenFileFilter - default - mavenFileFilter - - - - - org.apache.maven.shared.filtering.MavenFileFilter - default - org.apache.maven.shared.filtering.DefaultMavenFileFilter - - - - org.sonatype.plexus.build.incremental.BuildContext - buildContext - - - - - diff -Nru maven-filtering-1.1/debian/control maven-filtering-3.1.1/debian/control --- maven-filtering-1.1/debian/control 2013-11-26 00:13:53.000000000 +0000 +++ maven-filtering-3.1.1/debian/control 2017-07-17 15:46:41.000000000 +0000 @@ -2,32 +2,30 @@ Section: java Priority: optional Maintainer: Debian Java Maintainers -Uploaders: Torsten Werner , - Damien Raude-Morvan -Build-Depends: cdbs, debhelper (>= 9), default-jdk -Build-Depends-Indep: ant, - ant-optional, - junit, - libmaven2-core-java, - libplexus-build-api-java, - libplexus-container-default-java, - libplexus-interpolation-java (>= 1.12), - libplexus-utils-java (>= 1.5.15), - maven-ant-helper (>> 4), - maven-repo-helper -Standards-Version: 3.9.5 -Vcs-Svn: svn://anonscm.debian.org/pkg-java/trunk/maven-filtering -Vcs-Browser: http://anonscm.debian.org/viewvc/pkg-java/trunk/maven-filtering/ +Uploaders: + Torsten Werner , + Damien Raude-Morvan +Build-Depends: + debhelper (>= 10), + default-jdk, + junit4, + libassertj-core-java, + libmaven3-core-java, + libmockito-java, + libplexus-build-api-java, + libplexus-component-metadata-java, + libplexus-interpolation-java (>= 1.12), + libplexus-utils-java (>= 1.5.15), + maven-debian-helper (>= 2.2~) +Standards-Version: 4.0.0 +Vcs-Git: https://anonscm.debian.org/git/pkg-java/maven-filtering.git +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/maven-filtering.git Homepage: http://maven.apache.org/shared/maven-filtering/ Package: libmaven-filtering-java Architecture: all -Depends: libmaven2-core-java, - libplexus-build-api-java, - libplexus-container-default-java, - libplexus-interpolation-java (>= 1.12), - libplexus-utils-java (>= 1.5.15), - ${misc:Depends} +Depends: ${maven:Depends}, ${misc:Depends} +Suggests: ${maven:OptionalDepends} Description: Maven Filtering Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, diff -Nru maven-filtering-1.1/debian/copyright maven-filtering-3.1.1/debian/copyright --- maven-filtering-1.1/debian/copyright 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/copyright 2017-07-17 15:53:03.000000000 +0000 @@ -1,33 +1,18 @@ -This package was debianized by Torsten Werner . - -The Debian packaging is Copyright (c) 2008 Torsten Werner and is -licensed under the GNU General Public License version 3. On Debian -systems, the complete text of the GNU General Public License can be -found in '/usr/share/common-licenses/GPL-3'. - -The package was downloaded from -. - -Copyright: 2008 The Apache Software Foundation. - -License: - - 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. - -The full text of the license can be found in -`/usr/share/common-licenes/Apache-2.0'. +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Apache Maven Filtering +Source: http://svn.apache.org/repos/asf/maven/shared/trunk/maven-filtering/ + +Files: * +Copyright: 2008-2016, The Apache Software Foundation +License: Apache-2.0 + +Files: debian/* +Copyright: 2008-2009, Torsten Werner + 2009, Ludovic Claude + 2011, Damien Raude-Morvan + 2013-2017, Emmanuel Bourg +License: Apache-2.0 + +License: Apache-2.0 + On Debian systems, the full text of the Apache-2.0 license + can be found in the file '/usr/share/common-licenses/Apache-2.0' diff -Nru maven-filtering-1.1/debian/libmaven-filtering-java.poms maven-filtering-3.1.1/debian/libmaven-filtering-java.poms --- maven-filtering-1.1/debian/libmaven-filtering-java.poms 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/libmaven-filtering-java.poms 2017-07-17 15:23:40.000000000 +0000 @@ -1 +1 @@ -pom.xml --no-parent +pom.xml --no-parent --has-package-version diff -Nru maven-filtering-1.1/debian/maven.ignoreRules maven-filtering-3.1.1/debian/maven.ignoreRules --- maven-filtering-1.1/debian/maven.ignoreRules 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/debian/maven.ignoreRules 2017-07-17 15:23:40.000000000 +0000 @@ -0,0 +1 @@ +org.sonatype.plexus plexus-build-api jar * tests * diff -Nru maven-filtering-1.1/debian/maven.properties maven-filtering-3.1.1/debian/maven.properties --- maven-filtering-1.1/debian/maven.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/debian/maven.properties 2017-07-17 15:23:40.000000000 +0000 @@ -0,0 +1,5 @@ +# Include here properties to pass to Maven during the build. +# For example: +# maven.test.skip=true + +maven.test.skip=true diff -Nru maven-filtering-1.1/debian/maven.rules maven-filtering-3.1.1/debian/maven.rules --- maven-filtering-1.1/debian/maven.rules 2013-11-26 00:13:53.000000000 +0000 +++ maven-filtering-3.1.1/debian/maven.rules 2017-07-17 15:46:25.000000000 +0000 @@ -1,3 +1,3 @@ -junit junit jar s/3\..*/3.x/ -org.codehaus.plexus plexus-container-default jar s/1\.0-alpha.*/1.0-alpha/ - +junit junit jar s/.*/4.x/ +org.codehaus.plexus plexus-component-metadata maven-plugin s/1.6/1.5.5/ * * +org.apache.maven maven-core * s/.*/3.x/ * * diff -Nru maven-filtering-1.1/debian/rules maven-filtering-3.1.1/debian/rules --- maven-filtering-1.1/debian/rules 2013-11-26 00:13:54.000000000 +0000 +++ maven-filtering-3.1.1/debian/rules 2017-07-17 15:23:40.000000000 +0000 @@ -1,34 +1,7 @@ #!/usr/bin/make -f -include /usr/share/cdbs/1/rules/debhelper.mk -include /usr/share/cdbs/1/class/ant.mk - -PACKAGE := $(DEB_SOURCE_PACKAGE) -VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | sed -s "s/~/-/") -JAVA_HOME := /usr/lib/jvm/default-java -DEB_JARS := ant-nodeps maven-core maven-project maven-model maven-settings \ - plexus-build-api plexus-container-default-alpha plexus-interpolation plexus-utils junit -DEB_ANT_BUILD_TARGET := package #javadoc -DEB_ANT_BUILDFILE := /usr/share/maven-ant-helper/maven-build.xml -DEB_ANT_ARGS := -Dbasedir=$(realpath .) -Dpackage=$(PACKAGE) -API_DOCS := target/api +%: + dh $@ get-orig-source: - -uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename - -makebuilddir/lib$(PACKAGE)-java:: - install -d target/classes/META-INF/plexus/ - install -m644 debian/components.xml target/classes/META-INF/plexus/ - -binary-post-install/lib$(PACKAGE)-java:: - mh_installpoms -plib$(PACKAGE)-java - mh_installjar -plib$(PACKAGE)-java -l pom.xml target/$(PACKAGE)-$(VERSION).jar - -clean:: - mh_clean - mh_unpatchpoms -plib$(PACKAGE)-java - -# Extract generated plexus components.xml files from a standard Maven build -copy-plexus-components: target/classes/META-INF/plexus/components.xml - cp target/classes/META-INF/plexus/components.xml debian/components.xml - + -uscan --download-current --force-download --rename diff -Nru maven-filtering-1.1/deploySite.sh maven-filtering-3.1.1/deploySite.sh --- maven-filtering-1.1/deploySite.sh 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/deploySite.sh 2016-05-28 21:58:54.000000000 +0000 @@ -0,0 +1,23 @@ +#!/bin/sh + +# +# 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. +# + +mvn -Preporting site site:stage $@ +mvn scm-publish:publish-scm $@ diff -Nru maven-filtering-1.1/pom.xml maven-filtering-3.1.1/pom.xml --- maven-filtering-1.1/pom.xml 2012-08-10 04:35:50.000000000 +0000 +++ maven-filtering-3.1.1/pom.xml 2016-05-30 20:26:05.000000000 +0000 @@ -1,19 +1,19 @@ @@ -23,34 +23,38 @@ org.apache.maven.shared maven-shared-components - 17 - ../maven-shared-components/pom.xml + 30 + ../../pom/maven/maven-shared-components/pom.xml - org.apache.maven.shared maven-filtering - 1.1 - jar + 3.1.1 - Maven Filtering + Apache Maven Filtering A component to assist in filtering of resource files with properties from a Maven project. - 2.0.6 + ${mavenVersion} - scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/maven-filtering-1.1 - scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/maven-filtering-1.1 - http://svn.apache.org/viewvc/maven/shared/tags/maven-filtering-1.1 + scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/maven-filtering-3.1.1 + scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/maven-filtering-3.1.1 + http://svn.apache.org/viewvc/maven/shared/tags/maven-filtering-3.1.1 - jira - http://jira.codehaus.org/browse/MSHARED/component/13380 + JIRA + https://issues.apache.org/jira/browse/MSHARED/component/12326444 - + + + apache.website + scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path} + + + - 2.0.6 + 3.0 @@ -58,88 +62,80 @@ Graham Leggett - - - - - junit - junit - 3.8.1 - test - - - + org.apache.maven - maven-project - ${mavenVersion} - - - org.apache.maven maven-core ${mavenVersion} - org.apache.maven - maven-model - ${mavenVersion} - - - org.apache.maven - maven-artifact - ${mavenVersion} - - - org.apache.maven - maven-monitor - ${mavenVersion} - test - - - org.apache.maven - maven-settings - ${mavenVersion} - - - org.codehaus.plexus - plexus-container-default - 1.0-alpha-9-stable-1 + org.apache.maven.shared + maven-shared-utils + 3.0.0 org.codehaus.plexus plexus-utils - 1.5.15 + 3.0.24 org.codehaus.plexus plexus-interpolation - 1.12 + 1.22 org.sonatype.plexus plexus-build-api - 0.0.4 + 0.0.7 + + + + com.google.code.findbugs + jsr305 + 3.0.0 + provided org.sonatype.plexus plexus-build-api + 0.0.4 test tests + + + org.mockito + mockito-core + 1.9.5 + test + + + junit + junit + 4.11 + test + + + + org.assertj + assertj-core + 1.7.1 + test + + org.codehaus.plexus - plexus-maven-plugin - 1.3.4 + plexus-component-metadata - descriptor + generate-metadata @@ -155,13 +151,14 @@ org.apache.maven.plugins maven-changes-plugin - 2.4 Type,Key,Summary,Assignee,Status,Resolution,Created 200 true Key maven-filtering- + 12335751 + true diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/AbstractFilterReaderLineEnding.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/AbstractFilterReaderLineEnding.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/AbstractFilterReaderLineEnding.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/AbstractFilterReaderLineEnding.java 2015-11-07 11:01:55.000000000 +0000 @@ -0,0 +1,114 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.FilterReader; +import java.io.Reader; +import java.util.LinkedHashSet; + +import org.codehaus.plexus.interpolation.multi.DelimiterSpecification; + +/** + * @author Karl Heinz Marbaise + */ +public abstract class AbstractFilterReaderLineEnding + extends FilterReader +{ + + private String escapeString; + + /** + * using escape or not. + */ + protected boolean useEscape = false; + + /** + * if true escapeString will be preserved \{foo} -> \{foo} + */ + private boolean preserveEscapeString = false; + + protected LinkedHashSet delimiters = new LinkedHashSet(); + + /** + * must always be bigger than escape string plus delimiters, but doesn't need to be exact + */ + protected int markLength = 128; + + protected AbstractFilterReaderLineEnding( Reader in ) + { + super( in ); + } + + /** + * @return the escapce string. + */ + public String getEscapeString() + { + return escapeString; + } + + /** + * @param escapeString Set the value of the escape string. + */ + public void setEscapeString( String escapeString ) + { + // TODO NPE if escapeString is null ? + if ( escapeString != null && escapeString.length() >= 1 ) + { + this.escapeString = escapeString; + this.useEscape = escapeString != null && escapeString.length() >= 1; + calculateMarkLength(); + } + } + + /** + * @return state of preserve escape string. + */ + public boolean isPreserveEscapeString() + { + return preserveEscapeString; + } + + /** + * @param preserveEscapeString preserve escape string {@code true} or {@code false}. + */ + public void setPreserveEscapeString( boolean preserveEscapeString ) + { + this.preserveEscapeString = preserveEscapeString; + } + + protected void calculateMarkLength() + { + markLength = 128; + + if ( escapeString != null ) + { + + markLength += escapeString.length(); + + } + for ( DelimiterSpecification spec : delimiters ) + { + markLength += spec.getBegin().length(); + markLength += spec.getEnd().length(); + + } + } +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequest.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequest.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequest.java 2012-07-05 09:16:43.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequest.java 2016-02-08 08:19:47.000000000 +0000 @@ -19,14 +19,13 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; - import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Properties; -import java.util.Set; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; /** * @since 1.0-beta-3 @@ -40,65 +39,69 @@ private boolean escapeWindowsPaths = true; - private String encoding; - private MavenSession mavenSession; - /** - * List of Strings considered as expressions which contains values in the project/pom: - * pom project - * Default value will be pom and project. + /** + * List of Strings considered as expressions which contains values in the project/pom: pom project Default value + * will be pom and project. * * @since 1.0-beta-2 */ private List projectStartExpressions = new ArrayList(); - + /** - * String which will escape interpolation mechanism: - * foo \${foo.bar} -> foo ${foo.bar} + * String which will escape interpolation mechanism: foo \${foo.bar} -> foo ${foo.bar} * * @since 1.0-beta-2 */ private String escapeString; - + /** * @since 1.0-beta-3 */ private Properties additionalProperties; - + /** * @since 1.0-beta-3 */ private boolean injectProjectBuildFilters = false; - + /** - * Set of expression delimiter specifications to use during filtering. Delimiter specifications are - * given in the form 'BEGIN*END' or, for symmetrical delimiters, simply 'TOKEN'. The default - * values are '${*}' and '@'. + * Set of expression delimiter specifications to use during filtering. Delimiter specifications are given in the + * form 'BEGIN*END' or, for symmetrical delimiters, simply 'TOKEN'. The default values are '${*}' and '@'. * * @since 1.0-beta-3 */ private LinkedHashSet delimiters = new LinkedHashSet(); - + /** * Do not stop trying to filter tokens when reaching EOL. * * @since 1.0 */ private boolean supportMultiLineFiltering; - + + /** + * Create instance. + */ protected AbstractMavenFilteringRequest() { initDefaults(); } + /** + * Create instance with given parameters + * + * @param mavenProject The instance of MavenProject. + * @param filters The list of filters. + * @param mavenSession The MavenSession. + */ protected AbstractMavenFilteringRequest( MavenProject mavenProject, List filters, - String encoding, MavenSession mavenSession ) + MavenSession mavenSession ) { initDefaults(); this.mavenProject = mavenProject; this.filters = filters; - this.encoding = encoding; this.mavenSession = mavenSession; } @@ -106,43 +109,72 @@ { projectStartExpressions.add( "pom" ); projectStartExpressions.add( "project" ); - + delimiters.add( "${*}" ); delimiters.add( "@" ); } + /** + * @return The MavenProject + */ public MavenProject getMavenProject() { return mavenProject; } + /** + * Set the MavenProject. + * + * @param mavenProject The MavenProject to be set. + */ public void setMavenProject( MavenProject mavenProject ) { this.mavenProject = mavenProject; } + /** + * The list of filters. + * + * @return The list of currently set filters. + */ public List getFilters() { return filters; } + /** + * Set the filters. + * + * @param filters Set the list of filters + */ public void setFilters( List filters ) { this.filters = filters; } + /** + * Alias for {@link #getFilters()}. + * + * @return The list of filters. + */ public List getFileFilters() { return getFilters(); } - public void setFileFilters( List filters ) + /** + * Alias for {@link #setFilters(List)} + * + * @param paramfilters The list of filters to be set. + */ + public void setFileFilters( List paramfilters ) { - setFilters( filters ); + setFilters( paramfilters ); } /** * @since 1.0-beta-3 + * @return true if escape is activated false otherwise. */ public boolean isEscapeWindowsPaths() { @@ -151,43 +183,51 @@ /** * @since 1.0-beta-3 + * @param escapedBackslashesInFilePath true or false. */ public void setEscapeWindowsPaths( boolean escapedBackslashesInFilePath ) { this.escapeWindowsPaths = escapedBackslashesInFilePath; } - + + /** + * Alias for {@link #isEscapeWindowsPaths()} + * + * @return The current value of {@link #isEscapeWindowsPaths()} + */ public boolean isEscapedBackslashesInFilePath() { return isEscapeWindowsPaths(); } - + + /** + * Alias for {@link #setEscapeWindowsPaths(boolean)} + * + * @param escape activate or deactivate escaping. + */ public void setEscapedBackslashesInFilePath( boolean escape ) { setEscapeWindowsPaths( escape ); } - public String getEncoding() - { - return encoding; - } - - public void setEncoding( String encoding ) - { - this.encoding = encoding; - } - + /** + * @return Current value of mavenSession + */ public MavenSession getMavenSession() { return mavenSession; } + /** + * @param mavenSession Set new value for the MavenSession of the instance. + */ public void setMavenSession( MavenSession mavenSession ) { this.mavenSession = mavenSession; } /** + * @return the additional properties. * @since 1.0-beta-3 */ public Properties getAdditionalProperties() @@ -196,6 +236,7 @@ } /** + * @param additionalProperties The additional properties to be set. * @since 1.0-beta-3 */ public void setAdditionalProperties( Properties additionalProperties ) @@ -204,6 +245,7 @@ } /** + * @return the current value of injectProjectBuildFilters. * @since 1.0-beta-3 */ public boolean isInjectProjectBuildFilters() @@ -212,6 +254,7 @@ } /** + * @param injectProjectBuildFilters true or false. * @since 1.0-beta-3 */ public void setInjectProjectBuildFilters( boolean injectProjectBuildFilters ) @@ -220,6 +263,7 @@ } /** + * @return Current value of escapeString. * @since 1.0-beta-2 */ public String getEscapeString() @@ -228,27 +272,28 @@ } /** - * @param escapeString + * @param escapeString The escape string to use * @since 1.0-beta-2 */ public void setEscapeString( String escapeString ) { this.escapeString = escapeString; } - + /** + * @return The list of project start expressions. * @since 1.0-beta-2 */ - public List getProjectStartExpressions() + public List getProjectStartExpressions() { return projectStartExpressions; } /** - * @param projectStartExpressions + * @param projectStartExpressions The start expressions * @since 1.0-beta-2 */ - public void setProjectStartExpressions( List projectStartExpressions ) + public void setProjectStartExpressions( List projectStartExpressions ) { this.projectStartExpressions = projectStartExpressions; } @@ -265,8 +310,8 @@ } /** - * Set the delimiter specifications to use during filtering. Specifications should be of the form: - * 'BEGIN*END' for asymmetrical delimiters, or 'TOKEN' for symmetrical delimiters. See + * Set the delimiter specifications to use during filtering. Specifications should be of the form: 'BEGIN*END' for + * asymmetrical delimiters, or 'TOKEN' for symmetrical delimiters. See * {@link AbstractMavenFilteringRequest#delimiters} for more information and default values. * * @param delimiters If null, reset delimiters to '${*}' only. Otherwise, use the provided value. @@ -285,11 +330,50 @@ } } + /** + * @param delimiters If {@code null} than nothing will happen. If not {@code null} the delimiters will be set + * according to the contents. If delimiter entries are {@code null} those entries will be set to '${*}'. + * @param useDefaultDelimiters true if the default delimiters will be used false otherwise. + */ + public void setDelimiters( LinkedHashSet delimiters, boolean useDefaultDelimiters ) + { + if ( delimiters != null && !delimiters.isEmpty() ) + { + LinkedHashSet delims = new LinkedHashSet(); + if ( useDefaultDelimiters ) + { + delims.addAll( this.getDelimiters() ); + } + + for ( String delim : delimiters ) + { + if ( delim == null ) + { + // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution. + delims.add( "${*}" ); + } + else + { + delims.add( delim ); + } + } + + this.setDelimiters( delims ); + } + + } + + /** + * @return If support multiple line filtering is active or not. + */ public boolean isSupportMultiLineFiltering() { return supportMultiLineFiltering; } + /** + * @param supportMultiLineFiltering activate or deactivate multiple line filtering support. + */ public void setSupportMultiLineFiltering( boolean supportMultiLineFiltering ) { this.supportMultiLineFiltering = supportMultiLineFiltering; diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/BaseFilter.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/BaseFilter.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/BaseFilter.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/BaseFilter.java 2016-05-21 11:53:12.000000000 +0000 @@ -0,0 +1,335 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.apache.maven.shared.utils.StringUtils; +import org.apache.maven.shared.utils.io.FileUtils; +import org.codehaus.plexus.interpolation.InterpolationPostProcessor; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; +import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; +import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor; +import org.codehaus.plexus.interpolation.SingleResponseValueSource; +import org.codehaus.plexus.interpolation.ValueSource; +import org.codehaus.plexus.interpolation.multi.MultiDelimiterStringSearchInterpolator; +import org.codehaus.plexus.logging.AbstractLogEnabled; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Properties; + +import javax.annotation.Nonnull; + +class BaseFilter + extends AbstractLogEnabled + implements DefaultFilterInfo +{ + + @Nonnull + public List getDefaultFilterWrappers( final MavenProject mavenProject, + List filters, + final boolean escapedBackslashesInFilePath, + MavenSession mavenSession, + MavenResourcesExecution mavenResourcesExecution ) + throws MavenFilteringException + { + + MavenResourcesExecution mre = + mavenResourcesExecution == null ? new MavenResourcesExecution() : mavenResourcesExecution.copyOf(); + + mre.setMavenProject( mavenProject ); + mre.setMavenSession( mavenSession ); + mre.setFilters( filters ); + mre.setEscapedBackslashesInFilePath( escapedBackslashesInFilePath ); + + return getDefaultFilterWrappers( mre ); + + } + + @Nonnull + public List getDefaultFilterWrappers( final AbstractMavenFilteringRequest req ) + throws MavenFilteringException + { + // backup values + boolean supportMultiLineFiltering = req.isSupportMultiLineFiltering(); + + // compensate for null parameter value. + final AbstractMavenFilteringRequest request = req == null ? new MavenFileFilterRequest() : req; + + request.setSupportMultiLineFiltering( supportMultiLineFiltering ); + + // Here we build some properties which will be used to read some properties files + // to interpolate the expression ${ } in this properties file + + // Take a copy of filterProperties to ensure that evaluated filterTokens are not propagated + // to subsequent filter files. Note: this replicates current behaviour and seems to make sense. + + final Properties baseProps = new Properties(); + + // Project properties + if ( request.getMavenProject() != null ) + { + baseProps.putAll( request.getMavenProject().getProperties() == null ? Collections.emptyMap() + : request.getMavenProject().getProperties() ); + } + // TODO this is NPE free but do we consider this as normal + // or do we have to throw an MavenFilteringException with mavenSession cannot be null + // + // khmarbaise: 2016-05-21: + // If we throw an MavenFilteringException tests will fail which is + // caused by for example: + // void copyFile( File from, final File to, boolean filtering, List filterWrappers, + // String encoding ) + // in MavenFileFilter interface where no MavenSession is given. + // So changing here to throw a MavenFilteringException would make + // it necessary to change the interface or we need to find a better solution. + // + if ( request.getMavenSession() != null ) + { + // User properties have precedence over system properties + baseProps.putAll( request.getMavenSession().getSystemProperties() ); + baseProps.putAll( request.getMavenSession().getUserProperties() ); + } + + // now we build properties to use for resources interpolation + + final Properties filterProperties = new Properties(); + + File basedir = request.getMavenProject() != null ? request.getMavenProject().getBasedir() : new File( "." ); + + loadProperties( filterProperties, basedir, request.getFileFilters(), baseProps ); + if ( filterProperties.size() < 1 ) + { + filterProperties.putAll( baseProps ); + } + + if ( request.getMavenProject() != null ) + { + if ( request.isInjectProjectBuildFilters() ) + { + List buildFilters = new ArrayList( request.getMavenProject().getBuild().getFilters() ); + + // JDK-8015656: (coll) unexpected NPE from removeAll + if ( request.getFileFilters() != null ) + { + buildFilters.removeAll( request.getFileFilters() ); + } + + loadProperties( filterProperties, basedir, buildFilters, baseProps ); + } + + // Project properties + filterProperties.putAll( request.getMavenProject().getProperties() == null ? Collections.emptyMap() + : request.getMavenProject().getProperties() ); + } + if ( request.getMavenSession() != null ) + { + // User properties have precedence over system properties + filterProperties.putAll( request.getMavenSession().getSystemProperties() ); + filterProperties.putAll( request.getMavenSession().getUserProperties() ); + } + + if ( request.getAdditionalProperties() != null ) + { + // additional properties wins + filterProperties.putAll( request.getAdditionalProperties() ); + } + + List defaultFilterWrappers = + request == null ? new ArrayList( 1 ) + : new ArrayList( request.getDelimiters().size() + 1 ); + + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( "properties used " + filterProperties ); + } + + final ValueSource propertiesValueSource = new PropertiesBasedValueSource( filterProperties ); + + if ( request != null ) + { + FileUtils.FilterWrapper wrapper = + new Wrapper( request.getDelimiters(), request.getMavenProject(), request.getMavenSession(), + propertiesValueSource, request.getProjectStartExpressions(), request.getEscapeString(), + request.isEscapeWindowsPaths(), request.isSupportMultiLineFiltering() ); + + defaultFilterWrappers.add( wrapper ); + } + + return defaultFilterWrappers; + } + + /** + * default visibility only for testing reason ! + */ + void loadProperties( Properties filterProperties, File basedir, List propertiesFilePaths, + Properties baseProps ) + throws MavenFilteringException + { + if ( propertiesFilePaths != null ) + { + Properties workProperties = new Properties(); + workProperties.putAll( baseProps ); + + for ( String filterFile : propertiesFilePaths ) + { + if ( StringUtils.isEmpty( filterFile ) ) + { + // skip empty file name + continue; + } + try + { + File propFile = FileUtils.resolveFile( basedir, filterFile ); + Properties properties = PropertyUtils.loadPropertyFile( propFile, workProperties ); + filterProperties.putAll( properties ); + workProperties.putAll( properties ); + } + catch ( IOException e ) + { + throw new MavenFilteringException( "Error loading property file '" + filterFile + "'", e ); + } + } + } + } + + private static final class Wrapper + extends FileUtils.FilterWrapper + { + + private LinkedHashSet delimiters; + + private MavenProject project; + + private ValueSource propertiesValueSource; + + private List projectStartExpressions; + + private String escapeString; + + private boolean escapeWindowsPaths; + + private final MavenSession mavenSession; + + private boolean supportMultiLineFiltering; + + Wrapper( LinkedHashSet delimiters, MavenProject project, MavenSession mavenSession, + ValueSource propertiesValueSource, List projectStartExpressions, String escapeString, + boolean escapeWindowsPaths, boolean supportMultiLineFiltering ) + { + super(); + this.delimiters = delimiters; + this.project = project; + this.mavenSession = mavenSession; + this.propertiesValueSource = propertiesValueSource; + this.projectStartExpressions = projectStartExpressions; + this.escapeString = escapeString; + this.escapeWindowsPaths = escapeWindowsPaths; + this.supportMultiLineFiltering = supportMultiLineFiltering; + } + + public Reader getReader( Reader reader ) + { + Interpolator interpolator = createInterpolator( delimiters, projectStartExpressions, propertiesValueSource, + project, mavenSession, escapeString, escapeWindowsPaths ); + + MultiDelimiterInterpolatorFilterReaderLineEnding filterReader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( reader, interpolator, supportMultiLineFiltering ); + + final RecursionInterceptor ri; + if ( projectStartExpressions != null && !projectStartExpressions.isEmpty() ) + { + ri = new PrefixAwareRecursionInterceptor( projectStartExpressions, true ); + } + else + { + ri = new SimpleRecursionInterceptor(); + } + + filterReader.setRecursionInterceptor( ri ); + filterReader.setDelimiterSpecs( delimiters ); + + filterReader.setInterpolateWithPrefixPattern( false ); + filterReader.setEscapeString( escapeString ); + + return filterReader; + } + + } + + private static Interpolator createInterpolator( LinkedHashSet delimiters, + List projectStartExpressions, + ValueSource propertiesValueSource, MavenProject project, + MavenSession mavenSession, String escapeString, + boolean escapeWindowsPaths ) + { + MultiDelimiterStringSearchInterpolator interpolator = new MultiDelimiterStringSearchInterpolator(); + interpolator.setDelimiterSpecs( delimiters ); + + interpolator.addValueSource( propertiesValueSource ); + + if ( project != null ) + { + interpolator.addValueSource( new PrefixedObjectValueSource( projectStartExpressions, project, true ) ); + } + + if ( mavenSession != null ) + { + interpolator.addValueSource( new PrefixedObjectValueSource( "session", mavenSession ) ); + + final Settings settings = mavenSession.getSettings(); + if ( settings != null ) + { + interpolator.addValueSource( new PrefixedObjectValueSource( "settings", settings ) ); + interpolator.addValueSource( new SingleResponseValueSource( "localRepository", + settings.getLocalRepository() ) ); + } + } + + interpolator.setEscapeString( escapeString ); + + if ( escapeWindowsPaths ) + { + interpolator.addPostProcessor( new InterpolationPostProcessor() + { + public Object execute( String expression, Object value ) + { + if ( value instanceof String ) + { + return FilteringUtils.escapeWindowsPath( (String) value ); + } + + return value; + } + } ); + } + return interpolator; + } +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/BoundedReader.java 2015-10-31 21:45:30.000000000 +0000 @@ -0,0 +1,104 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.IOException; +import java.io.Reader; + +/** + * A reader that imposes a limit to the number of bytes that can be read from an underlying reader, simulating eof when + * this limit is reached. This stream can typically be used to constrain a client with regard to a readAheadLimit of an + * underlying stream, to avoid overrunning this limit and hence lose the opportunity do to reset. + */ +public class BoundedReader + extends Reader +{ + + private final Reader target; + + int pos = 0; + + int readAheadLimit; + + /** + * @param target {@link Reader} + * @param readAheadLimit read ahead limit. + * @throws IOException in case of a failure. + */ + public BoundedReader( Reader target, int readAheadLimit ) + throws IOException + { + this.target = target; + target.mark( readAheadLimit ); + this.readAheadLimit = readAheadLimit; + } + + @Override + public void close() + throws IOException + { + target.close(); + } + + @Override + public void reset() + throws IOException + { + pos = 0; + target.reset(); + } + + @Override + public void mark( int theReadAheadLimit ) + throws IOException + { + this.readAheadLimit = theReadAheadLimit; + target.mark( theReadAheadLimit ); + } + + @Override + public int read() + throws IOException + { + if ( pos >= readAheadLimit ) + { + return -1; + } + pos++; + return target.read(); + } + + @Override + public int read( char[] cbuf, int off, int len ) + throws IOException + { + int c; + for ( int i = 0; i < len; i++ ) + { + c = read(); + if ( c == -1 ) + { + return i; + } + cbuf[off + i] = (char) c; + } + return len; + } +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultFilterInfo.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultFilterInfo.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultFilterInfo.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultFilterInfo.java 2015-10-31 22:38:16.000000000 +0000 @@ -0,0 +1,62 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.util.List; + +import javax.annotation.Nonnull; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.io.FileUtils; + +/** + * @author Kristian Rosenvold + */ +public interface DefaultFilterInfo +{ + + /** + * @param mavenProject The maven project + * @param filters The filters to get + * @param escapedBackslashesInFilePath escape backslashes ? + * @param mavenSession The maven session + * @param mavenResourcesExecution The filtering configuration + * @throws MavenFilteringException in case of failure. + * @return {@link java.util.List} of FileUtils.FilterWrapper + * @since 1.0-beta-2 + */ + @Nonnull + List getDefaultFilterWrappers( MavenProject mavenProject, List filters, + boolean escapedBackslashesInFilePath, + MavenSession mavenSession, + MavenResourcesExecution mavenResourcesExecution ) + throws MavenFilteringException; + + /** + * @param request The filtering request + * @throws org.apache.maven.shared.filtering.MavenFilteringException in case of failure. + * @return {@link java.util.List} of FileUtils.FilterWrapper + * @since 1.0-beta-3 + */ + @Nonnull + List getDefaultFilterWrappers( AbstractMavenFilteringRequest request ) + throws MavenFilteringException; +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java 2012-07-05 09:21:34.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenFileFilter.java 2015-11-05 06:23:46.000000000 +0000 @@ -19,52 +19,53 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; -import org.apache.maven.settings.Settings; -import org.codehaus.plexus.interpolation.InterpolationPostProcessor; -import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; -import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; -import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; -import org.codehaus.plexus.interpolation.RecursionInterceptor; -import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor; -import org.codehaus.plexus.interpolation.SingleResponseValueSource; -import org.codehaus.plexus.interpolation.ValueSource; -import org.codehaus.plexus.interpolation.multi.MultiDelimiterStringSearchInterpolator; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; -import org.sonatype.plexus.build.incremental.BuildContext; - +import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; import java.io.Reader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; +import java.io.UnsupportedEncodingException; +import java.io.Writer; import java.util.List; -import java.util.Properties; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.StringUtils; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper; +import org.apache.maven.shared.utils.io.IOUtil; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.sonatype.plexus.build.incremental.BuildContext; /** * @author Olivier Lamy - * - * @plexus.component role="org.apache.maven.shared.filtering.MavenFileFilter" - * role-hint="default" */ +@Component( role = org.apache.maven.shared.filtering.MavenFileFilter.class, hint = "default" ) public class DefaultMavenFileFilter - extends AbstractLogEnabled + extends BaseFilter implements MavenFileFilter { - /** - * @plexus.requirement - */ + @Requirement + private MavenReaderFilter readerFilter; + + @Requirement private BuildContext buildContext; + /** {@inheritDoc} */ public void copyFile( File from, File to, boolean filtering, MavenProject mavenProject, List filters, boolean escapedBackslashesInFilePath, String encoding, MavenSession mavenSession ) - throws MavenFilteringException + throws MavenFilteringException { MavenResourcesExecution mre = new MavenResourcesExecution(); mre.setMavenProject( mavenProject ); @@ -77,29 +78,29 @@ copyFile( from, to, filtering, filterWrappers, encoding ); } - + /** {@inheritDoc} */ public void copyFile( MavenFileFilterRequest mavenFileFilterRequest ) throws MavenFilteringException { - List filterWrappers = getDefaultFilterWrappers( mavenFileFilterRequest ); + List filterWrappers = getDefaultFilterWrappers( mavenFileFilterRequest ); copyFile( mavenFileFilterRequest.getFrom(), mavenFileFilterRequest.getTo(), mavenFileFilterRequest.isFiltering(), filterWrappers, mavenFileFilterRequest.getEncoding() ); } - + /** {@inheritDoc} */ public void copyFile( File from, File to, boolean filtering, List filterWrappers, String encoding ) - throws MavenFilteringException + throws MavenFilteringException { // overwrite forced to false to preserve backward comp copyFile( from, to, filtering, filterWrappers, encoding, false ); } - + /** {@inheritDoc} */ public void copyFile( File from, File to, boolean filtering, List filterWrappers, String encoding, boolean overwrite ) - throws MavenFilteringException + throws MavenFilteringException { try { @@ -109,9 +110,7 @@ { getLogger().debug( "filtering " + from.getPath() + " to " + to.getPath() ); } - FileUtils.FilterWrapper[] wrappers = (FileUtils.FilterWrapper[]) filterWrappers.toArray( - new FileUtils.FilterWrapper[filterWrappers.size()] ); - FileUtils.copyFile( from, to, encoding, wrappers ); + filterFile( from, to, encoding, filterWrappers ); } else { @@ -131,267 +130,65 @@ } - /** - * @see org.apache.maven.shared.filtering.MavenFileFilter#getDefaultFilterWrappers(org.apache.maven.project.MavenProject, java.util.List, boolean, org.apache.maven.execution.MavenSession) - * @deprecated - */ - public List getDefaultFilterWrappers( final MavenProject mavenProject, - List filters, - final boolean escapedBackslashesInFilePath, - MavenSession mavenSession ) - throws MavenFilteringException - { - return getDefaultFilterWrappers( mavenProject, filters, escapedBackslashesInFilePath, mavenSession, null ); - } - - - public List getDefaultFilterWrappers( final MavenProject mavenProject, List filters, - final boolean escapedBackslashesInFilePath, - MavenSession mavenSession, - MavenResourcesExecution mavenResourcesExecution ) - throws MavenFilteringException - { - - MavenResourcesExecution mre = - mavenResourcesExecution == null ? new MavenResourcesExecution() : mavenResourcesExecution.copyOf(); - - mre.setMavenProject( mavenProject ); - mre.setMavenSession( mavenSession ); - mre.setFilters( filters ); - mre.setEscapedBackslashesInFilePath( escapedBackslashesInFilePath ); - - return getDefaultFilterWrappers( mre ); - - } - - public List getDefaultFilterWrappers( final AbstractMavenFilteringRequest req ) - throws MavenFilteringException + private void filterFile( @Nonnull File from, @Nonnull File to, @Nullable String encoding, + @Nullable List wrappers ) + throws IOException, MavenFilteringException { - // backup values - boolean supportMultiLineFiltering = req.isSupportMultiLineFiltering(); - - // compensate for null parameter value. - final AbstractMavenFilteringRequest request = req == null ? new MavenFileFilterRequest() : req; - - request.setSupportMultiLineFiltering( supportMultiLineFiltering ); - - // Here we build some properties which will be used to read some properties files - // to interpolate the expression ${ } in this properties file - - // Take a copy of filterProperties to ensure that evaluated filterTokens are not propagated - // to subsequent filter files. Note: this replicates current behaviour and seems to make sense. - - final Properties baseProps = new Properties(); - - // Project properties - if ( request.getMavenProject() != null ) - { - baseProps.putAll( request.getMavenProject().getProperties() == null - ? Collections.emptyMap() - : request.getMavenProject().getProperties() ); - } - // TODO this is NPE free but do we consider this as normal - // or do we have to throw an MavenFilteringException with mavenSession cannot be null - if ( request.getMavenSession() != null ) - { - // execution properties wins - baseProps.putAll( request.getMavenSession().getExecutionProperties() ); - } - - // now we build properties to use for resources interpolation - - final Properties filterProperties = new Properties(); - - loadProperties( filterProperties, request.getFileFilters(), baseProps ); - if ( filterProperties.size() < 1 ) + if ( wrappers != null && wrappers.size() > 0 ) { - filterProperties.putAll( baseProps ); - } - - if ( request.getMavenProject() != null ) - { - if ( request.isInjectProjectBuildFilters() ) + Reader fileReader = null; + Writer fileWriter = null; + try { - List buildFilters = new ArrayList( request.getMavenProject().getBuild().getFilters() ); - buildFilters.removeAll( request.getFileFilters() ); + fileReader = getFileReader( encoding, from ); + fileWriter = getFileWriter( encoding, to ); + Reader src = readerFilter.filter( fileReader, true, wrappers ); - loadProperties( filterProperties, buildFilters, baseProps ); + IOUtil.copy( src, fileWriter ); + } + finally + { + IOUtil.close( fileReader ); + IOUtil.close( fileWriter ); } - - // Project properties - filterProperties.putAll( request.getMavenProject().getProperties() == null - ? Collections.emptyMap() - : request.getMavenProject().getProperties() ); - } - if ( request.getMavenSession() != null ) - { - // execution properties wins - filterProperties.putAll( request.getMavenSession().getExecutionProperties() ); - } - - if ( request.getAdditionalProperties() != null ) - { - // additional properties wins - filterProperties.putAll( request.getAdditionalProperties() ); - } - - List defaultFilterWrappers = request == null - ? new ArrayList( 1 ) - : new ArrayList( request.getDelimiters().size() + 1 ); - - if ( getLogger().isDebugEnabled() ) - { - getLogger().debug( "properties used " + filterProperties ); } - - final ValueSource propertiesValueSource = new PropertiesBasedValueSource( filterProperties ); - - if ( request != null ) + else { - FileUtils.FilterWrapper wrapper = - new Wrapper( request.getDelimiters(), request.getMavenProject(), request.getMavenSession(), - propertiesValueSource, request.getProjectStartExpressions(), request.getEscapeString(), - request.isEscapeWindowsPaths(), request.isSupportMultiLineFiltering() ); - - defaultFilterWrappers.add( wrapper ); + if ( to.lastModified() < from.lastModified() ) + { + FileUtils.copyFile( from, to ); + } } - - return defaultFilterWrappers; } - /** - * protected only for testing reason ! - */ - protected void loadProperties( Properties filterProperties, List propertiesFilePaths, Properties baseProps ) - throws MavenFilteringException + private Writer getFileWriter( String encoding, File to ) + throws IOException { - if ( propertiesFilePaths != null ) + if ( StringUtils.isEmpty( encoding ) ) { - Properties workProperties = new Properties(); - workProperties.putAll( baseProps ); + return new FileWriter( to ); + } + else + { + FileOutputStream outstream = new FileOutputStream( to ); - for ( Iterator iterator = propertiesFilePaths.iterator(); iterator.hasNext(); ) - { - String filterFile = (String) iterator.next(); - if ( StringUtils.isEmpty( filterFile ) ) - { - // skip empty file name - continue; - } - try - { - // TODO new File should be new File(mavenProject.getBasedir(), filterfile ) ? - Properties properties = PropertyUtils.loadPropertyFile( new File( filterFile ), workProperties ); - filterProperties.putAll( properties ); - workProperties.putAll( properties ); - } - catch ( IOException e ) - { - throw new MavenFilteringException( "Error loading property file '" + filterFile + "'", e ); - } - } + return new OutputStreamWriter( outstream, encoding ); } } - private static final class Wrapper - extends FileUtils.FilterWrapper + private Reader getFileReader( String encoding, File from ) + throws FileNotFoundException, UnsupportedEncodingException { - - private LinkedHashSet delimiters; - - private MavenProject project; - - private ValueSource propertiesValueSource; - - private List projectStartExpressions; - - private String escapeString; - - private boolean escapeWindowsPaths; - - private final MavenSession mavenSession; - - private boolean supportMultiLineFiltering; - - Wrapper( LinkedHashSet delimiters, MavenProject project, MavenSession mavenSession, - ValueSource propertiesValueSource, List projectStartExpressions, String escapeString, - boolean escapeWindowsPaths, boolean supportMultiLineFiltering ) + // buffer so it isn't reading a byte at a time! + if ( StringUtils.isEmpty( encoding ) ) { - super(); - this.delimiters = delimiters; - this.project = project; - this.mavenSession = mavenSession; - this.propertiesValueSource = propertiesValueSource; - this.projectStartExpressions = projectStartExpressions; - this.escapeString = escapeString; - this.escapeWindowsPaths = escapeWindowsPaths; - this.supportMultiLineFiltering = supportMultiLineFiltering; + return new BufferedReader( new FileReader( from ) ); } - - public Reader getReader( Reader reader ) + else { - MultiDelimiterStringSearchInterpolator interpolator = new MultiDelimiterStringSearchInterpolator(); - interpolator.setDelimiterSpecs( delimiters ); - - RecursionInterceptor ri = null; - if ( projectStartExpressions != null && !projectStartExpressions.isEmpty() ) - { - ri = new PrefixAwareRecursionInterceptor( projectStartExpressions, true ); - } - else - { - ri = new SimpleRecursionInterceptor(); - } - - interpolator.addValueSource( propertiesValueSource ); - - if ( project != null ) - { - interpolator.addValueSource( new PrefixedObjectValueSource( projectStartExpressions, project, true ) ); - } - - if ( mavenSession != null ) - { - interpolator.addValueSource( new PrefixedObjectValueSource( "session", mavenSession ) ); - - final Settings settings = mavenSession.getSettings(); - if ( settings != null ) - { - interpolator.addValueSource( new PrefixedObjectValueSource( "settings", settings ) ); - interpolator.addValueSource( - new SingleResponseValueSource( "localRepository", settings.getLocalRepository() ) ); - } - } - - interpolator.setEscapeString( escapeString ); - - if ( escapeWindowsPaths ) - { - interpolator.addPostProcessor( new InterpolationPostProcessor() - { - public Object execute( String expression, Object value ) - { - if ( value instanceof String ) - { - return FilteringUtils.escapeWindowsPath( (String) value ); - } - - return value; - } - } ); - } - - MultiDelimiterInterpolatorFilterReaderLineEnding filterReader = - new MultiDelimiterInterpolatorFilterReaderLineEnding( reader, interpolator, supportMultiLineFiltering ); - filterReader.setRecursionInterceptor( ri ); - filterReader.setDelimiterSpecs( delimiters ); - - filterReader.setInterpolateWithPrefixPattern( false ); - filterReader.setEscapeString( escapeString ); - - return filterReader; + FileInputStream instream = new FileInputStream( from ); + return new BufferedReader( new InputStreamReader( instream, encoding ) ); } - } } diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilter.java 2015-11-05 06:23:46.000000000 +0000 @@ -0,0 +1,85 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.Reader; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper; +import org.codehaus.plexus.component.annotations.Component; + +/** + * @author Kristian Rosenvold + */ +@Component( role = org.apache.maven.shared.filtering.MavenReaderFilter.class, hint = "default" ) +public class DefaultMavenReaderFilter + extends BaseFilter + implements MavenReaderFilter +{ + /** {@inheritDoc} */ + @Nonnull + public Reader filter( @Nonnull Reader from, boolean filtering, MavenProject mavenProject, List filters, + boolean escapedBackslashesInFilePath, MavenSession mavenSession ) + throws MavenFilteringException + { + MavenResourcesExecution mre = new MavenResourcesExecution(); + mre.setMavenProject( mavenProject ); + mre.setFileFilters( filters ); + mre.setEscapeWindowsPaths( escapedBackslashesInFilePath ); + mre.setMavenSession( mavenSession ); + mre.setInjectProjectBuildFilters( true ); + + List filterWrappers = getDefaultFilterWrappers( mre ); + return filter( from, filtering, filterWrappers ); + } + + /** {@inheritDoc} */ + @Nonnull + public Reader filter( @Nonnull MavenReaderFilterRequest mavenFileFilterRequest ) + throws MavenFilteringException + { + List filterWrappers = getDefaultFilterWrappers( mavenFileFilterRequest ); + return filter( mavenFileFilterRequest.getFrom(), mavenFileFilterRequest.isFiltering(), filterWrappers ); + } + + /** {@inheritDoc} */ + @Nonnull + public Reader filter( @Nonnull Reader from, boolean filtering, @Nonnull List filterWrappers ) + { + return filterWrap( from, filtering ? filterWrappers : Collections.emptyList() ); + } + + @Nonnull + private static Reader filterWrap( @Nonnull Reader from, @Nonnull Iterable wrappers ) + { + Reader reader = from; + for ( FilterWrapper wrapper : wrappers ) + { + reader = wrapper.getReader( reader ); + } + return reader; + } + +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java 2012-07-07 09:22:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java 2016-05-30 20:24:49.000000000 +0000 @@ -19,53 +19,58 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import org.apache.maven.model.Resource; -import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.PathTool; +import org.apache.maven.shared.utils.ReaderFactory; +import org.apache.maven.shared.utils.StringUtils; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper; +import org.apache.maven.shared.utils.io.IOUtil; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.PathTool; -import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.Scanner; -import org.codehaus.plexus.util.StringUtils; import org.sonatype.plexus.build.incremental.BuildContext; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * @author Olivier Lamy - * @plexus.component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" - * role-hint="default" */ +@Component( role = MavenResourcesFiltering.class, hint = "default" ) public class DefaultMavenResourcesFiltering extends AbstractLogEnabled implements MavenResourcesFiltering, Initializable { - private static final String[] EMPTY_STRING_ARRAY = { }; + private static final String[] EMPTY_STRING_ARRAY = {}; private static final String[] DEFAULT_INCLUDES = { "**/**" }; private List defaultNonFilteredFileExtensions; - /** - * @plexus.requirement - */ + @Requirement private BuildContext buildContext; + @Requirement + private MavenFileFilter mavenFileFilter; + // ------------------------------------------------ - // Plexus lifecycle + // Plexus lifecycle // ------------------------------------------------ + /** {@inheritDoc} */ public void initialize() throws InitializationException { - // jpg,jpeg,gif,bmp,png this.defaultNonFilteredFileExtensions = new ArrayList( 5 ); this.defaultNonFilteredFileExtensions.add( "jpg" ); this.defaultNonFilteredFileExtensions.add( "jpeg" ); @@ -74,38 +79,7 @@ this.defaultNonFilteredFileExtensions.add( "png" ); } - - /** - * @plexus.requirement role-hint="default" - */ - private MavenFileFilter mavenFileFilter; - - public void filterResources( List resources, File outputDirectory, MavenProject mavenProject, - String encoding, List fileFilters, List nonFilteredFileExtensions, - MavenSession mavenSession ) - throws MavenFilteringException - { - MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( resources, outputDirectory, mavenProject, encoding, fileFilters, - nonFilteredFileExtensions, mavenSession ); - mavenResourcesExecution.setUseDefaultFilterWrappers( true ); -// mavenResourcesExecution.setEscapeWindowsPaths( false ); - - filterResources( mavenResourcesExecution ); - } - - public void filterResources( List resources, File outputDirectory, String encoding, - List filterWrappers, File resourcesBaseDirectory, - List nonFilteredFileExtensions ) - throws MavenFilteringException - { - MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( resources, outputDirectory, encoding, filterWrappers, resourcesBaseDirectory, - nonFilteredFileExtensions ); - filterResources( mavenResourcesExecution ); - } - - + /** {@inheritDoc} */ public boolean filteredFileExtension( String fileName, List userNonFilteredFileExtensions ) { List nonFilteredFileExtensions = new ArrayList( getDefaultNonFilteredFileExtensions() ); @@ -117,12 +91,13 @@ !nonFilteredFileExtensions.contains( StringUtils.lowerCase( FileUtils.extension( fileName ) ) ); if ( getLogger().isDebugEnabled() ) { - getLogger().debug( - "file " + fileName + " has a" + ( filteredFileExtension ? " " : " non " ) + "filtered file extension" ); + getLogger().debug( "file " + fileName + " has a" + ( filteredFileExtension ? " " : " non " ) + + "filtered file extension" ); } return filteredFileExtension; } + /** {@inheritDoc} */ public List getDefaultNonFilteredFileExtensions() { if ( this.defaultNonFilteredFileExtensions == null ) @@ -132,6 +107,7 @@ return this.defaultNonFilteredFileExtensions; } + /** {@inheritDoc} */ public void filterResources( MavenResourcesExecution mavenResourcesExecution ) throws MavenFilteringException { @@ -153,24 +129,18 @@ if ( mavenResourcesExecution.isUseDefaultFilterWrappers() ) { - List filterWrappers = new ArrayList(); - if ( mavenResourcesExecution.getFilterWrappers() != null ) - { - filterWrappers.addAll( mavenResourcesExecution.getFilterWrappers() ); - } - filterWrappers.addAll( mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution ) ); - mavenResourcesExecution.setFilterWrappers( filterWrappers ); + handleDefaultFilterWrappers( mavenResourcesExecution ); } if ( mavenResourcesExecution.getEncoding() == null || mavenResourcesExecution.getEncoding().length() < 1 ) { getLogger().warn( "Using platform encoding (" + ReaderFactory.FILE_ENCODING - + " actually) to copy filtered resources, i.e. build is platform dependent!" ); + + " actually) to copy filtered resources, i.e. build is platform dependent!" ); } else { - getLogger().info( - "Using '" + mavenResourcesExecution.getEncoding() + "' encoding to copy filtered resources." ); + getLogger().info( "Using '" + mavenResourcesExecution.getEncoding() + + "' encoding to copy filtered resources." ); } for ( Resource resource : mavenResourcesExecution.getResources() ) @@ -179,14 +149,17 @@ if ( getLogger().isDebugEnabled() ) { String ls = System.getProperty( "line.separator" ); - StringBuffer debugMessage = - new StringBuffer( "resource with targetPath " + resource.getTargetPath() ).append( ls ); - debugMessage.append( "directory " + resource.getDirectory() ).append( ls ); - debugMessage.append( "excludes " + ( resource.getExcludes() == null - ? " empty " - : resource.getExcludes().toString() ) ).append( ls ); - debugMessage.append( - "includes " + ( resource.getIncludes() == null ? " empty " : resource.getIncludes().toString() ) ); + StringBuilder debugMessage = + new StringBuilder( "resource with targetPath " ).append( resource.getTargetPath() ).append( ls ); + debugMessage.append( "directory " ).append( resource.getDirectory() ).append( ls ); + + // @formatter:off + debugMessage.append( "excludes " ).append( resource.getExcludes() == null ? " empty " + : resource.getExcludes().toString() ).append( ls ); + debugMessage.append( "includes " ).append( resource.getIncludes() == null ? " empty " + : resource.getIncludes().toString() ); + + // @formatter:on getLogger().debug( debugMessage.toString() ); } @@ -206,7 +179,8 @@ continue; } - // this part is required in case the user specified "../something" as destination + // this part is required in case the user specified "../something" + // as destination // see MNG-1345 File outputDirectory = mavenResourcesExecution.getOutputDirectory(); boolean outputExists = outputDirectory.exists(); @@ -220,7 +194,7 @@ getLogger().debug( "ignoreDelta " + ignoreDelta ); Scanner scanner = buildContext.newScanner( resourceDirectory, ignoreDelta ); - setupScanner( resource, scanner ); + setupScanner( resource, scanner, mavenResourcesExecution.isAddDefaultExcludes() ); scanner.scan(); @@ -234,26 +208,23 @@ } catch ( IOException e ) { - throw new MavenFilteringException( - "Cannot copy directory structure from " + resourceDirectory.getPath() + " to " - + outputDirectory.getPath() ); + throw new MavenFilteringException( "Cannot copy directory structure from " + + resourceDirectory.getPath() + " to " + outputDirectory.getPath() ); } } List includedFiles = Arrays.asList( scanner.getIncludedFiles() ); - getLogger().info( - "Copying " + includedFiles.size() + " resource" + ( includedFiles.size() > 1 ? "s" : "" ) + ( - targetPath == null ? "" : " to " + targetPath ) ); + getLogger().info( "Copying " + includedFiles.size() + " resource" + ( includedFiles.size() > 1 ? "s" : "" ) + + ( targetPath == null ? "" : " to " + targetPath ) ); for ( String name : includedFiles ) { + getLogger().debug( "Copying file " + name ); File source = new File( resourceDirectory, name ); - //File destinationFile = new File( outputDirectory, destination ); - - File destinationFile = getDestinationFile( outputDirectory, targetPath, name ); + File destinationFile = getDestinationFile( outputDirectory, targetPath, name, mavenResourcesExecution ); boolean filteredExt = filteredFileExtension( source.getName(), mavenResourcesExecution.getNonFilteredFileExtensions() ); @@ -268,7 +239,7 @@ scanner = buildContext.newDeleteScanner( resourceDirectory ); - setupScanner( resource, scanner ); + setupScanner( resource, scanner, mavenResourcesExecution.isAddDefaultExcludes() ); scanner.scan(); @@ -276,7 +247,7 @@ for ( String name : deletedFiles ) { - File destinationFile = getDestinationFile( outputDirectory, targetPath, name ); + File destinationFile = getDestinationFile( outputDirectory, targetPath, name, mavenResourcesExecution ); destinationFile.delete(); @@ -287,13 +258,32 @@ } - private File getDestinationFile( File outputDirectory, String targetPath, String name ) + private void handleDefaultFilterWrappers( MavenResourcesExecution mavenResourcesExecution ) + throws MavenFilteringException + { + List filterWrappers = new ArrayList(); + if ( mavenResourcesExecution.getFilterWrappers() != null ) + { + filterWrappers.addAll( mavenResourcesExecution.getFilterWrappers() ); + } + filterWrappers.addAll( mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution ) ); + mavenResourcesExecution.setFilterWrappers( filterWrappers ); + } + + private File getDestinationFile( File outputDirectory, String targetPath, String name, + MavenResourcesExecution mavenResourcesExecution ) + throws MavenFilteringException { String destination = name; + if ( mavenResourcesExecution.isFilterFilenames() && mavenResourcesExecution.getFilterWrappers().size() > 0 ) + { + destination = filterFileName( destination, mavenResourcesExecution.getFilterWrappers() ); + } + if ( targetPath != null ) { - destination = targetPath + "/" + name; + destination = targetPath + "/" + destination; } File destinationFile = new File( destination ); @@ -309,7 +299,7 @@ return destinationFile; } - private String[] setupScanner( Resource resource, Scanner scanner ) + private String[] setupScanner( Resource resource, Scanner scanner, boolean addDefaultExcludes ) { String[] includes = null; if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() ) @@ -329,7 +319,10 @@ scanner.setExcludes( excludes ); } - scanner.addDefaultExcludes(); + if ( addDefaultExcludes ) + { + scanner.addDefaultExcludes(); + } return includes; } @@ -393,4 +386,37 @@ return relOutDir; } + /* + * Filter the name of a file using the same mechanism for filtering the content of the file. + */ + private String filterFileName( String name, List wrappers ) + throws MavenFilteringException + { + + Reader reader = new StringReader( name ); + for ( FilterWrapper wrapper : wrappers ) + { + reader = wrapper.getReader( reader ); + } + + StringWriter writer = new StringWriter(); + + try + { + IOUtil.copy( reader, writer ); + } + catch ( IOException e ) + { + throw new MavenFilteringException( "Failed filtering filename" + name, e ); + } + + String filteredFilename = writer.toString(); + + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( "renaming filename " + name + " to " + filteredFilename ); + } + return filteredFilename; + } + } diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java 2014-10-17 19:18:55.000000000 +0000 @@ -20,18 +20,18 @@ */ import java.util.regex.Pattern; -import org.codehaus.plexus.util.StringUtils; + +import org.apache.maven.shared.utils.StringUtils; /** * @author Olivier Lamy * @author Dennis Lundberg - * */ public final class FilteringUtils { private static final String WINDOWS_PATH_PATTERN = "^(.*)[a-zA-Z]:\\\\(.*)"; - private static final Pattern PATTERN = Pattern.compile( WINDOWS_PATH_PATTERN ) ; + private static final Pattern PATTERN = Pattern.compile( WINDOWS_PATH_PATTERN ); /** * @@ -40,29 +40,33 @@ { // nothing just an util class } - + // TODO: Correct to handle relative windows paths. (http://jira.codehaus.org/browse/MSHARED-121) // How do we distinguish a relative windows path from some other value that happens to contain backslashes?? + /** + * @param val The value to be escaped. + * @return Escaped value + */ public static String escapeWindowsPath( String val ) { if ( !StringUtils.isEmpty( val ) && PATTERN.matcher( val ).matches() ) { // Adapted from StringUtils.replace in plexus-utils to accommodate pre-escaped backslashes. - StringBuffer buf = new StringBuffer( val.length() ); + StringBuilder buf = new StringBuilder( val.length() ); int start = 0, end = 0; while ( ( end = val.indexOf( '\\', start ) ) != -1 ) { buf.append( val.substring( start, end ) ).append( "\\\\" ); start = end + 1; - + if ( val.indexOf( '\\', end + 1 ) == end + 1 ) { start++; } } - + buf.append( val.substring( start ) ); - + return buf.toString(); } return val; diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEnding.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEnding.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEnding.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEnding.java 2016-05-21 11:53:12.000000000 +0000 @@ -19,27 +19,25 @@ * under the License. */ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; + import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.RecursionInterceptor; import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor; -import java.io.BufferedReader; -import java.io.FilterReader; -import java.io.IOException; -import java.io.Reader; - /** * A FilterReader implementation, that works with Interpolator interface instead of it's own interpolation * implementation. This implementation is heavily based on org.codehaus.plexus.util.InterpolationFilterReader. * * @author cstamas * @author Olivier Lamy - * * @since 1.0 */ public class InterpolatorFilterReaderLineEnding - extends FilterReader + extends AbstractFilterReaderLineEnding { /** @@ -78,29 +76,15 @@ */ private boolean interpolateWithPrefixPattern = true; - private String escapeString; - - private boolean useEscape = false; - - /** - * if true escapeString will be preserved \{foo} -> \{foo} - */ - private boolean preserveEscapeString = false; - private boolean supportMultiLineFiltering; - /** - * must always be bigger than escape string plus delimiters, but doesn't need to be exact - */ - private int markLength = 16; - private boolean eof = false; /** - * @param in reader to use - * @param interpolator interpolator instance to use - * @param beginToken start token to use - * @param endToken end token to use + * @param in reader to use + * @param interpolator interpolator instance to use + * @param beginToken start token to use + * @param endToken end token to use * @param supportMultiLineFiltering If multi line filtering is allowed */ public InterpolatorFilterReaderLineEnding( Reader in, Interpolator interpolator, String beginToken, String endToken, @@ -110,11 +94,11 @@ } /** - * @param in reader to use - * @param interpolator interpolator instance to use - * @param beginToken start token to use - * @param endToken end token to use - * @param ri The {@link RecursionInterceptor} to use to prevent recursive expressions. + * @param in reader to use + * @param interpolator interpolator instance to use + * @param beginToken start token to use + * @param endToken end token to use + * @param ri The {@link RecursionInterceptor} to use to prevent recursive expressions. * @param supportMultiLineFiltering If multi line filtering is allowed */ private InterpolatorFilterReaderLineEnding( Reader in, Interpolator interpolator, String beginToken, @@ -144,8 +128,7 @@ * * @param n The number of characters to skip * @return the number of characters actually skipped - * @throws IllegalArgumentException If n is negative. - * @throws IOException If an I/O error occurs + * @throws IOException If an I/O error occurs */ public long skip( long n ) throws IOException @@ -170,8 +153,8 @@ * occurs, or the end of the stream is reached. * * @param cbuf Destination buffer to write characters to. Must not be null. - * @param off Offset at which to start storing characters. - * @param len Maximum number of characters to read. + * @param off Offset at which to start storing characters. + * @param len Maximum number of characters to read. * @return the number of characters read, or -1 if the end of the stream has been reached * @throws IOException If an I/O error occurs */ @@ -218,23 +201,23 @@ in.mark( markLength ); int ch = in.read(); - if ( ( ch == -1 ) || ( ch == '\n' && !supportMultiLineFiltering ) ) + if ( ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) { return ch; } - boolean inEscape = ( useEscape && ch == escapeString.charAt( 0 ) ); + boolean inEscape = useEscape && ch == getEscapeString().charAt( 0 ); - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); // have we found an escape string? if ( inEscape ) { - for ( int i = 0; i < escapeString.length(); i++ ) + for ( int i = 0; i < getEscapeString().length(); i++ ) { key.append( (char) ch ); - if ( ch != escapeString.charAt( i ) || ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) + if ( ch != getEscapeString().charAt( i ) || ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) { // mismatch, EOF or EOL, no escape string here in.reset(); @@ -244,7 +227,6 @@ } ch = in.read(); - } } @@ -280,7 +262,7 @@ if ( beginToken != null ) { - if ( !preserveEscapeString ) + if ( !isPreserveEscapeString() ) { key.setLength( 0 ); } @@ -311,7 +293,8 @@ in.skip( beginToken.length() ); ch = in.read(); - int end = endToken.length(); + int endTokenSize = endToken.length(); + int end = endTokenSize; do { if ( ch == -1 ) @@ -327,7 +310,7 @@ key.append( (char) ch ); - if ( ch == this.endToken.charAt( end - 1 ) ) + if ( ch == this.endToken.charAt( endTokenSize - end ) ) { end--; if ( end == 0 ) @@ -337,7 +320,7 @@ } else { - end = endToken.length(); + end = endTokenSize; } ch = in.read(); @@ -388,72 +371,38 @@ } + /** + * @return current state of interpolate with prefix pattern. + */ public boolean isInterpolateWithPrefixPattern() { return interpolateWithPrefixPattern; } + /** + * @param interpolateWithPrefixPattern interpolate with prefix pattern. + */ public void setInterpolateWithPrefixPattern( boolean interpolateWithPrefixPattern ) { this.interpolateWithPrefixPattern = interpolateWithPrefixPattern; } - public String getEscapeString() - { - return escapeString; - } - - public void setEscapeString( String escapeString ) - { - // TODO NPE if escapeString is null ? - if ( escapeString != null && escapeString.length() >= 1 ) - { - this.escapeString = escapeString; - this.useEscape = escapeString != null && escapeString.length() >= 1; - calculateMarkLength(); - } - } - - public boolean isPreserveEscapeString() - { - return preserveEscapeString; - } - - public void setPreserveEscapeString( boolean preserveEscapeString ) - { - this.preserveEscapeString = preserveEscapeString; - } - + /** + * @return {@link #recursionInterceptor} + */ public RecursionInterceptor getRecursionInterceptor() { return recursionInterceptor; } - public InterpolatorFilterReaderLineEnding setRecursionInterceptor( RecursionInterceptor recursionInterceptor ) + /** + * @param theRecursionInterceptor {@link RecursionInterceptor} + * @return {@link InterpolatorFilterReaderLineEnding} + */ + public InterpolatorFilterReaderLineEnding setRecursionInterceptor( RecursionInterceptor theRecursionInterceptor ) { - this.recursionInterceptor = recursionInterceptor; + this.recursionInterceptor = theRecursionInterceptor; return this; } - private void calculateMarkLength() - { - markLength = 16; - - if ( escapeString != null ) - { - markLength += escapeString.length(); - } - - if ( beginToken != null ) - { - markLength += beginToken.length(); - } - - if ( endToken != null ) - { - markLength += endToken.length(); - } - - } - } diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilter.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilter.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilter.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilter.java 2015-10-31 21:45:30.000000000 +0000 @@ -19,113 +19,69 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; - import java.io.File; import java.util.List; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.io.FileUtils; + /** * @author Olivier Lamy - * */ public interface MavenFileFilter + extends DefaultFilterInfo { /** * Will copy a file with some filtering using defaultFilterWrappers. * - * @param from file to copy/filter - * @param to destination file - * @param filtering enable or not filering - * @param mavenProject the mavenproject - * @param filters {@link List} of String which are path to a Property file - * @throws MavenFilteringException + * @param from file to copy/filter + * @param to destination file + * @param filtering enable or not filtering + * @param mavenProject {@link MavenProject} + * @param mavenSession {@link MavenSession} + * @param escapedBackslashesInFilePath escape backslashes in file path. + * @param filters {@link List} of String which are path to a Property file + * @param encoding The encoding which is used during the filtering process. + * @throws MavenFilteringException in case of failure. * @see #getDefaultFilterWrappers(MavenProject, List, boolean, MavenSession) */ void copyFile( File from, final File to, boolean filtering, MavenProject mavenProject, List filters, boolean escapedBackslashesInFilePath, String encoding, MavenSession mavenSession ) - throws MavenFilteringException; + throws MavenFilteringException; /** - * @param mavenFileFilterRequest - * @throws MavenFilteringException + * @param mavenFileFilterRequest the request + * @throws MavenFilteringException in case of failure. * @since 1.0-beta-3 */ void copyFile( MavenFileFilterRequest mavenFileFilterRequest ) throws MavenFilteringException; /** - * @param from - * @param to - * @param filtering + * @param from The source file + * @param to The target file + * @param filtering true to apply filtering * @param filterWrappers {@link List} of FileUtils.FilterWrapper - * @throws MavenFilteringException + * @param encoding The encoding used during the filtering. + * @throws MavenFilteringException In case of an error. */ void copyFile( File from, final File to, boolean filtering, List filterWrappers, String encoding ) - throws MavenFilteringException; - + throws MavenFilteringException; /** - * @param from - * @param to - * @param filtering - * @param filterWrappers - * @param encoding - * @param overwrite - * @throws MavenFilteringException + * @param from The source file + * @param to The destination file + * @param filtering true to apply filtering + * @param filterWrappers The filters to be applied. + * @param encoding The encoding to use + * @param overwrite Overwrite to file ? + * @throws MavenFilteringException In case of an error. * @since 1.0-beta-2 */ void copyFile( File from, final File to, boolean filtering, List filterWrappers, String encoding, boolean overwrite ) - throws MavenFilteringException; - - /** - * Will return the default FileUtils.FilterWrappers. - *

- *

    - *
  • interpolate with token ${} and values from sysProps, project.properties, filters and project filters.
  • - *
  • interpolate with token @ @ and values from sysProps, project.properties, filters and project filters.
  • - *
  • interpolate with token ${} and values from mavenProject interpolation.
  • - *
  • interpolation with token @ @ and values from mavenProject interpolation
  • - *
- * This method is now deprecated and no escape mechanism will be used. - * - * @param mavenProject - * @param filters {@link List} of properties file - * @return {@link List} of FileUtils.FilterWrapper - * @deprecated use {@link #getDefaultFilterWrappers(MavenProject, List, boolean, MavenSession, MavenResourcesExecution)} - */ - List getDefaultFilterWrappers( MavenProject mavenProject, List filters, - boolean escapedBackslashesInFilePath, - MavenSession mavenSession ) - throws MavenFilteringException; - - /** - * @param mavenProject - * @param filters - * @param escapedBackslashesInFilePath - * @param mavenSession - * @param mavenResourcesExecution - * @return {@link List} of FileUtils.FilterWrapper - * @throws MavenFilteringException - * @since 1.0-beta-2 - */ - List getDefaultFilterWrappers( MavenProject mavenProject, List filters, - boolean escapedBackslashesInFilePath, - MavenSession mavenSession, - MavenResourcesExecution mavenResourcesExecution ) - throws MavenFilteringException; - - /** - * @param request - * @return {@link List} of FileUtils.FilterWrapper - * @throws MavenFilteringException - * @since 1.0-beta-3 - */ - List getDefaultFilterWrappers( AbstractMavenFilteringRequest request ) - throws MavenFilteringException; - + throws MavenFilteringException; } diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilterRequest.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilterRequest.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilterRequest.java 2012-07-05 09:16:43.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFileFilterRequest.java 2015-10-31 21:45:30.000000000 +0000 @@ -33,23 +33,40 @@ public class MavenFileFilterRequest extends AbstractMavenFilteringRequest { - + private File from; private File to; - + private boolean filtering; + private String encoding; + + /** + * The constructor. + */ public MavenFileFilterRequest() { // nothing } - public MavenFileFilterRequest( File from, File to, boolean filtering, MavenProject mavenProject, List filters, - boolean escapedBackslashesInFilePath, String encoding, MavenSession mavenSession, - Properties additionalProperties ) + /** + * @param from The request from where. + * @param to The request to where + * @param filtering Filtering yes {@code true} or no {@code false} + * @param mavenProject The Maven Project. + * @param filters The list of given filters. + * @param escapedBackslashesInFilePath Escape back slashes in file path. + * @param encoding The used encoding during the filtering. + * @param mavenSession The Maven Session. + * @param additionalProperties Supplemental properties. + */ + public MavenFileFilterRequest( File from, File to, boolean filtering, MavenProject mavenProject, + List filters, boolean escapedBackslashesInFilePath, String encoding, + MavenSession mavenSession, Properties additionalProperties ) { - super( mavenProject, filters, encoding, mavenSession ); + super( mavenProject, filters, mavenSession ); + this.encoding = encoding; this.from = from; this.to = to; this.filtering = filtering; @@ -57,32 +74,69 @@ setEscapeWindowsPaths( escapedBackslashesInFilePath ); } + /** + * Return the encoding. + * + * @return Current encoding. + */ + public String getEncoding() + { + return encoding; + } + + /** + * Set the value for encoding. + * + * @param encoding Give the new value for encoding. + */ + public void setEncoding( String encoding ) + { + this.encoding = encoding; + } + /** + * @return to filter from. + */ public File getFrom() { return from; } + /** + * @param from set filter from. + */ public void setFrom( File from ) { this.from = from; } + /** + * @return The filter to + */ public File getTo() { return to; } + /** + * @param to Set the target. + */ public void setTo( File to ) { this.to = to; } + /** + * @return if we are filtering yes {@code true} no {@code false} + */ public boolean isFiltering() { return filtering; } + /** + * @param filtering set filtering yes / no. + */ public void setFiltering( boolean filtering ) { this.filtering = filtering; diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFilteringException.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFilteringException.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenFilteringException.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenFilteringException.java 2015-11-06 20:28:40.000000000 +0000 @@ -21,7 +21,6 @@ /** * @author Olivier Lamy - * */ public class MavenFilteringException extends Exception @@ -30,13 +29,18 @@ /** * */ + private static final long serialVersionUID = 1L; + + /** + * + */ public MavenFilteringException() { // nothing } /** - * @param message + * @param message the message */ public MavenFilteringException( String message ) { @@ -44,7 +48,7 @@ } /** - * @param cause + * @param cause the cause of the exception */ public MavenFilteringException( Throwable cause ) { @@ -52,8 +56,8 @@ } /** - * @param message - * @param cause + * @param message a message + * @param cause a worthy cause */ public MavenFilteringException( String message, Throwable cause ) { diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilter.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilter.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilter.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilter.java 2015-11-06 20:28:40.000000000 +0000 @@ -0,0 +1,81 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.Reader; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.io.FileUtils; + +/** + * @author Olivier Lamy + * @author Kristian Rosenvold + * @since 1.3 + */ +public interface MavenReaderFilter + extends DefaultFilterInfo +{ + /** + * Provides a new reader that applies filtering using defaultFilterWrappers. + * + * @param from the source reader + * @param filtering enable or not filtering + * @param mavenProject {@link MavenProject} + * @param mavenSession {@link MavenSession} + * @param filters {@link java.util.List} of String which are path to a Property file + * @param escapedBackslashesInFilePath escape backslashes in file path. + * @return an input stream that applies the filter + * @throws org.apache.maven.shared.filtering.MavenFilteringException in case of failure. + * @see #getDefaultFilterWrappers(org.apache.maven.project.MavenProject, java.util.List, boolean, + * org.apache.maven.execution.MavenSession) + */ + @Nonnull + Reader filter( @Nonnull Reader from, boolean filtering, @Nullable MavenProject mavenProject, List filters, + boolean escapedBackslashesInFilePath, MavenSession mavenSession ) + throws MavenFilteringException; + + /** + * Provides a new reader that applies filtering using defaultFilterWrappers. + * + * @param mavenFileFilterRequest The filter request + * @throws org.apache.maven.shared.filtering.MavenFilteringException in case of failure. + * @return an input stream that applies the filter + * @since 1.0-beta-3 + */ + @Nonnull + Reader filter( @Nonnull MavenReaderFilterRequest mavenFileFilterRequest ) + throws MavenFilteringException; + + /** + * Provides a new reader that applies filtering using defaultFilterWrappers. + * + * @param from the source reader + * @param filtering true to apply filtering + * @param filterWrappers {@link java.util.List} of FileUtils.FilterWrapper + * @return an input stream that applies the filter + */ + @Nonnull + Reader filter( @Nonnull Reader from, boolean filtering, @Nonnull List filterWrappers ); +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilterRequest.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilterRequest.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilterRequest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenReaderFilterRequest.java 2015-11-06 20:28:40.000000000 +0000 @@ -0,0 +1,102 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.Reader; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; + +/** + * @author Olivier Lamy + * @author Kristian Rosenvold + * @since 1.0-beta-3 + */ +public class MavenReaderFilterRequest + extends AbstractMavenFilteringRequest +{ + + private Reader from; + + private boolean filtering; + + /** + * Default constructor. + */ + public MavenReaderFilterRequest() + { + // nothing + } + + /** + * @param from To read from + * @param filtering filter yes/no + * @param mavenProject The Maven Project. + * @param filters The list of filters which will be used. + * @param escapedBackslashesInFilePath escape backslashes in file paths. + * @param mavenSession The Maven Session. + * @param additionalProperties supplemental properties. + */ + public MavenReaderFilterRequest( Reader from, boolean filtering, MavenProject mavenProject, List filters, + boolean escapedBackslashesInFilePath, MavenSession mavenSession, + Properties additionalProperties ) + { + super( mavenProject, filters, mavenSession ); + this.from = from; + this.filtering = filtering; + setAdditionalProperties( additionalProperties ); + setEscapeWindowsPaths( escapedBackslashesInFilePath ); + } + + /** + * @return where we read from. + */ + public Reader getFrom() + { + return from; + } + + /** + * @param from set where to read from. + */ + public void setFrom( Reader from ) + { + this.from = from; + } + + /** + * @return is filtering active ({@code true}) false otherwise. + */ + public boolean isFiltering() + { + return filtering; + } + + /** + * @param filtering turn filtering on {@code true}) or off ({@code false}). + */ + public void setFiltering( boolean filtering ) + { + this.filtering = filtering; + } + +} diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java 2016-05-16 11:52:48.000000000 +0000 @@ -19,26 +19,23 @@ * under the License. */ +import java.io.File; +import java.io.Reader; +import java.util.ArrayList; +import java.util.List; + import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Resource; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.interpolation.Interpolator; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper; import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.interpolation.ValueSource; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.FileUtils.FilterWrapper; - -import java.io.File; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; /** * A bean to configure a resources filtering execution. * * @author Olivier Lamy - * */ public class MavenResourcesExecution extends AbstractMavenFilteringRequest @@ -56,9 +53,41 @@ private boolean useDefaultFilterWrappers = false; + private boolean filterFilenames = false; + + private String encoding; + /** - * Overwrite existing files even if the destination files are newer. - * false by default. + * By default files like {@code .gitignore}, {@code .cvsignore} etc. are excluded which means they will not being + * copied. If you need them for a particular reason you can do that by settings this to {@code false}. This means + * all files like the following will be copied. + *
    + *
  • Misc: **/*~, **/#*#, **/.#*, **/%*%, **/._*
  • + *
  • CVS: **/CVS, **/CVS/**, **/.cvsignore
  • + *
  • RCS: **/RCS, **/RCS/**
  • + *
  • SCCS: **/SCCS, **/SCCS/**
  • + *
  • VSSercer: **/vssver.scc
  • + *
  • MKS: **/project.pj
  • + *
  • SVN: **/.svn, **/.svn/**
  • + *
  • GNU: **/.arch-ids, **/.arch-ids/**
  • + *
  • Bazaar: **/.bzr, **/.bzr/**
  • + *
  • SurroundSCM: **/.MySCMServerInfo
  • + *
  • Mac: **/.DS_Store
  • + *
  • Serena Dimension: **/.metadata, **/.metadata/**
  • + *
  • Mercurial: **/.hg, **/.hg/**, **/.hgignore,
  • + *
  • GIT: **/.git, **/.gitignore, **/.gitattributes, **/.git/**
  • + *
  • Bitkeeper: **/BitKeeper, **/BitKeeper/**, **/ChangeSet, + * **/ChangeSet/**
  • + *
  • Darcs: **/_darcs, **/_darcs/**, **/.darcsrepo, + * **/.darcsrepo/****/-darcs-backup*, **/.darcs-temp-mail + *
+ * + * @since 3.1.0 + */ + private boolean addDefaultExcludes = true; + + /** + * Overwrite existing files even if the destination files are newer. false by default. * * @since 1.0-beta-2 */ @@ -78,34 +107,48 @@ */ private boolean supportMultiLineFiltering; + /** + * Do nothing. + */ public MavenResourcesExecution() { // no op } /** - * As we use a Maven project useDefaultFilterWrappers will be set to true. + * As we use a Maven project useDefaultFilterWrappers will be set to true. The + * {@code useDefaultExcludes} is set to {@code true}. * - * @param resources - * @param outputDirectory - * @param mavenProject - * @param encoding - * @param fileFilters - * @param nonFilteredFileExtensions - * @param mavenSession + * @param resources The list of resources. + * @param outputDirectory The output directory. + * @param mavenProject The maven project. + * @param encoding The given encoding. + * @param fileFilters The file filters. + * @param nonFilteredFileExtensions The extensions which should not being filtered. + * @param mavenSession The maven session. */ public MavenResourcesExecution( List resources, File outputDirectory, MavenProject mavenProject, - String encoding, List fileFilters, List nonFilteredFileExtensions, + String encoding, List fileFilters, List nonFilteredFileExtensions, MavenSession mavenSession ) { - super( mavenProject, fileFilters, encoding, mavenSession ); + super( mavenProject, fileFilters, mavenSession ); + this.encoding = encoding; this.resources = resources; this.outputDirectory = outputDirectory; this.nonFilteredFileExtensions = nonFilteredFileExtensions; this.useDefaultFilterWrappers = true; + this.addDefaultExcludes = true; this.resourcesBaseDirectory = mavenProject.getBasedir(); } + /** + * @param resources The list of resources. + * @param outputDirectory The output directory. + * @param encoding The given encoding. + * @param filterWrappers The list of filter wrappers. + * @param resourcesBaseDirectory The resources base directory. + * @param nonFilteredFileExtensions The list of extensions which should not being filtered. + */ public MavenResourcesExecution( List resources, File outputDirectory, String encoding, List filterWrappers, File resourcesBaseDirectory, List nonFilteredFileExtensions ) @@ -120,6 +163,25 @@ setEncoding( encoding ); } + /** + * Return the encoding. + * + * @return Current encoding. + */ + public String getEncoding() + { + return encoding; + } + + /** + * Set the value for encoding. + * + * @param encoding Give the new value for encoding. + */ + public void setEncoding( String encoding ) + { + this.encoding = encoding; + } /** * @return List of {@link org.apache.maven.model.Resource} @@ -137,18 +199,24 @@ this.resources = resources; } + /** + * @return The output directory. + */ public File getOutputDirectory() { return outputDirectory; } + /** + * @param outputDirectory The output directory. + */ public void setOutputDirectory( File outputDirectory ) { this.outputDirectory = outputDirectory; } /** - * @return List of {@link String} file extensions to not filter + * @return List of {@link String} file extensions not to filter */ public List getNonFilteredFileExtensions() { @@ -179,6 +247,9 @@ this.filterWrappers = filterWrappers; } + /** + * @param filterWrapper The filter wrapper which should be added. + */ public void addFilterWrapper( FilterWrapper filterWrapper ) { if ( this.filterWrappers == null ) @@ -189,87 +260,15 @@ } /** - * Helper to add {@link FileUtils.FilterWrapper}, will {@link RegexBasedInterpolator} with default regex Exp ${ } - * and InterpolatorFilterReaderLineEnding with defaultTokens ${ }. - * - * @param valueSource - * @deprecated This doesn't support escaping use {@link #addFilerWrapperWithEscaping(ValueSource, String, String, String, boolean)} - */ - public void addFilerWrapper( final ValueSource valueSource ) - { - addFilterWrapper( new FileUtils.FilterWrapper() - { - public Reader getReader( Reader reader ) - { - Interpolator propertiesInterpolator = new RegexBasedInterpolator(); - propertiesInterpolator.addValueSource( valueSource ); - return new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, - InterpolatorFilterReaderLineEnding.DEFAULT_BEGIN_TOKEN, - InterpolatorFilterReaderLineEnding.DEFAULT_END_TOKEN, - false ); - } - } ); - } - - /** - * @param valueSource - * @param startRegExp - * @param endRegExp - * @param startToken - * @param endToken - * @deprecated This doesn't support escaping use {@link #addFilerWrapperWithEscaping(ValueSource, String, String, String, boolean)} - */ - public void addFilerWrapper( final ValueSource valueSource, final String startRegExp, final String endRegExp, - final String startToken, final String endToken ) - { - addFilterWrapper( new FileUtils.FilterWrapper() - { - public Reader getReader( Reader reader ) - { - Interpolator propertiesInterpolator = new RegexBasedInterpolator( startRegExp, endRegExp ); - propertiesInterpolator.addValueSource( valueSource ); - return new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, startToken, endToken, - false ); - } - } ); - } - - /** - * @param valueSource - * @param startExp start token like ${ - * @param endExp endToken } - * @param escapeString - * @since 1.0-beta-2 - * @deprecated This doesn't support escaping use {@link #addFilerWrapperWithEscaping(ValueSource, String, String, String, boolean)} - */ - public void addFilerWrapperWithEscaping( final ValueSource valueSource, final String startExp, final String endExp, - final String escapeString ) - { - addFilterWrapper( new FileUtils.FilterWrapper() - { - public Reader getReader( Reader reader ) - { - StringSearchInterpolator propertiesInterpolator = new StringSearchInterpolator( startExp, endExp ); - propertiesInterpolator.addValueSource( valueSource ); - propertiesInterpolator.setEscapeString( escapeString ); - InterpolatorFilterReaderLineEnding interpolatorFilterReader = - new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, startExp, endExp, false ); - interpolatorFilterReader.setInterpolateWithPrefixPattern( false ); - return interpolatorFilterReader; - } - } ); - } - - /** - * @param valueSource - * @param startExp start token like ${ - * @param endExp endToken } - * @param escapeString - * @param supportMultiLineFiltering do we support or use filtering on multi lines with start and endtoken on multi lines + * @param valueSource {@link ValueSource} + * @param startExp start token like ${ + * @param endExp endToken } + * @param escapeString The escape string. + * @param multiLineFiltering do we support or use filtering on multi lines with start and endtoken on multi lines * @since 1.0 */ public void addFilerWrapperWithEscaping( final ValueSource valueSource, final String startExp, final String endExp, - final String escapeString, final boolean supportMultiLineFiltering ) + final String escapeString, final boolean multiLineFiltering ) { addFilterWrapper( new FileUtils.FilterWrapper() { @@ -280,37 +279,65 @@ propertiesInterpolator.setEscapeString( escapeString ); InterpolatorFilterReaderLineEnding interpolatorFilterReader = new InterpolatorFilterReaderLineEnding( reader, propertiesInterpolator, startExp, endExp, - supportMultiLineFiltering ); + multiLineFiltering ); interpolatorFilterReader.setInterpolateWithPrefixPattern( false ); return interpolatorFilterReader; } } ); } - + /** + * @return The resource base directory. + */ public File getResourcesBaseDirectory() { return resourcesBaseDirectory; } + /** + * @param resourcesBaseDirectory Set the resource base directory. + */ public void setResourcesBaseDirectory( File resourcesBaseDirectory ) { this.resourcesBaseDirectory = resourcesBaseDirectory; } + /** + * @return use default filter wrapper + */ public boolean isUseDefaultFilterWrappers() { return useDefaultFilterWrappers; } + /** + * @param useDefaultFilterWrappers {@link #useDefaultFilterWrappers} + */ public void setUseDefaultFilterWrappers( boolean useDefaultFilterWrappers ) { this.useDefaultFilterWrappers = useDefaultFilterWrappers; } /** + * @return add the default excludes. + */ + public boolean isAddDefaultExcludes() + { + return addDefaultExcludes; + } + + /** + * @param addDefaultExcludes {@link #addDefaultExcludes} + */ + public void setAddDefaultExcludes( boolean addDefaultExcludes ) + { + this.addDefaultExcludes = addDefaultExcludes; + } + + /** * Overwrite existing files even if the destination files are newer. * + * @return {@link #overwrite} * @since 1.0-beta-2 */ public boolean isOverwrite() @@ -321,7 +348,7 @@ /** * Overwrite existing files even if the destination files are newer. * - * @param overwrite + * @param overwrite overwrite true or false. * @since 1.0-beta-2 */ public void setOverwrite( boolean overwrite ) @@ -332,6 +359,7 @@ /** * Copy any empty directories included in the Resources. * + * @return {@link #includeEmptyDirs} * @since 1.0-beta-2 */ public boolean isIncludeEmptyDirs() @@ -342,7 +370,7 @@ /** * Copy any empty directories included in the Resources. * - * @param includeEmptyDirs + * @param includeEmptyDirs {@code true} to include empty directories, otherwise {@code false}. * @since 1.0-beta-2 */ public void setIncludeEmptyDirs( boolean includeEmptyDirs ) @@ -350,6 +378,27 @@ this.includeEmptyDirs = includeEmptyDirs; } + /** + * @return {@code true} if filenames are filtered, otherwise {@code false} + * @since 1.2 + */ + public boolean isFilterFilenames() + { + return filterFilenames; + } + + /** + * @param filterFilenames {@code true} if filenames should be filtered, otherwise {@code false} + * @since 1.2 + */ + public void setFilterFilenames( boolean filterFilenames ) + { + this.filterFilenames = filterFilenames; + } + + /** + * @return {@link MavenResourcesExecution} + */ public MavenResourcesExecution copyOf() { MavenResourcesExecution mre = new MavenResourcesExecution(); @@ -370,11 +419,12 @@ mre.setResources( copyList( mre.getResources() ) ); mre.setResourcesBaseDirectory( mre.getResourcesBaseDirectory() ); mre.setUseDefaultFilterWrappers( mre.isUseDefaultFilterWrappers() ); + mre.setAddDefaultExcludes( mre.isAddDefaultExcludes() ); mre.setSupportMultiLineFiltering( mre.isSupportMultiLineFiltering() ); return mre; } - private List copyList( List lst ) + private List copyList( List lst ) { if ( lst == null ) { @@ -382,19 +432,21 @@ } else if ( lst.isEmpty() ) { - return new ArrayList(); + return new ArrayList(); } else { - return new ArrayList( lst ); + return new ArrayList( lst ); } } + /** {@inheritDoc} */ public boolean isSupportMultiLineFiltering() { return supportMultiLineFiltering; } + /** {@inheritDoc} */ public void setSupportMultiLineFiltering( boolean supportMultiLineFiltering ) { this.supportMultiLineFiltering = supportMultiLineFiltering; diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesFiltering.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesFiltering.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesFiltering.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MavenResourcesFiltering.java 2015-11-06 20:28:40.000000000 +0000 @@ -19,69 +19,32 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Resource; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; - -import java.io.File; import java.util.List; /** * @author Olivier Lamy - * */ public interface MavenResourcesFiltering { /** - * @param resources {@link List} of {@link org.apache.maven.model.Resource} - * @param outputDirectory parent destination directory - * @param mavenProject the maven project - * @param encoding encoding to use for writing files - * @param fileFilters {@link List} of String which are path to a Property file - * @param nonFilteredFileExtensions {@link List} of String for non filtered file extensions - * @param mavenSession Can include executionProperties that will be used for filtering - * @throws MavenFilteringException - * @deprecated use {@link #filterResources(MavenResourcesExecution)} - */ - void filterResources( List resources, File outputDirectory, MavenProject mavenProject, String encoding, - List fileFilters, List nonFilteredFileExtensions, MavenSession mavenSession ) - throws MavenFilteringException; - - /** - * @param resources {@link List} of {@link org.apache.maven.model.Resource} - * @param outputDirectory parent destination directory - * @param encoding encoding to use for writing files - * @param filterWrappers {@link List} of FileUtils.FilterWrapper - * @param resourcesBaseDirectory baseDirectory of resources - * @param nonFilteredFileExtensions {@link List} of String for non filtered file extensions - * @throws MavenFilteringException - * @deprecated use {@link #filterResources(MavenResourcesExecution)} - */ - void filterResources( List resources, File outputDirectory, String encoding, - List filterWrappers, File resourcesBaseDirectory, - List nonFilteredFileExtensions ) - throws MavenFilteringException; - - /** * return the List of the non filtered extensions (jpg,jpeg,gif,bmp,png) * * @return {@link List} of {@link String} */ - List getDefaultNonFilteredFileExtensions(); + List getDefaultNonFilteredFileExtensions(); /** - * @param fileName the file name + * @param fileName the file name * @param userNonFilteredFileExtensions an extra list of file extensions - * @return true if filtering can be applied to the file (means extensions.lowerCase is in the - * default List or in the user defined extension List) + * @return true if filtering can be applied to the file (means extensions.lowerCase is in the default List or in the + * user defined extension List) */ boolean filteredFileExtension( String fileName, List userNonFilteredFileExtensions ); /** * @param mavenResourcesExecution {@link MavenResourcesExecution} - * @throws MavenFilteringException + * @throws MavenFilteringException in case of failure. */ void filterResources( MavenResourcesExecution mavenResourcesExecution ) throws MavenFilteringException; diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEnding.java 2016-05-16 11:55:33.000000000 +0000 @@ -19,31 +19,27 @@ * under the License. */ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.util.Set; + import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.RecursionInterceptor; import org.codehaus.plexus.interpolation.SimpleRecursionInterceptor; import org.codehaus.plexus.interpolation.multi.DelimiterSpecification; -import java.io.BufferedReader; -import java.io.FilterReader; -import java.io.IOException; -import java.io.Reader; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; - /** * A FilterReader implementation, that works with Interpolator interface instead of it's own interpolation * implementation. This implementation is heavily based on org.codehaus.plexus.util.InterpolationFilterReader. * * @author cstamas * @author Olivier Lamy - * * @since 1.0 */ public class MultiDelimiterInterpolatorFilterReaderLineEnding - extends FilterReader + extends AbstractFilterReaderLineEnding { /** @@ -78,35 +74,21 @@ */ private boolean interpolateWithPrefixPattern = true; - private String escapeString; - - private boolean useEscape = false; - - /** - * if true escapeString will be preserved \{foo} -> \{foo} - */ - private boolean preserveEscapeString = false; - - private LinkedHashSet delimiters = new LinkedHashSet(); - private String beginToken; private String endToken; private boolean supportMultiLineFiltering; - /** - * must always be bigger than escape string plus delimiters, but doesn't need to be exact - */ - private int markLength = 16; + private static final int MAXIMUM_BUFFER_SIZE = 8192; private boolean eof = false; /** * This constructor uses default begin token ${ and default end token }. * - * @param in reader to use - * @param interpolator interpolator instance to use + * @param in reader to use + * @param interpolator interpolator instance to use * @param supportMultiLineFiltering If multi line filtering is allowed */ public MultiDelimiterInterpolatorFilterReaderLineEnding( Reader in, Interpolator interpolator, @@ -116,9 +98,9 @@ } /** - * @param in reader to use - * @param interpolator interpolator instance to use - * @param ri The {@link RecursionInterceptor} to use to prevent recursive expressions. + * @param in reader to use + * @param interpolator interpolator instance to use + * @param ri The {@link RecursionInterceptor} to use to prevent recursive expressions. * @param supportMultiLineFiltering If multi line filtering is allowed */ public MultiDelimiterInterpolatorFilterReaderLineEnding( Reader in, Interpolator interpolator, @@ -126,7 +108,7 @@ boolean supportMultiLineFiltering ) { // wrap our own buffer, so we can use mark/reset safely. - super( new BufferedReader( in ) ); + super( new BufferedReader( in, MAXIMUM_BUFFER_SIZE ) ); this.interpolator = interpolator; @@ -143,18 +125,24 @@ } - + /** + * @param delimiterSpec delimiter spec. + * @return true/false. + */ public boolean removeDelimiterSpec( String delimiterSpec ) { return delimiters.remove( DelimiterSpecification.parse( delimiterSpec ) ); } - public MultiDelimiterInterpolatorFilterReaderLineEnding setDelimiterSpecs( HashSet specs ) + /** + * @param specs set of specs. + * @return {@link MultiDelimiterInterpolatorFilterReaderLineEnding} + */ + public AbstractFilterReaderLineEnding setDelimiterSpecs( Set specs ) { delimiters.clear(); - for ( Iterator it = specs.iterator(); it.hasNext(); ) + for ( String spec : specs ) { - String spec = (String) it.next(); delimiters.add( DelimiterSpecification.parse( spec ) ); markLength += spec.length() * 2; } @@ -167,12 +155,12 @@ * the stream is reached. * * @param n The number of characters to skip - * @return the number of characters actually skipped * @throws IllegalArgumentException If n is negative. - * @throws IOException If an I/O error occurs + * @throws IOException If an I/O error occurs + * @return the number of characters actually skipped */ public long skip( long n ) - throws IOException + throws IOException, IllegalArgumentException { if ( n < 0L ) { @@ -194,8 +182,8 @@ * occurs, or the end of the stream is reached. * * @param cbuf Destination buffer to write characters to. Must not be null. - * @param off Offset at which to start storing characters. - * @param len Maximum number of characters to read. + * @param off Offset at which to start storing characters. + * @param len Maximum number of characters to read. * @return the number of characters read, or -1 if the end of the stream has been reached * @throws IOException If an I/O error occurs */ @@ -239,26 +227,26 @@ return -1; } - in.mark( markLength ); + BoundedReader in = new BoundedReader( this.in, markLength ); int ch = in.read(); - if ( ( ch == -1 ) || ( ch == '\n' && !supportMultiLineFiltering ) ) + if ( ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) { return ch; } - boolean inEscape = ( useEscape && ch == escapeString.charAt( 0 ) ); + boolean inEscape = useEscape && ch == getEscapeString().charAt( 0 ); - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); // have we found an escape string? if ( inEscape ) { - for ( int i = 0; i < escapeString.length(); i++ ) + for ( int i = 0; i < getEscapeString().length(); i++ ) { key.append( (char) ch ); - if ( ch != escapeString.charAt( i ) || ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) + if ( ch != getEscapeString().charAt( i ) || ch == -1 || ( ch == '\n' && !supportMultiLineFiltering ) ) { // mismatch, EOF or EOL, no escape string here in.reset(); @@ -275,9 +263,8 @@ // have we found a delimiter? int max = 0; - for ( Iterator it = delimiters.iterator(); it.hasNext(); ) + for ( DelimiterSpecification spec : delimiters ) { - DelimiterSpecification spec = (DelimiterSpecification) it.next(); String begin = spec.getBegin(); // longest match wins @@ -318,7 +305,7 @@ if ( beginToken != null ) { - if ( !preserveEscapeString ) + if ( !isPreserveEscapeString() ) { key.setLength( 0 ); } @@ -352,7 +339,8 @@ in.skip( beginToken.length() ); ch = in.read(); - int end = endToken.length(); + int endTokenSize = endToken.length(); + int end = endTokenSize; do { if ( ch == -1 ) @@ -368,7 +356,7 @@ key.append( (char) ch ); - if ( ch == this.endToken.charAt( end - 1 ) ) + if ( ch == this.endToken.charAt( endTokenSize - end ) ) { end--; if ( end == 0 ) @@ -378,7 +366,7 @@ } else { - end = endToken.length(); + end = endTokenSize; } ch = in.read(); @@ -412,6 +400,12 @@ throw error; } } + else + { + // no endtoken? Write current char and continue in search for next expression + in.reset(); + return in.read(); + } // write away the value if present, otherwise the key unmodified if ( value != null ) @@ -433,72 +427,40 @@ } + /** + * @return interpolate with prefix pattern {@code true} (active) {@code false} otherwise. + */ public boolean isInterpolateWithPrefixPattern() { return interpolateWithPrefixPattern; } + /** + * @param interpolateWithPrefixPattern set the interpolate with prefix pattern. + */ public void setInterpolateWithPrefixPattern( boolean interpolateWithPrefixPattern ) { this.interpolateWithPrefixPattern = interpolateWithPrefixPattern; } - public String getEscapeString() - { - return escapeString; - } - - public void setEscapeString( String escapeString ) - { - // TODO NPE if escapeString is null ? - if ( escapeString != null && escapeString.length() >= 1 ) - { - this.escapeString = escapeString; - this.useEscape = escapeString != null && escapeString.length() >= 1; - calculateMarkLength(); - } - } - - public boolean isPreserveEscapeString() - { - return preserveEscapeString; - } - - public void setPreserveEscapeString( boolean preserveEscapeString ) - { - this.preserveEscapeString = preserveEscapeString; - } - + /** + * @return {@link RecursionInterceptor} + */ public RecursionInterceptor getRecursionInterceptor() { return recursionInterceptor; } - public MultiDelimiterInterpolatorFilterReaderLineEnding setRecursionInterceptor( - RecursionInterceptor recursionInterceptor ) + /** + * @param givenRecursionInterceptor {@link RecursionInterceptor} + * @return this + */ + // CHECKSTYLE_OFF: LineLength + public AbstractFilterReaderLineEnding setRecursionInterceptor( RecursionInterceptor givenRecursionInterceptor ) + // CHECKSTYLE_ON: LineLength { - this.recursionInterceptor = recursionInterceptor; + this.recursionInterceptor = givenRecursionInterceptor; return this; } - private void calculateMarkLength() - { - markLength = 16; - - if ( escapeString != null ) - { - - markLength += escapeString.length(); - - } - for ( Iterator it = delimiters.iterator(); it.hasNext(); ) - { - - DelimiterSpecification spec = (DelimiterSpecification) it.next(); - markLength += spec.getBegin().length(); - markLength += spec.getEnd().length(); - - } - } - } diff -Nru maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java --- maven-filtering-1.1/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java 2012-07-05 09:21:21.000000000 +0000 +++ maven-filtering-3.1.1/src/main/java/org/apache/maven/shared/filtering/PropertyUtils.java 2014-10-17 20:14:16.000000000 +0000 @@ -19,21 +19,18 @@ * under the License. */ -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.Iterator; import java.util.Properties; +import org.apache.maven.shared.utils.StringUtils; +import org.apache.maven.shared.utils.io.IOUtil; /** * @author Kenney Westerhof * @author William Ferguson - * */ public final class PropertyUtils { @@ -48,8 +45,8 @@ /** * Reads a property file, resolving all internal variables, using the supplied base properties. *

- * The properties are resolved iteratively, so if the value of property A refers to property B, - * then after resolution the value of property B will contain the value of property B. + * The properties are resolved iteratively, so if the value of property A refers to property B, then after + * resolution the value of property B will contain the value of property B. *

* * @param propFile The property file to load. @@ -83,15 +80,15 @@ // The algorithm iterates only over the fileProps which is all that is required to resolve // the properties defined within the file. This is slightly different to current, however // I suspect that this was the actual original intent. - // + // // The difference is that #loadPropertyFile(File, boolean, boolean) also resolves System properties // whose values contain expressions. I believe this is unexpected and is not validated by the test cases, // as can be verified by replacing the implementation of #loadPropertyFile(File, boolean, boolean) // with the commented variant I have provided that reuses this method. - for ( Iterator iter = fileProps.keySet().iterator(); iter.hasNext(); ) + for ( Object o : fileProps.keySet() ) { - final String k = (String) iter.next(); + final String k = (String) o; final String propValue = getPropertyValue( k, combinedProps ); fileProps.setProperty( k, propValue ); } @@ -111,7 +108,7 @@ public static Properties loadPropertyFile( File propfile, boolean fail, boolean useSystemProps ) throws IOException { - + final Properties baseProps = new Properties(); if ( useSystemProps ) @@ -140,16 +137,10 @@ return resolvedProps; } - /** - * Retrieves a property value, replacing values like ${token} - * using the Properties to look them up. - * - * It will leave unresolved properties alone, trying for System - * properties, and implements reparsing (in the case that - * the value of a property contains a key), and will - * not loop endlessly on a pair like - * test = ${test}. + * Retrieves a property value, replacing values like ${token} using the Properties to look them up. It will leave + * unresolved properties alone, trying for System properties, and implements reparsing (in the case that the value + * of a property contains a key), and will not loop endlessly on a pair like test = ${test}. * * @param k * @param p @@ -174,7 +165,8 @@ v = v.substring( idx + 2 ); // if no matching } then bail - if ( ( idx2 = v.indexOf( '}' ) ) < 0 ) + idx2 = v.indexOf( '}' ); + if ( idx2 < 0 ) { break; } diff -Nru maven-filtering-1.1/src/site/apt/index.apt maven-filtering-3.1.1/src/site/apt/index.apt --- maven-filtering-1.1/src/site/apt/index.apt 2011-01-05 22:52:34.000000000 +0000 +++ maven-filtering-3.1.1/src/site/apt/index.apt 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - ------ - Introduction - ------ - Olivier Lamy - ------ - 2011-01-05 - ------ - - ~~ 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. - -Maven Filtering - - These Plexus components have been built from the filtering process/code in Maven Resources Plugin. - - The goal is to provide a shared component for all plugins that needs to filter resources. - - -* MavenResourcesExecution - -** POM Interpolation - - POM values will be interpolated <> with expressions starting with <<>> or <<>> (it's configurable). - In previous versions something like $\{foo.version\} or $\{version\} was interpolated with the current POM version, but - it won't be interpolated with a POM value any more. - -** Escaping Interpolation - - It's possible now to define a String which will escape interpolation. - \$\{java.home\} will be interpolated to $\{java.home\}. - -** <<>> parameter - - It also accepts absolute paths. - -** <<>> parameter - - The parameter <<>> forces file copy even if the destination file is newer. - - -* MavenResourcesFiltering - - This component will apply filtering on a <<>> of <<>>s. - - If you want to use the default <<>> of <<>> (see below) - you should use the method without the <<>> parameter. - - The component will not filter a predefined set of file extensions (jpg, jpeg, gif, bmp, png). - - <> You can easily add extra file extensions. - - -* MavenFileFilter - - This component has a method which returns the default <<>>s. - These are: - - * Interpolation with token $\{ \} and values from properties files, <<<\>>>/<<<\>>>/<<<\>>, <<>> - and <<>> - - * Interpolation with token @ @ and values from properties files, <<<\>>>/<<<\>>>/<<<\>>, <<>> - and <<>> - - * Interpolation with token $\{ \} and values from <<>> interpolation - - * Interpolation with token @ @ and values from <<>> interpolation - - [] - - The values used for interpolation are stored in a <<>> object - and are loaded in the following order: - - * A <<>> of properties files, provided as a parameter to the method - - * Filters defined in the <<<\>>>/<<<\>>> section of the POM - - * Properties defined in the <<<\>>> section of the POM - - * The <<>> from the current <<>> - - [] - - <> As it's a <<>> object, the last defined key/value pair wins. - - <> When building the <<>> object and reading the properties files that defines the different filters, - interpolation with the token $\{ \} is supported for these filters with limited properties values coming from - <<>> and <<>>. The last wins here too. diff -Nru maven-filtering-1.1/src/site/apt/index.apt.vm maven-filtering-3.1.1/src/site/apt/index.apt.vm --- maven-filtering-1.1/src/site/apt/index.apt.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/site/apt/index.apt.vm 2015-06-13 09:57:50.000000000 +0000 @@ -0,0 +1,101 @@ + ------ + Introduction + ------ + Olivier Lamy + ------ + 2013-07-24 + ------ + + ~~ 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.name} + + This component has been built from the filtering process/code in Maven Resources Plugin. + + The goal is to provide a shared component for all plugins that needs to filter resources. + + +* MavenResourcesExecution + +** POM Interpolation + + POM values will be interpolated <> with expressions starting with <<>> or <<>> (it's configurable). + In previous versions something like $\{foo.version\} or $\{version\} was interpolated with the current POM version, but + it won't be interpolated with a POM value any more. + +** Escaping Interpolation + + It's possible now to define a String which will escape interpolation. + \$\{java.home\} will be interpolated to $\{java.home\}. + +** <<>> parameter + + It also accepts absolute paths. + +** <<>> parameter + + The parameter <<>> forces file copy even if the destination file is newer. + + +* MavenResourcesFiltering + + This component will apply filtering on a <<>> of <<>>s. + + If you want to use the default <<>> of <<>> (see below) + you should use the method without the <<>> parameter. + + The component will not filter a predefined set of file extensions (jpg, jpeg, gif, bmp, png). + + <> You can easily add extra file extensions. + + +* MavenFileFilter + + This component has a method which returns the default <<>>s. + These are: + + * Interpolation with token $\{ \} and values from properties files, <<<\>>>/<<<\>>>/<<<\>>, <<>> + and <<>> + + * Interpolation with token @ @ and values from properties files, <<<\>>>/<<<\>>>/<<<\>>, <<>> + and <<>> + + * Interpolation with token $\{ \} and values from <<>> interpolation + + * Interpolation with token @ @ and values from <<>> interpolation + + [] + + The values used for interpolation are stored in a <<>> object + and are loaded in the following order: + + * A <<>> of properties files, provided as a parameter to the method + + * Filters defined in the <<<\>>>/<<<\>>> section of the POM + + * Properties defined in the <<<\>>> section of the POM + + * The <<>> from the current <<>> + + [] + + <> As it's a <<>> object, the last defined key/value pair wins. + + <> When building the <<>> object and reading the properties files that defines the different filters, + interpolation with the token $\{ \} is supported for these filters with limited properties values coming from + <<>> and <<>>. The last wins here too. diff -Nru maven-filtering-1.1/src/site/apt/usage.apt maven-filtering-3.1.1/src/site/apt/usage.apt --- maven-filtering-1.1/src/site/apt/usage.apt 2011-01-05 22:52:34.000000000 +0000 +++ maven-filtering-3.1.1/src/site/apt/usage.apt 2015-11-07 11:28:42.000000000 +0000 @@ -30,11 +30,7 @@ Lookup the component in your Mojo: +-----+ - /** - * @component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" - * role-hint="default" - * @required - */ + @Required private MavenResourcesFiltering mavenResourcesFiltering; +-----+ @@ -96,5 +92,5 @@ +-----+ <> Maven Filtering uses the - {{{http://plexus.codehaus.org/plexus-components/plexus-interpolation/}plexus-interpolation component}}. + {{{http://codehaus-plexus.github.io/plexus-interpolation/}plexus-interpolation component}}. diff -Nru maven-filtering-1.1/src/site/resources/download.cgi maven-filtering-3.1.1/src/site/resources/download.cgi --- maven-filtering-1.1/src/site/resources/download.cgi 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/site/resources/download.cgi 2014-05-18 14:26:56.000000000 +0000 @@ -0,0 +1,22 @@ +#!/bin/sh +# +# 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. +# +# Just call the standard mirrors.cgi script. It will use download.html +# as the input template. +exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* \ No newline at end of file diff -Nru maven-filtering-1.1/src/site/site.xml maven-filtering-3.1.1/src/site/site.xml --- maven-filtering-1.1/src/site/site.xml 2011-09-01 21:28:17.000000000 +0000 +++ maven-filtering-3.1.1/src/site/site.xml 2016-05-15 09:15:59.000000000 +0000 @@ -27,6 +27,9 @@ + + + diff -Nru maven-filtering-1.1/src/site/xdoc/download.xml.vm maven-filtering-3.1.1/src/site/xdoc/download.xml.vm --- maven-filtering-1.1/src/site/xdoc/download.xml.vm 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/site/xdoc/download.xml.vm 2015-06-19 23:25:50.000000000 +0000 @@ -0,0 +1,126 @@ + + + + + + + Download ${project.name} Source + + +
+ +

${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build + ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.

+ +

You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24 + hours to reach all mirrors.

+ +

In order to guard against corrupted downloads/installations, it is highly recommended to + verify the signature + of the release bundles against the public KEYS used by the Apache Maven + developers.

+ +

${project.name} is distributed under the Apache License, version 2.0.

+ +

We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.

+ + + + +

+ [if-any logo] + + logo + + [end] + The currently selected mirror is + [preferred]. + If you encounter a problem with this mirror, + please select another mirror. + If all mirrors are failing, there are + backup + mirrors + (at the end of the mirrors list) that should be available. +

+ +
+ Other mirrors: + + +
+ +

+ You may also consult the + complete list of + mirrors. +

+ + + + + +

This is the current stable version of ${project.name}.

+ + + + + + + + + + + + + + + + + + +
LinkChecksumSignature
${project.name} ${project.version} (Source zip)maven/shared/${project.artifactId}-${project.version}-source-release.zipmaven/shared/${project.artifactId}-${project.version}-source-release.zip.md5maven/shared/${project.artifactId}-${project.version}-source-release.zip.asc
+
+ + + +

Older non-recommended releases can be found on our archive site.

+ +
+
+ +
+ diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/AbstractInterpolatorFilterReaderLineEndingTest.java 2015-06-14 17:09:05.000000000 +0000 @@ -0,0 +1,122 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.when; + +import java.io.Reader; +import java.io.StringReader; + +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.util.IOUtil; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public abstract class AbstractInterpolatorFilterReaderLineEndingTest +{ + + @Mock + private Interpolator interpolator; + + @Before + public void onSetup() + { + MockitoAnnotations.initMocks( this ); + } + + @Test + public void testDefaults() + throws Exception + { + when( interpolator.interpolate( eq( "${a}" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DONE_A" ); + + Reader in = new StringReader( "text without expression" ); + Reader reader = getDollarBracesReader( in, interpolator, "\\" ); + assertEquals( "text without expression", IOUtil.toString( reader ) ); + + in = new StringReader( "valid expression ${a}" ); + reader = getDollarBracesReader( in, interpolator, null ); + assertEquals( "valid expression DONE_A", IOUtil.toString( reader ) ); + + in = new StringReader( "empty expression ${}" ); + reader = getDollarBracesReader( in, interpolator, null ); + assertEquals( "empty expression ${}", IOUtil.toString( reader ) ); + + in = new StringReader( "dollar space expression $ {a}" ); + reader = getDollarBracesReader( in, interpolator, "\\" ); + assertEquals( "dollar space expression $ {a}", IOUtil.toString( reader ) ); + + in = new StringReader( "space in expression ${ a}" ); + reader = getDollarBracesReader( in, interpolator, "\\" ); + assertEquals( "space in expression ${ a}", IOUtil.toString( reader ) ); + + in = new StringReader( "escape dollar with expression \\${a}" ); + reader = getDollarBracesReader( in, interpolator, "\\" ); + assertEquals( "escape dollar with expression ${a}", IOUtil.toString( reader ) ); + + in = new StringReader( "unknown expression ${unknown}" ); + reader = getDollarBracesReader( in, interpolator, "\\" ); + assertEquals( "unknown expression ${unknown}", IOUtil.toString( reader ) ); + } + + // MSHARED-198: custom delimiters doesn't work as expected + @Test + public void testCustomDelimiters() + throws Exception + { + when( interpolator.interpolate( eq( "aaaFILTER.a.MEaaa" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DONE" ); + when( interpolator.interpolate( eq( "abcFILTER.a.MEabc" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DONE" ); + + Reader in = new StringReader( "aaaFILTER.a.MEaaa" ); + Reader reader = getAaa_AaaReader( in, interpolator ); + + assertEquals( "DONE", IOUtil.toString( reader ) ); + + in = new StringReader( "abcFILTER.a.MEabc" ); + reader = getAbc_AbcReader( in, interpolator ); + assertEquals( "DONE", IOUtil.toString( reader ) ); + } + + // MSHARED-235: reader exceeds readAheadLimit + @Test + public void testMarkInvalid() + throws Exception + { + Reader in = new StringReader( "@\").replace(p,\"]\").replace(q,\"" ); + Reader reader = getAtReader( in, interpolator, "\\" ); + + assertEquals( "@\").replace(p,\"]\").replace(q,\"", IOUtil.toString( reader ) ); + } + + protected abstract Reader getAbc_AbcReader( Reader in, Interpolator interpolator ); + + protected abstract Reader getAaa_AaaReader( Reader in, Interpolator interpolator ); + + protected abstract Reader getDollarBracesReader( Reader in, Interpolator interpolator, String escapeString ); + + protected abstract Reader getAtReader( Reader in, Interpolator interpolator, String escapeString ); + +} \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/AbstractMavenFilteringRequestTest.java 2016-02-08 08:20:17.000000000 +0000 @@ -0,0 +1,111 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.LinkedHashSet; + +import org.junit.Test; + +/** + * @author Karl Heinz Marbaise delimiters = new LinkedHashSet(); + request.setDelimiters( delimiters, false ); + assertThat( request.getDelimiters() ).containsExactly( "${*}", "@" ); + } + + @Test + public void setDelimitersShouldAddOnlyTheGivenDelimiter() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + LinkedHashSet delimiters = new LinkedHashSet(); + delimiters.add( "test" ); + request.setDelimiters( delimiters, false ); + assertThat( request.getDelimiters() ).containsExactly( "test" ); + } + + @Test + public void setDelimitersShouldAddDefaultDelimitersForNullElements() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + LinkedHashSet delimiters = new LinkedHashSet(); + delimiters.add( "test" ); + delimiters.add( null ); + delimiters.add( "second" ); + request.setDelimiters( delimiters, false ); + assertThat( request.getDelimiters() ).containsExactly( "test", "${*}", "second" ); + } + + @Test + public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfNullGiven() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + request.setDelimiters( null, true ); + assertThat( request.getDelimiters() ).containsExactly( "${*}", "@" ); + } + + @Test + public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfNotNullGiven() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + LinkedHashSet delimiters = new LinkedHashSet(); + request.setDelimiters( delimiters, true ); + assertThat( request.getDelimiters() ).containsExactly( "${*}", "@" ); + } + + @Test + public void setDelimitersShouldAddDefaultDelimitersIfUseDefaultDelimitersIfSingleElementIsGiven() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + LinkedHashSet delimiters = new LinkedHashSet(); + delimiters.add( "test" ); + request.setDelimiters( delimiters, true ); + assertThat( request.getDelimiters() ).containsExactly( "${*}", "@", "test" ); + } + + @Test + public void setDelimitersShouldAddDefaultDelimitersForNullElement() + { + AbstractMavenFilteringRequest request = new AbstractMavenFilteringRequest(); + LinkedHashSet delimiters = new LinkedHashSet(); + delimiters.add( "test" ); + delimiters.add( null ); + delimiters.add( "second" ); + request.setDelimiters( delimiters, true ); + assertThat( request.getDelimiters() ).containsExactly( "${*}", "@", "test", "second" ); + } + +} \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/BoundedReaderTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -0,0 +1,108 @@ +/* + * 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. + */ +package org.apache.maven.shared.filtering; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; + +import org.junit.Test; + +public class BoundedReaderTest +{ + + private final Reader sr = new BufferedReader( new StringReader( "01234567890" ) ); + + @Test + public void readTillEnd() + throws IOException + { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.mark( 3 ); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void readMulti() + throws IOException + { + BoundedReader mr = new BoundedReader( sr, 3 ); + char[] cbuf = new char[4]; + for ( int i = 0; i < cbuf.length; i++ ) + cbuf[i] = 'X'; + final int read = mr.read( cbuf, 0, 4 ); + assertEquals( 3, read ); + assertEquals( '0', cbuf[0] ); + assertEquals( '1', cbuf[1] ); + assertEquals( '2', cbuf[2] ); + assertEquals( 'X', cbuf[3] ); + mr.close(); + } + + @Test + public void readMultiWithOffset() + throws IOException + { + BoundedReader mr = new BoundedReader( sr, 3 ); + char[] cbuf = new char[4]; + for ( int i = 0; i < cbuf.length; i++ ) + cbuf[i] = 'X'; + final int read = mr.read( cbuf, 1, 2 ); + assertEquals( 2, read ); + assertEquals( 'X', cbuf[0] ); + assertEquals( '0', cbuf[1] ); + assertEquals( '1', cbuf[2] ); + assertEquals( 'X', cbuf[3] ); + mr.close(); + } + + @Test + public void resetWorks() + throws IOException + { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.read(); + mr.read(); + mr.read(); + mr.reset(); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void skipTest() + throws IOException + { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.skip( 2 ); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } +} \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java 2011-02-20 20:09:17.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenFileFilterTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -20,16 +20,24 @@ */ import java.io.File; +import java.io.Reader; +import java.io.StringReader; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Properties; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.FileUtils.FilterWrapper; +import org.apache.maven.shared.utils.io.IOUtil; import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; /** - * @author olamy - * @version $Id: DefaultMavenFileFilterTest.java 1072705 2011-02-20 20:09:17Z bentmann $ + * @author Olivier Lamy + * @version $Id: DefaultMavenFileFilterTest.java 1713023 2015-11-06 20:28:40Z khmarbaise $ */ public class DefaultMavenFileFilterTest extends PlexusTestCase @@ -50,7 +58,7 @@ public void testNotOverwriteFile() throws Exception { - MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" ); + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); File from = new File( getBasedir(), "src/test/units-files/reflection-test.properties" ); @@ -73,7 +81,7 @@ public void testOverwriteFile() throws Exception { - MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" ); + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); File from = new File( getBasedir(), "src/test/units-files/reflection-test.properties" ); @@ -96,7 +104,7 @@ public void testNullSafeDefaultFilterWrappers() throws Exception { - MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" ); + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); mavenFileFilter.getDefaultFilterWrappers( null, null, false, null, null ); @@ -108,18 +116,78 @@ { DefaultMavenFileFilter mavenFileFilter = new DefaultMavenFileFilter(); - File testDir = new File(getBasedir(), "src/test/units-files/MSHARED-177"); + File testDir = new File( getBasedir(), "src/test/units-files/MSHARED-177" ); - List filters = new ArrayList(); + List filters = new ArrayList(); - filters.add(new File(testDir, "first_filter_file.properties").getAbsolutePath()); - filters.add(new File(testDir, "second_filter_file.properties").getAbsolutePath()); - filters.add(new File(testDir, "third_filter_file.properties").getAbsolutePath()); + filters.add( new File( testDir, "first_filter_file.properties" ).getAbsolutePath() ); + filters.add( new File( testDir, "second_filter_file.properties" ).getAbsolutePath() ); + filters.add( new File( testDir, "third_filter_file.properties" ).getAbsolutePath() ); final Properties filterProperties = new Properties(); - mavenFileFilter.loadProperties(filterProperties, filters, new Properties() ); + mavenFileFilter.loadProperties( filterProperties, new File( getBasedir() ), filters, new Properties() ); assertTrue( filterProperties.getProperty( "third_filter_key" ).equals( "first and second" ) ); } + + // MSHARED-161: DefaultMavenFileFilter.getDefaultFilterWrappers loads + // filters from the current directory instead of using basedir + public void testMavenBasedir() + throws Exception + { + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); + + AbstractMavenFilteringRequest req = new AbstractMavenFilteringRequest(); + req.setFileFilters( Collections.singletonList( "src/main/filters/filefilter.properties" ) ); + + MavenProject mavenProject = new StubMavenProject( new File( "src/test/units-files/MSHARED-161" ) ); + mavenProject.getBuild().setFilters( Collections.singletonList( "src/main/filters/buildfilter.properties" ) ); + req.setMavenProject( mavenProject ); + req.setInjectProjectBuildFilters( true ); + + List wrappers = mavenFileFilter.getDefaultFilterWrappers( req ); + + Reader reader = wrappers.get( 0 ).getReader( new StringReader( "${filefilter} ${buildfilter}" ) ); + + assertEquals( "true true", IOUtil.toString( reader ) ); + } + + // MSHARED-198: custom delimiters doesn't work as expected + public void testCustomDelimiters() + throws Exception + { + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); + + AbstractMavenFilteringRequest req = new AbstractMavenFilteringRequest(); + Properties additionalProperties = new Properties(); + additionalProperties.setProperty( "FILTER.a.ME", "DONE" ); + req.setAdditionalProperties( additionalProperties ); + req.setDelimiters( new LinkedHashSet( Arrays.asList( "aaa*aaa", "abc*abc" ) ) ); + + List wrappers = mavenFileFilter.getDefaultFilterWrappers( req ); + + Reader reader = wrappers.get( 0 ).getReader( new StringReader( "aaaFILTER.a.MEaaa" ) ); + assertEquals( "DONE", IOUtil.toString( reader ) ); + + reader = wrappers.get( 0 ).getReader( new StringReader( "abcFILTER.a.MEabc" ) ); + assertEquals( "DONE", IOUtil.toString( reader ) ); + } + + // MSHARED-199: Filtering doesn't work if 2 delimiters are used on the same line, the first one being left open + public void testLineWithSingleAtAndExpression() + throws Exception + { + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); + + AbstractMavenFilteringRequest req = new AbstractMavenFilteringRequest(); + Properties additionalProperties = new Properties(); + additionalProperties.setProperty( "foo", "bar" ); + req.setAdditionalProperties( additionalProperties ); + + List wrappers = mavenFileFilter.getDefaultFilterWrappers( req ); + + Reader reader = wrappers.get( 0 ).getReader( new StringReader( "toto@titi.com ${foo}" ) ); + assertEquals( "toto@titi.com bar", IOUtil.toString( reader ) ); + } } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenReaderFilterTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -0,0 +1,53 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.Reader; +import java.io.StringReader; +import java.util.Properties; + +import org.apache.maven.shared.utils.io.IOUtil; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Kristian Rosenvold + */ +public class DefaultMavenReaderFilterTest + extends PlexusTestCase +{ + public void testJustDoSomeFiltering() + throws Exception + { + assertNotNull( DefaultMavenReaderFilter.class ); + MavenReaderFilter readerFilter = lookup( MavenReaderFilter.class ); + + StringReader src = new StringReader( "toto@titi.com ${foo}" ); + MavenReaderFilterRequest req = new MavenReaderFilterRequest(); + Properties additionalProperties = new Properties(); + additionalProperties.setProperty( "foo", "bar" ); + req.setFrom( src ); + req.setFiltering( true ); + req.setAdditionalProperties( additionalProperties ); + + final Reader filter = readerFilter.filter( req ); + + assertEquals( "toto@titi.com bar", IOUtil.toString( filter ) ); + } +} diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java 2012-06-20 15:16:28.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java 2016-05-21 10:50:39.000000000 +0000 @@ -19,15 +19,6 @@ * under the License. */ -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Resource; -import org.apache.maven.settings.Settings; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; -import org.codehaus.plexus.interpolation.ValueSource; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; - import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -37,9 +28,18 @@ import java.util.List; import java.util.Properties; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Resource; +import org.apache.maven.settings.Settings; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.IOUtil; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; +import org.codehaus.plexus.interpolation.ValueSource; + /** * @author Olivier Lamy - * @version $Id: DefaultMavenResourcesFilteringTest.java 1352151 2012-06-20 15:16:28Z olamy $ + * @version $Id: DefaultMavenResourcesFilteringTest.java 1744899 2016-05-21 10:50:39Z khmarbaise $ * @since 1.0-beta-1 */ public class DefaultMavenResourcesFilteringTest @@ -72,26 +72,28 @@ projectProperties.put( "foo", "bar" ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; File initialImageFile = new File( unitFilesDir, "happy_duke.gif" ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); - mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - nonFilteredFileExtensions, new StubMavenSession() ); + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, + nonFilteredFileExtensions, new StubMavenSession() ); + mavenResourcesExecution.setUseDefaultFilterWrappers( true ); + mavenResourcesFiltering.filterResources( mavenResourcesExecution ); assertFiltering( baseDir, initialImageFile, false, false ); } @@ -102,27 +104,36 @@ File baseDir = new File( "c:\\foo\\bar" ); StubMavenProject mavenProject = new StubMavenProject( baseDir ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/session-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); + List filtersFile = new ArrayList(); Settings settings = new Settings(); - settings.setLocalRepository( - System.getProperty( "localRepository", System.getProperty( "maven.repo.local", "/path/to/local/repo" ) ) ); + settings.setLocalRepository( System.getProperty( "localRepository", + System.getProperty( "maven.repo.local", + "/path/to/local/repo" ) ) ); MavenSession session = new StubMavenSession( settings ); - mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, session ); + MavenResourcesExecution mre = new MavenResourcesExecution(); + mre.setResources( resources ); + mre.setOutputDirectory( outputDirectory ); + mre.setEncoding( "UTF-8" ); + mre.setMavenProject( mavenProject ); + mre.setFilters( filtersFile ); + mre.setNonFilteredFileExtensions( Collections. emptyList() ); + mre.setMavenSession( session ); + mre.setUseDefaultFilterWrappers( true ); + + mavenResourcesFiltering.filterResources( mre ); Properties result = new Properties(); FileInputStream in = null; @@ -154,23 +165,22 @@ projectProperties.put( "foo", "bar" ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; File initialImageFile = new File( unitFilesDir, "happy_duke.gif" ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, nonFilteredFileExtensions, new StubMavenSession() ); @@ -192,23 +202,22 @@ projectProperties.put( "foo", "bar" ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; File initialImageFile = new File( unitFilesDir, "happy_duke.gif" ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); Properties additionalProperties = new Properties(); additionalProperties.put( "greatDate", "1973-06-14" ); additionalProperties.put( "pom.version", "99.00" ); @@ -223,7 +232,7 @@ private void assertFiltering( File baseDir, File initialImageFile, boolean escapeTest, boolean additionnalProperties ) - throws Exception + throws Exception { assertEquals( 7, outputDirectory.listFiles().length ); Properties result = new Properties(); @@ -306,23 +315,22 @@ projectProperties.put( "foo", "bar" ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; File initialImageFile = new File( unitFilesDir, "happy_duke.gif" ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", null, @@ -331,7 +339,7 @@ ValueSource vs = new PrefixedObjectValueSource( mavenResourcesExecution.getProjectStartExpressions(), mavenProject, true ); - mavenResourcesExecution.addFilerWrapperWithEscaping( vs, "@", "@", null ); + mavenResourcesExecution.addFilerWrapperWithEscaping( vs, "@", "@", null, false ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); Properties result = @@ -348,20 +356,28 @@ mavenProject.setVersion( "1.0" ); mavenProject.setGroupId( "org.apache" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; File initialImageFile = new File( unitFilesDir, "happy_duke.gif" ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( false ); - mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", null, - Collections.EMPTY_LIST, new StubMavenSession() ); + + MavenResourcesExecution mre = new MavenResourcesExecution(); + mre.setResources( resources ); + mre.setOutputDirectory( outputDirectory ); + mre.setEncoding( "UTF-8" ); + mre.setMavenProject( mavenProject ); + mre.setFilters( null ); + mre.setNonFilteredFileExtensions( Collections. emptyList() ); + mre.setMavenSession( new StubMavenSession() ); + + mavenResourcesFiltering.filterResources( mre ); assertEquals( 7, outputDirectory.listFiles().length ); Properties result = @@ -426,25 +442,24 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); resource.addInclude( "includ*" ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, new StubMavenSession() ); + Collections. emptyList(), new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File[] files = outputDirectory.listFiles(); @@ -462,29 +477,29 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); resource.addInclude( "includ*" ); resource.addInclude( "**/includ*" ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, new StubMavenSession() ); + Collections. emptyList(), new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File[] files = outputDirectory.listFiles(); + assertNotNull( files ); assertEquals( 2, files.length ); File includeFile = new File( outputDirectory, "includefile.txt" ); assertTrue( includeFile.exists() ); @@ -503,26 +518,25 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); resource.addExclude( "*.gif" ); resource.addExclude( "**/excludedir/**" ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, new StubMavenSession() ); + Collections. emptyList(), new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File[] files = outputDirectory.listFiles(); @@ -549,13 +563,12 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); @@ -573,13 +586,13 @@ { FileUtils.cleanDirectory( targetPathFile ); } - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, new StubMavenSession() ); + Collections. emptyList(), new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File[] files = targetPathFile.listFiles(); @@ -596,25 +609,24 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/maven-resources-filtering"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); resource.addInclude( "includ*" ); resource.setTargetPath( "testTargetPath" ); - List filtersFile = new ArrayList(); - filtersFile.add( - getBasedir() + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); + List filtersFile = new ArrayList(); + filtersFile.add( getBasedir() + + "/src/test/units-files/maven-resources-filtering/empty-maven-resources-filtering.txt" ); MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - Collections.EMPTY_LIST, new StubMavenSession() ); + Collections. emptyList(), new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File targetPathFile = new File( outputDirectory, "testTargetPath" ); @@ -624,6 +636,7 @@ assertEquals( "includefile.txt", files[0].getName() ); } + @SuppressWarnings( "serial" ) public void testEmptyDirectories() throws Exception { @@ -633,29 +646,29 @@ mavenProject.setGroupId( "org.apache" ); mavenProject.setName( "test project" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( new Resource() { { setDirectory( getBasedir() + "/src/test/units-files/includeEmptyDirs" ); - setExcludes( Arrays.asList( new String[]{ "**/.gitignore" } ) ); + setExcludes( Arrays.asList( "**/.gitignore" ) ); } } ); MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", Collections.EMPTY_LIST, - Collections.EMPTY_LIST, new StubMavenSession() ); + new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", + Collections. emptyList(), Collections. emptyList(), + new StubMavenSession() ); mavenResourcesExecution.setIncludeEmptyDirs( true ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); File[] childs = outputDirectory.listFiles(); + assertNotNull( childs ); assertEquals( 3, childs.length ); - for ( int i = 0, size = childs.length; i < size; i++ ) + for ( File file : childs ) { - File file = childs[i]; if ( file.getName().endsWith( "dir1" ) || file.getName().endsWith( "empty-directory" ) || file.getName().endsWith( "empty-directory-child" ) ) { @@ -682,9 +695,109 @@ } } + @SuppressWarnings( "serial" ) + public void testShouldReturnGitIgnoreFiles() + throws Exception + { + File sourceDirectory = new File( getBasedir(), "/target/sourceTestGitIgnoreFile" ); + FileUtils.forceDelete( sourceDirectory ); + + createTestDataStructure( sourceDirectory ); + + File outputDirectory = new File( getBasedir(), "/target/testGitIgnoreFile" ); + File baseDir = new File( "c:\\foo\\bar" ); + StubMavenProject mavenProject = new StubMavenProject( baseDir ); + mavenProject.setVersion( "1.0" ); + mavenProject.setGroupId( "org.apache" ); + mavenProject.setName( "test project" ); + + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); + + List resources = new ArrayList(); + resources.add( new Resource() + { + { + setDirectory( getBasedir() + "/target/sourceTestGitIgnoreFile" ); + setIncludes( Arrays.asList( "**/*" ) ); + } + } ); + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", + Collections. emptyList(), Collections. emptyList(), + new StubMavenSession() ); + mavenResourcesExecution.setIncludeEmptyDirs( true ); + mavenResourcesExecution.setAddDefaultExcludes( false ); + mavenResourcesFiltering.filterResources( mavenResourcesExecution ); + + File[] childs = outputDirectory.listFiles(); + assertNotNull( childs ); + assertEquals( 3, childs.length ); + + for ( File file : childs ) + { + if ( file.getName().endsWith( "dir1" ) || file.getName().endsWith( "empty-directory" ) + || file.getName().endsWith( "empty-directory-child" ) ) + { + if ( file.getName().endsWith( "dir1" ) ) + { + assertEquals( 1, file.list().length ); + assertTrue( file.listFiles()[0].getName().endsWith( "foo.txt" ) ); + } + if ( file.getName().endsWith( "empty-directory" ) ) + { + + assertEquals( 1, file.list().length ); + assertTrue( file.listFiles()[0].getName().endsWith( ".gitignore" ) ); + } + if ( file.getName().endsWith( "empty-directory-child" ) ) + { + assertEquals( 1, file.list().length ); + assertTrue( file.listFiles()[0].isDirectory() ); + assertEquals( 1, file.listFiles()[0].listFiles().length ); + + assertTrue( file.listFiles()[0].listFiles()[0].getName().endsWith( ".gitignore" ) ); + } + } + else + { + fail( "unknow child file found " + file.getName() ); + } + } + } + /** - * unit test for MSHARED-81 : http://jira.codehaus.org/browse/MSHARED-81 + * The folder and file structure will be created instead of letting this resource plugin copying the structure which + * will not work. + * + * @param sourceDirectory The source folder where the structure will be created. + * @throws IOException */ + private void createTestDataStructure( File sourceDirectory ) + throws IOException + { + File dir1 = new File( sourceDirectory, "dir1" ); + + dir1.mkdirs(); + FileUtils.fileWrite( new File( dir1, "foo.txt" ), "UTF-8", "This is a Test File" ); + + File emptyDirectory = new File( sourceDirectory, "empty-directory" ); + emptyDirectory.mkdirs(); + + FileUtils.fileWrite( new File( emptyDirectory, ".gitignore" ), "UTF-8", "# .gitignore file" ); + + File emptyDirectoryChild = new File( sourceDirectory, "empty-directory-child" ); + emptyDirectory.mkdirs(); + + File emptyDirectoryChildEmptyChild = new File( emptyDirectoryChild, "empty-child" ); + emptyDirectoryChildEmptyChild.mkdirs(); + + FileUtils.fileWrite( new File( emptyDirectoryChildEmptyChild, ".gitignore" ), "UTF-8", "# .gitignore file" ); + } + + /** + * unit test for MSHARED-81 : https://issues.apache.org/jira/browse/MSHARED-81 + */ + @SuppressWarnings( "serial" ) public void testMSHARED81() throws Exception { @@ -697,10 +810,9 @@ mavenProject.addProperty( "foo", "this is foo" ); mavenProject.addProperty( "bar", "this is bar" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( new Resource() { { @@ -717,8 +829,8 @@ } ); File output = new File( outputDirectory, "MSHARED-81" ); MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.EMPTY_LIST, - Collections.EMPTY_LIST, new StubMavenSession() ); + new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections. emptyList(), + Collections. emptyList(), new StubMavenSession() ); mavenResourcesExecution.setIncludeEmptyDirs( true ); mavenResourcesExecution.setEscapeString( "\\" ); @@ -726,28 +838,28 @@ Properties filteredResult = PropertyUtils.loadPropertyFile( new File( output, "filtered.properties" ), null ); - Properties expectedFilteredResult = PropertyUtils.loadPropertyFile( - new File( getBasedir() + "/src/test/units-files/MSHARED-81", "expected-filtered.properties" ), null ); - - System.out.println( "\nExpected:\n" ); - expectedFilteredResult.list( System.out ); - System.out.println( "\n\n\nGot:\n" ); - filteredResult.list( System.out ); + Properties expectedFilteredResult = + PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/MSHARED-81", + "expected-filtered.properties" ), + null ); assertEquals( expectedFilteredResult, filteredResult ); Properties nonFilteredResult = PropertyUtils.loadPropertyFile( new File( output, "unfiltered.properties" ), null ); - Properties expectedNonFilteredResult = PropertyUtils.loadPropertyFile( - new File( getBasedir() + "/src/test/units-files/MSHARED-81/resources", "unfiltered.properties" ), null ); + Properties expectedNonFilteredResult = + PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/MSHARED-81/resources", + "unfiltered.properties" ), + null ); assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) ); } /** - * unit test for edge cases : http://jira.codehaus.org/browse/MSHARED-228 + * unit test for edge cases : https://issues.apache.org/jira/browse/MSHARED-228 */ + @SuppressWarnings( "serial" ) public void testEdgeCases() throws Exception { @@ -761,10 +873,9 @@ mavenProject.addProperty( "bar", "this is bar" ); mavenProject.addProperty( "domain", "this.is.domain.com" ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( new Resource() { { @@ -781,8 +892,8 @@ } ); File output = new File( outputDirectory, "edge-cases" ); MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections.EMPTY_LIST, - Collections.EMPTY_LIST, new StubMavenSession() ); + new MavenResourcesExecution( resources, output, mavenProject, "UTF-8", Collections. emptyList(), + Collections. emptyList(), new StubMavenSession() ); mavenResourcesExecution.setIncludeEmptyDirs( true ); mavenResourcesExecution.setEscapeString( "\\" ); @@ -790,23 +901,57 @@ Properties filteredResult = PropertyUtils.loadPropertyFile( new File( output, "filtered.properties" ), null ); - Properties expectedFilteredResult = PropertyUtils.loadPropertyFile( - new File( getBasedir() + "/src/test/units-files/edge-cases", "expected-filtered.properties" ), null ); - - System.out.println( "\nExpected:\n" ); - expectedFilteredResult.list( System.out ); - System.out.println( "\n\n\nGot:\n" ); - filteredResult.list( System.out ); + Properties expectedFilteredResult = + PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/edge-cases", + "expected-filtered.properties" ), + null ); assertEquals( expectedFilteredResult, filteredResult ); Properties nonFilteredResult = PropertyUtils.loadPropertyFile( new File( output, "unfiltered.properties" ), null ); - Properties expectedNonFilteredResult = PropertyUtils.loadPropertyFile( - new File( getBasedir() + "/src/test/units-files/edge-cases/resources", "unfiltered.properties" ), null ); + Properties expectedNonFilteredResult = + PropertyUtils.loadPropertyFile( new File( getBasedir() + "/src/test/units-files/edge-cases/resources", + "unfiltered.properties" ), + null ); assertTrue( nonFilteredResult.equals( expectedNonFilteredResult ) ); } + // MSHARED-220: Apply filtering to filenames + public void testFilterFileName() + throws Exception + { + + File baseDir = new File( "/foo/bar" ); + StubMavenProject mavenProject = new StubMavenProject( baseDir ); + mavenProject.setVersion( "1.0" ); + mavenProject.setGroupId( "org.apache" ); + mavenProject.setName( "test project" ); + + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); + + String unitFilesDir = getBasedir() + "/src/test/units-files/maven-filename-filtering"; + + Resource resource = new Resource(); + resource.setDirectory( unitFilesDir ); + resource.setFiltering( true ); + resource.addInclude( "${pom.version}*" ); + resource.setTargetPath( "testTargetPath" ); + + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( Collections.singletonList( resource ), outputDirectory, mavenProject, "UTF-8", + Collections. emptyList(), Collections. emptyList(), + new StubMavenSession() ); + mavenResourcesExecution.setFilterFilenames( true ); + mavenResourcesFiltering.filterResources( mavenResourcesExecution ); + + File targetPathFile = new File( outputDirectory, "testTargetPath" ); + + File[] files = targetPathFile.listFiles(); + assertEquals( 1, files.length ); + assertEquals( "1.0.txt", files[0].getName() ); + } + } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java 2011-02-20 20:42:50.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/EscapeStringTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -27,18 +27,17 @@ import java.util.Properties; import org.apache.maven.model.Resource; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.IOUtil; import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; /** * @author Olivier Lamy - * */ public class EscapeStringTest extends PlexusTestCase { - + File outputDirectory = new File( getBasedir(), "target/EscapeStringTest" ); File unitDirectory = new File( getBasedir(), "src/test/units-files/escape-remove-char" ); @@ -68,24 +67,21 @@ projectProperties.put( "java.version", "zloug" ); projectProperties.put( "replaceThis", "I am the replacement" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class - .getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitDirectory.getPath() ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); + List filtersFile = new ArrayList(); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); - MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, - mavenProject, "UTF-8", - filtersFile, - nonFilteredFileExtensions, - new StubMavenSession() ); + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, + nonFilteredFileExtensions, new StubMavenSession() ); mavenResourcesExecution.setUseDefaultFilterWrappers( true ); mavenResourcesExecution.setEscapeString( "!" ); @@ -97,9 +93,8 @@ { String content = IOUtil.toString( new FileInputStream( new File( outputDirectory, "content.xml" ) ) ); - System.out.println( "content " + content ); - assertTrue( content.indexOf( "Content with replacement: I am the replacement !" ) >= 0 ); - assertTrue( content.indexOf( "Content with escaped replacement: Do not ${replaceThis} !" ) >= 0 ); + assertTrue( content.contains( "Content with replacement: I am the replacement !" ) ); + assertTrue( content.contains( "Content with escaped replacement: Do not ${replaceThis} !" ) ); } finally { diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/FilteringUtilsTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/FilteringUtilsTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/FilteringUtilsTest.java 2011-01-20 20:58:23.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/FilteringUtilsTest.java 2014-10-17 15:36:52.000000000 +0000 @@ -25,7 +25,7 @@ * @author John Casey * @author Dennis Lundberg * @since 1.0 - * @version $Id: FilteringUtilsTest.java 1061510 2011-01-20 20:58:23Z dennisl $ + * @version $Id: FilteringUtilsTest.java 1632611 2014-10-17 15:36:52Z khmarbaise $ */ public class FilteringUtilsTest extends PlexusTestCase @@ -47,24 +47,25 @@ // This doesn't work, see MSHARED-121 /* - public void testEscapeWindowsPathStartingWithDrivelessAbsolutePath() - { - assertEquals( "\\\\Users\\\\Administrator", FilteringUtils.escapeWindowsPath( "\\Users\\Administrator" ) ); - } - */ + * public void testEscapeWindowsPathStartingWithDrivelessAbsolutePath() + * { + * assertEquals( "\\\\Users\\\\Administrator", FilteringUtils.escapeWindowsPath( "\\Users\\Administrator" ) ); + * } + */ // This doesn't work, see MSHARED-121 /* - public void testEscapeWindowsPathStartingWithExpression() - { - assertEquals( "${pathExpr}\\\\Documents", FilteringUtils.escapeWindowsPath( "${pathExpr}\\Documents" ) ); - } - */ + * public void testEscapeWindowsPathStartingWithExpression() + * { + * assertEquals( "${pathExpr}\\\\Documents", FilteringUtils.escapeWindowsPath( "${pathExpr}\\Documents" ) ); + * } + */ // MSHARED-179 public void testEscapeWindowsPathNotAtBeginning() throws Exception { - assertEquals( "jdbc:derby:C:\\\\Users\\\\Administrator/test;create=true", FilteringUtils.escapeWindowsPath( "jdbc:derby:C:\\Users\\Administrator/test;create=true" ) ); + assertEquals( "jdbc:derby:C:\\\\Users\\\\Administrator/test;create=true", + FilteringUtils.escapeWindowsPath( "jdbc:derby:C:\\Users\\Administrator/test;create=true" ) ); } } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java 2011-02-20 20:09:17.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -24,15 +24,16 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Properties; +import java.util.Set; import org.apache.maven.model.Resource; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.IOUtil; import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; import org.sonatype.plexus.build.incremental.ThreadBuildContext; import org.sonatype.plexus.build.incremental.test.TestIncrementalBuildContext; @@ -65,10 +66,11 @@ assertTime( "time", "file02.txt" ); // only one file is expected to change - HashSet changedFiles = new HashSet(); + Set changedFiles = new HashSet(); changedFiles.add( "file01.txt" ); - TestIncrementalBuildContext ctx = new TestIncrementalBuildContext( unitDirectory, changedFiles, new HashMap() ); + TestIncrementalBuildContext ctx = + new TestIncrementalBuildContext( unitDirectory, changedFiles, Collections.emptyMap() ); ThreadBuildContext.setThreadBuildContext( ctx ); filter( "notime" ); @@ -77,11 +79,8 @@ assertTrue( ctx.getRefreshFiles().contains( new File( outputDirectory, "file01.txt" ) ) ); - // one file is expected to be deleted - HashSet deletedFiles = new HashSet(); - deletedFiles.add( "file01.txt" ); - - ctx = new TestIncrementalBuildContext( unitDirectory, new HashSet(), changedFiles, new HashMap() ); + ctx = new TestIncrementalBuildContext( unitDirectory, Collections.emptySet(), changedFiles, + Collections.emptyMap() ); ThreadBuildContext.setThreadBuildContext( ctx ); filter( "moretime" ); @@ -99,9 +98,10 @@ filter( "time" ); // all files are reprocessed after contents of output directory changed (e.g. was deleted) - HashSet changedFiles = new HashSet(); + Set changedFiles = new HashSet(); changedFiles.add( "target/IncrementalResourceFilteringTest" ); - TestIncrementalBuildContext ctx = new TestIncrementalBuildContext( unitDirectory, changedFiles, new HashMap() ); + TestIncrementalBuildContext ctx = + new TestIncrementalBuildContext( unitDirectory, changedFiles, Collections.emptyMap() ); ThreadBuildContext.setThreadBuildContext( ctx ); filter( "notime" ); @@ -120,9 +120,10 @@ filter( "time" ); // all files are reprocessed after content of filters changes - HashSet changedFiles = new HashSet(); + Set changedFiles = new HashSet(); changedFiles.add( "filters.txt" ); - TestIncrementalBuildContext ctx = new TestIncrementalBuildContext( unitDirectory, changedFiles, new HashMap() ); + TestIncrementalBuildContext ctx = + new TestIncrementalBuildContext( unitDirectory, changedFiles, Collections.emptyMap() ); ThreadBuildContext.setThreadBuildContext( ctx ); filter( "notime" ); @@ -141,10 +142,10 @@ filter( "time" ); // all files are reprocessed after content of filters changes - HashSet deletedFiles = new HashSet(); + Set deletedFiles = new HashSet(); deletedFiles.add( "filters.txt" ); - TestIncrementalBuildContext ctx = - new TestIncrementalBuildContext( unitDirectory, new HashSet(), deletedFiles, new HashMap() ); + TestIncrementalBuildContext ctx = new TestIncrementalBuildContext( unitDirectory, Collections.emptySet(), + deletedFiles, Collections.emptyMap() ); ThreadBuildContext.setThreadBuildContext( ctx ); filter( "notime" ); @@ -174,7 +175,7 @@ } private void filter( String time ) - throws Exception, MavenFilteringException + throws Exception { File baseDir = new File( getBasedir() ); StubMavenProject mavenProject = new StubMavenProject( baseDir ); @@ -186,22 +187,30 @@ projectProperties.put( "time", time ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = - (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = new File( unitDirectory, "files" ).getPath(); Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); + List filtersFile = new ArrayList(); filtersFile.add( new File( unitDirectory, "filters.txt" ).getPath() ); - mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, - new ArrayList(), new StubMavenSession() ); + MavenResourcesExecution mre = new MavenResourcesExecution(); + mre.setResources( resources ); + mre.setOutputDirectory( outputDirectory ); + mre.setEncoding( "UTF-8" ); + mre.setMavenProject( mavenProject ); + mre.setFilters( filtersFile ); + mre.setNonFilteredFileExtensions( Collections.emptyList() ); + mre.setMavenSession( new StubMavenSession() ); + mre.setUseDefaultFilterWrappers( true ); + + mavenResourcesFiltering.filterResources( mre ); } } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEndingTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEndingTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEndingTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/InterpolatorFilterReaderLineEndingTest.java 2015-06-14 17:09:05.000000000 +0000 @@ -0,0 +1,58 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.Reader; + +import org.codehaus.plexus.interpolation.Interpolator; + +public class InterpolatorFilterReaderLineEndingTest + extends AbstractInterpolatorFilterReaderLineEndingTest +{ + @Override + protected Reader getAaa_AaaReader( Reader in, Interpolator interpolator ) + { + return new InterpolatorFilterReaderLineEnding( in, interpolator, "aaa", "aaa", true ); + } + + @Override + protected Reader getAbc_AbcReader( Reader in, Interpolator interpolator ) + { + return new InterpolatorFilterReaderLineEnding( in, interpolator, "abc", "abc", true ); + } + + @Override + protected Reader getDollarBracesReader( Reader in, Interpolator interpolator, String escapeString ) + { + InterpolatorFilterReaderLineEnding reader = + new InterpolatorFilterReaderLineEnding( in, interpolator, "${", "}", true ); + reader.setEscapeString( escapeString ); + return reader; + } + + @Override + protected Reader getAtReader( Reader in, Interpolator interpolator, String escapeString ) + { + InterpolatorFilterReaderLineEnding reader = + new InterpolatorFilterReaderLineEnding( in, interpolator, "@", "@", true ); + reader.setEscapeString( escapeString ); + return reader; + } +} diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/InvalidMarkTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -0,0 +1,72 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import java.io.File; +import java.util.Collections; + +import org.apache.maven.model.Resource; +import org.apache.maven.shared.utils.io.FileUtils; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Mikolaj Izdebski + */ +public class InvalidMarkTest + extends PlexusTestCase +{ + File outputDirectory = new File( getBasedir(), "target/LongLineTest" ); + + protected void setUp() + throws Exception + { + super.setUp(); + if ( outputDirectory.exists() ) + { + FileUtils.forceDelete( outputDirectory ); + } + outputDirectory.mkdirs(); + } + + public void testEscape() + throws Exception + { + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); + + Resource resource = new Resource(); + resource.setDirectory( "src/test/units-files/MSHARED-325" ); + resource.setFiltering( true ); + + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( Collections.singletonList( resource ), outputDirectory, + new StubMavenProject( new File( "." ) ), "UTF-8", + Collections.emptyList(), Collections.emptyList(), + new StubMavenSession() ); + + try + { + mavenResourcesFiltering.filterResources( mavenResourcesExecution ); + } + catch ( MavenFilteringException e ) + { + fail(); + } + } +} diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java 2010-12-22 18:42:50.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/MuliLinesMavenResourcesFilteringTest.java 2015-11-06 20:28:40.000000000 +0000 @@ -27,15 +27,13 @@ import java.util.Properties; import org.apache.maven.model.Resource; +import org.apache.maven.shared.utils.io.FileUtils; +import org.apache.maven.shared.utils.io.IOUtil; import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; /** - * @author olamy - * - * - * @version $Id: MuliLinesMavenResourcesFilteringTest.java 1052026 2010-12-22 18:42:50Z olamy $ + * @author Olivier Lamy + * @version $Id: MuliLinesMavenResourcesFilteringTest.java 1713023 2015-11-06 20:28:40Z khmarbaise $ */ public class MuliLinesMavenResourcesFilteringTest extends PlexusTestCase @@ -55,7 +53,6 @@ } /** - * * @throws Exception */ public void testFilteringTokenOnce() @@ -71,29 +68,26 @@ projectProperties.put( "foo", "bar" ); projectProperties.put( "java.version", "zloug" ); mavenProject.setProperties( projectProperties ); - MavenResourcesFiltering mavenResourcesFiltering = (MavenResourcesFiltering) lookup( MavenResourcesFiltering.class.getName() ); + MavenResourcesFiltering mavenResourcesFiltering = lookup( MavenResourcesFiltering.class ); String unitFilesDir = getBasedir() + "/src/test/units-files/MRESOURCES-104"; Resource resource = new Resource(); - List resources = new ArrayList(); + List resources = new ArrayList(); resources.add( resource ); resource.setDirectory( unitFilesDir ); resource.setFiltering( true ); - List filtersFile = new ArrayList(); + List filtersFile = new ArrayList(); filtersFile.add( getBasedir() + "/src/test/units-files/MRESOURCES-104/test.properties" ); - List nonFilteredFileExtensions = Collections.singletonList( "gif" ); + List nonFilteredFileExtensions = Collections.singletonList( "gif" ); - MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources, outputDirectory, - mavenProject, "UTF-8", - filtersFile, - nonFilteredFileExtensions, - new StubMavenSession() ); + MavenResourcesExecution mavenResourcesExecution = + new MavenResourcesExecution( resources, outputDirectory, mavenProject, "UTF-8", filtersFile, + nonFilteredFileExtensions, new StubMavenSession() ); mavenResourcesExecution.setUseDefaultFilterWrappers( true ); - - + mavenResourcesFiltering.filterResources( mavenResourcesExecution ); Properties result = new Properties(); @@ -107,11 +101,10 @@ { IOUtil.close( in ); } - - System.out.println("properties " + result.toString()); - //email=foo@bar.com - //foo=${project.version} - //bar=@project.version@ + + // email=foo@bar.com + // foo=${project.version} + // bar=@project.version@ assertEquals( "1.0", result.get( "foo" ) ); assertEquals( "1.0", result.get( "bar" ) ); assertEquals( "foo@bar.com", result.get( "email" ) ); diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/MultiDelimiterInterpolatorFilterReaderLineEndingTest.java 2015-06-14 17:09:05.000000000 +0000 @@ -0,0 +1,124 @@ +package org.apache.maven.shared.filtering; + +/* + * 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. + */ + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.eq; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.when; + +import java.io.Reader; +import java.io.StringReader; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; + +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.util.IOUtil; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public class MultiDelimiterInterpolatorFilterReaderLineEndingTest + extends AbstractInterpolatorFilterReaderLineEndingTest +{ + + @Mock + private Interpolator interpolator; + + @Before + public void onSetup() + { + MockitoAnnotations.initMocks( this ); + } + + @Override + protected Reader getAaa_AaaReader( Reader in, Interpolator interpolator ) + { + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setDelimiterSpecs( Collections.singleton( "aaa*aaa" ) ); + return reader; + } + + @Override + protected Reader getAbc_AbcReader( Reader in, Interpolator interpolator ) + { + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setDelimiterSpecs( Collections.singleton( "abc*abc" ) ); + return reader; + } + + @Override + protected Reader getDollarBracesReader( Reader in, Interpolator interpolator, String escapeString ) + { + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setDelimiterSpecs( Collections.singleton( "${*}" ) ); + reader.setEscapeString( escapeString ); + return reader; + } + + @Override + protected Reader getAtReader( Reader in, Interpolator interpolator, String escapeString ) + { + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setDelimiterSpecs( Collections.singleton( "@" ) ); + reader.setEscapeString( escapeString ); + return reader; + } + + // MSHARED-199: Filtering doesn't work if 2 delimiters are used on the same line, the first one being left open + @Test + public void testLineWithSingleAtAndExpression() + throws Exception + { + when( interpolator.interpolate( eq( "${foo}" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "bar" ); + + Reader in = new StringReader( "toto@titi.com ${foo}" ); + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setDelimiterSpecs( new HashSet( Arrays.asList( "${*}", "@" ) ) ); + + assertEquals( "toto@titi.com bar", IOUtil.toString( reader ) ); + } + + // http://stackoverflow.com/questions/21786805/maven-war-plugin-customize-filter-delimitters-in-webresources/ + @Test + public void testAtDollarExpression() + throws Exception + { + when( interpolator.interpolate( eq( "${db.server}" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DB_SERVER" ); + when( interpolator.interpolate( eq( "${db.port}" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DB_PORT" ); + when( interpolator.interpolate( eq( "${db.name}" ), eq( "" ), isA( RecursionInterceptor.class ) ) ).thenReturn( "DB_NAME" ); + + Reader in = new StringReader( " url=\"jdbc:oracle:thin:\\@${db.server}:${db.port}:${db.name}\"" ); + MultiDelimiterInterpolatorFilterReaderLineEnding reader = + new MultiDelimiterInterpolatorFilterReaderLineEnding( in, interpolator, true ); + reader.setEscapeString( "\\" ); + reader.setDelimiterSpecs( new HashSet( Arrays.asList( "${*}", "@" ) ) ); + + assertEquals( " url=\"jdbc:oracle:thin:@DB_SERVER:DB_PORT:DB_NAME\"", IOUtil.toString( reader ) ); + } +} diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/PropertyUtilsTest.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/PropertyUtilsTest.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/PropertyUtilsTest.java 2011-01-13 18:29:54.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/PropertyUtilsTest.java 2012-09-20 09:12:14.000000000 +0000 @@ -26,9 +26,9 @@ import org.codehaus.plexus.PlexusTestCase; /** - * @author olamy + * @author Olivier Lamy * @since 1.0-beta-1 - * @version $Id: PropertyUtilsTest.java 1058704 2011-01-13 18:29:54Z dennisl $ + * @version $Id: PropertyUtilsTest.java 1387923 2012-09-20 09:12:14Z olamy $ */ public class PropertyUtilsTest extends PlexusTestCase diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenProject.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenProject.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenProject.java 2011-01-13 18:29:54.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenProject.java 2014-10-17 15:36:52.000000000 +0000 @@ -25,22 +25,22 @@ import org.apache.maven.project.MavenProject; /** - * @author olamy + * @author Olivier Lamy * @since 1.0-beta-1 - * @version $Id: StubMavenProject.java 1058704 2011-01-13 18:29:54Z dennisl $ + * @version $Id: StubMavenProject.java 1632611 2014-10-17 15:36:52Z khmarbaise $ */ public class StubMavenProject extends MavenProject { private Properties properties; - + private File basedir; - protected StubMavenProject (File basedir) + protected StubMavenProject( File basedir ) { this.basedir = basedir; } - + public Properties getProperties() { return this.properties; @@ -51,19 +51,18 @@ this.properties = properties; } - public void addProperty(String key, String value) + public void addProperty( String key, String value ) { - if (this.properties == null) + if ( this.properties == null ) { this.properties = new Properties(); } this.properties.put( key, value ); } - + public File getBasedir() { return basedir; } - } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenSession.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenSession.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenSession.java 2011-01-13 18:29:54.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/StubMavenSession.java 2016-05-21 10:50:39.000000000 +0000 @@ -21,58 +21,78 @@ import java.util.Properties; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.settings.Settings; +import org.codehaus.plexus.PlexusContainer; +import org.sonatype.aether.RepositorySystemSession; /** - * @author olamy + * @author Olivier Lamy * @since 1.0-beta-1 - * @version $Id: StubMavenSession.java 1058704 2011-01-13 18:29:54Z dennisl $ + * @version $Id: StubMavenSession.java 1744899 2016-05-21 10:50:39Z khmarbaise $ */ public class StubMavenSession extends MavenSession { - private Properties executionProperties; - + private Properties userProperties; + + private Properties systemProperties; + private final Settings settings; - + public StubMavenSession( Settings settings ) { - this( null, settings ); + this( null, null, settings ); } public StubMavenSession() { - this( null, null ); + this( null, null, null ); } - public StubMavenSession( Properties executionProperties ) + public StubMavenSession( Properties userProperties ) { - this( executionProperties, null ); + this( null, userProperties, null ); } - - public StubMavenSession( Properties executionProperties, Settings settings ) + + public StubMavenSession( Properties systemProperties, Properties userProperties, Settings settings ) { - super( null, null, null, null, null, null, null, null, null ); - + + super( (PlexusContainer) null, (RepositorySystemSession) null, new DefaultMavenExecutionRequest(), + (MavenExecutionResult) null ); + this.settings = settings; - this.executionProperties = new Properties(); - if ( executionProperties != null ) + + this.systemProperties = new Properties(); + if ( systemProperties != null ) { - this.executionProperties.putAll( executionProperties ); + this.systemProperties.putAll( systemProperties ); + } + this.systemProperties.putAll( System.getProperties() ); + + this.userProperties = new Properties(); + if ( userProperties != null ) + { + this.userProperties.putAll( userProperties ); } - this.executionProperties.putAll( System.getProperties() ); } - + public Settings getSettings() { return settings; } - public Properties getExecutionProperties() + public Properties getSystemProperties() + { + return this.systemProperties; + } + + public Properties getUserProperties() { - return this.executionProperties; + return this.userProperties; } } diff -Nru maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/TestReflectionProperties.java maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/TestReflectionProperties.java --- maven-filtering-1.1/src/test/java/org/apache/maven/shared/filtering/TestReflectionProperties.java 2011-01-13 18:29:54.000000000 +0000 +++ maven-filtering-3.1.1/src/test/java/org/apache/maven/shared/filtering/TestReflectionProperties.java 2016-05-21 10:50:39.000000000 +0000 @@ -27,9 +27,9 @@ import org.codehaus.plexus.PlexusTestCase; /** - * @author olamy + * @author Olivier Lamy * @since 1.0-beta-1 - * @version $Id: TestReflectionProperties.java 1058704 2011-01-13 18:29:54Z dennisl $ + * @version $Id: TestReflectionProperties.java 1744899 2016-05-21 10:50:39Z khmarbaise $ */ public class TestReflectionProperties extends PlexusTestCase @@ -44,20 +44,20 @@ MavenProject mavenProject = new MavenProject(); mavenProject.setVersion( "1.0" ); mavenProject.setGroupId( "org.apache" ); - Properties executionProperties = new Properties(); - executionProperties.setProperty( "foo", "bar" ); - MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" ); + Properties userProperties = new Properties(); + userProperties.setProperty( "foo", "bar" ); + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); File from = new File( getBasedir() + "/src/test/units-files/reflection-test.properties" ); File to = new File( getBasedir() + "/target/reflection-test.properties" ); - if (to.exists()) + if ( to.exists() ) { to.delete(); - } - + } + mavenFileFilter.copyFile( from, to, true, mavenProject, null, false, null, - new StubMavenSession( executionProperties ) ); + new StubMavenSession( userProperties ) ); Properties reading = new Properties(); readFileInputStream = new FileInputStream( to ); @@ -86,20 +86,20 @@ MavenProject mavenProject = new MavenProject(); mavenProject.setVersion( "1.0" ); mavenProject.setGroupId( "org.apache" ); - Properties executionProperties = new Properties(); - executionProperties.setProperty( "foo", "bar" ); - MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" ); + Properties userProperties = new Properties(); + userProperties.setProperty( "foo", "bar" ); + MavenFileFilter mavenFileFilter = lookup( MavenFileFilter.class ); File from = new File( getBasedir() + "/src/test/units-files/reflection-test.properties" ); File to = new File( getBasedir() + "/target/reflection-test.properties" ); - if (to.exists()) + if ( to.exists() ) { to.delete(); } - + mavenFileFilter.copyFile( from, to, false, mavenProject, null, false, null, - new StubMavenSession( executionProperties ) ); + new StubMavenSession( userProperties ) ); Properties reading = new Properties(); readFileInputStream = new FileInputStream( to ); @@ -117,6 +117,6 @@ } } - } - + } + } diff -Nru maven-filtering-1.1/src/test/resources/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.xml maven-filtering-3.1.1/src/test/resources/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.xml --- maven-filtering-1.1/src/test/resources/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.xml 2009-02-14 22:26:30.000000000 +0000 +++ maven-filtering-3.1.1/src/test/resources/org/apache/maven/shared/filtering/IncrementalResourceFilteringTest.xml 2013-09-15 19:06:47.000000000 +0000 @@ -1,3 +1,21 @@ + diff -Nru maven-filtering-1.1/src/test/units-files/escape-remove-char/content.xml maven-filtering-3.1.1/src/test/units-files/escape-remove-char/content.xml --- maven-filtering-1.1/src/test/units-files/escape-remove-char/content.xml 2012-06-20 15:16:28.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/escape-remove-char/content.xml 2013-09-15 19:06:47.000000000 +0000 @@ -1,4 +1,22 @@ + Why is my !\${\}\! static.content broken if the escapeString occurs ?!? diff -Nru maven-filtering-1.1/src/test/units-files/includeEmptyDirs/dir1/foo.txt maven-filtering-3.1.1/src/test/units-files/includeEmptyDirs/dir1/foo.txt --- maven-filtering-1.1/src/test/units-files/includeEmptyDirs/dir1/foo.txt 2008-09-15 22:14:51.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/includeEmptyDirs/dir1/foo.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1 +1,18 @@ +# 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. + foo. \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/incremental/files/file01.txt maven-filtering-3.1.1/src/test/units-files/incremental/files/file01.txt --- maven-filtering-1.1/src/test/units-files/incremental/files/file01.txt 2009-02-14 22:26:30.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/incremental/files/file01.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1,2 +1,19 @@ +# 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. + time=${time} foo=${foo} diff -Nru maven-filtering-1.1/src/test/units-files/incremental/files/file02.txt maven-filtering-3.1.1/src/test/units-files/incremental/files/file02.txt --- maven-filtering-1.1/src/test/units-files/incremental/files/file02.txt 2009-02-14 22:26:30.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/incremental/files/file02.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1,2 +1,19 @@ +# 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. + time=${time} foo=${foo} diff -Nru maven-filtering-1.1/src/test/units-files/incremental/filters.txt maven-filtering-3.1.1/src/test/units-files/incremental/filters.txt --- maven-filtering-1.1/src/test/units-files/incremental/filters.txt 2009-02-14 22:26:30.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/incremental/filters.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1 +1,18 @@ +# 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. + foo=bar\ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/maven-filename-filtering/${pom.version}.txt maven-filtering-3.1.1/src/test/units-files/maven-filename-filtering/${pom.version}.txt --- maven-filtering-1.1/src/test/units-files/maven-filename-filtering/${pom.version}.txt 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-filename-filtering/${pom.version}.txt 2014-02-14 17:28:06.000000000 +0000 @@ -0,0 +1,16 @@ +# 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. diff -Nru maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludedir/bar.txt maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludedir/bar.txt --- maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludedir/bar.txt 2008-08-03 11:56:41.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludedir/bar.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1 +1,18 @@ +# 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. + excluded \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludedir/foo.txt maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludedir/foo.txt --- maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludedir/foo.txt 2008-08-03 11:56:41.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludedir/foo.txt 2013-09-15 19:06:47.000000000 +0000 @@ -1 +1,18 @@ +# 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. + excluded \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludefile.txt maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludefile.txt --- maven-filtering-1.1/src/test/units-files/maven-resources-filtering/excludefile.txt 2008-08-03 11:56:41.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/excludefile.txt 2013-09-15 19:06:47.000000000 +0000 @@ -0,0 +1,16 @@ +# 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. diff -Nru maven-filtering-1.1/src/test/units-files/maven-resources-filtering/includedir/include.txt maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/includedir/include.txt --- maven-filtering-1.1/src/test/units-files/maven-resources-filtering/includedir/include.txt 2008-08-03 11:56:41.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/includedir/include.txt 2013-09-15 19:06:47.000000000 +0000 @@ -0,0 +1,16 @@ +# 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. diff -Nru maven-filtering-1.1/src/test/units-files/maven-resources-filtering/includefile.txt maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/includefile.txt --- maven-filtering-1.1/src/test/units-files/maven-resources-filtering/includefile.txt 2008-08-03 11:56:41.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/maven-resources-filtering/includefile.txt 2013-09-15 19:06:47.000000000 +0000 @@ -0,0 +1,16 @@ +# 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. diff -Nru maven-filtering-1.1/src/test/units-files/MRESOURCES-104/test.properties maven-filtering-3.1.1/src/test/units-files/MRESOURCES-104/test.properties --- maven-filtering-1.1/src/test/units-files/MRESOURCES-104/test.properties 2010-12-22 18:42:50.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/MRESOURCES-104/test.properties 2013-09-15 19:06:47.000000000 +0000 @@ -1,3 +1,20 @@ +# 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. + email=foo@bar.com foo=${project.version} bar=@project.version@ diff -Nru maven-filtering-1.1/src/test/units-files/MSHARED-161/src/main/filters/buildfilter.properties maven-filtering-3.1.1/src/test/units-files/MSHARED-161/src/main/filters/buildfilter.properties --- maven-filtering-1.1/src/test/units-files/MSHARED-161/src/main/filters/buildfilter.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/MSHARED-161/src/main/filters/buildfilter.properties 2014-02-09 18:39:10.000000000 +0000 @@ -0,0 +1,19 @@ +#/* +# * 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. +# */ +buildfilter=true \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/MSHARED-161/src/main/filters/filefilter.properties maven-filtering-3.1.1/src/test/units-files/MSHARED-161/src/main/filters/filefilter.properties --- maven-filtering-1.1/src/test/units-files/MSHARED-161/src/main/filters/filefilter.properties 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/MSHARED-161/src/main/filters/filefilter.properties 2014-02-09 18:39:10.000000000 +0000 @@ -0,0 +1,19 @@ +#/* +# * 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. +# */ +filefilter=true \ No newline at end of file diff -Nru maven-filtering-1.1/src/test/units-files/MSHARED-325/payload maven-filtering-3.1.1/src/test/units-files/MSHARED-325/payload --- maven-filtering-1.1/src/test/units-files/MSHARED-325/payload 1970-01-01 00:00:00.000000000 +0000 +++ maven-filtering-3.1.1/src/test/units-files/MSHARED-325/payload 2014-10-15 18:20:23.000000000 +0000 @@ -0,0 +1,19 @@ +/* + * 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. + */ +@").replace(p,"]").replace(q, \ No newline at end of file