* So, the default filtering delimiters might be specified as: *
- * + * ** <delimiters> * <delimiter>${*}</delimiter> @@ -258,11 +259,6 @@ public class ResourcesMojo @Parameter private ListmavenFilteringHints; - /** - * @since 2.4 - */ - private PlexusContainer plexusContainer; - /** * @since 2.4 */ @@ -278,7 +274,7 @@ public class ResourcesMojo /** * Support filtering of filenames folders etc. - * + * * @since 3.0.0 */ @Parameter( defaultValue = "false" ) @@ -287,22 +283,17 @@ public class ResourcesMojo /** * You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on * occasion. - * + * * @since 3.0.0 */ @Parameter( property = "maven.resources.skip", defaultValue = "false" ) private boolean skip; - /** {@inheritDoc} */ - public void contextualize( Context context ) - throws ContextException - { - plexusContainer = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - } - - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ public void execute() - throws MojoExecutionException + throws MojoExecutionException { if ( isSkip() ) { @@ -313,8 +304,8 @@ public void execute() if ( StringUtils.isBlank( encoding ) && isFilteringEnabled( getResources() ) ) { getLog().warn( "File encoding has not been set, using platform encoding " - + System.getProperty( "file.encoding" ) - + ". Build is platform dependent!" ); + + System.getProperty( "file.encoding" ) + + ". Build is platform dependent!" ); getLog().warn( "See https://maven.apache.org/general.html#encoding-warning" ); } @@ -323,8 +314,9 @@ public void execute() List combinedFilters = getCombinedFiltersList(); MavenResourcesExecution mavenResourcesExecution = - new MavenResourcesExecution( getResources(), getOutputDirectory(), project, encoding, combinedFilters, - Collections.emptyList(), session ); + new MavenResourcesExecution( getResources(), getOutputDirectory(), project, encoding, + combinedFilters, + Collections.emptyList(), session ); mavenResourcesExecution.setEscapeWindowsPaths( escapeWindowsPaths ); @@ -371,10 +363,10 @@ public void execute() * can't be found in the context which can be got from the maven core.
* A solution could be to put those values into the context by Maven core so they are accessible everywhere. (I'm * not sure if this is a good idea). Better ideas are always welcome. - * - * The problem at the moment is that maven core handles usage of properties and replacements in + *+ * The problem at the moment is that maven core handles usage of properties and replacements in * the model, but does not the resource filtering which needed some of the properties. - * + * * @return the new instance with those properties. */ private Properties addSeveralSpecialProperties() @@ -391,35 +383,36 @@ private Properties addSeveralSpecialProperties() } /** - * @param mavenResourcesExecution {@link MavenResourcesExecution} - * @throws MojoExecutionException in case of wrong lookup. + * @param mavenResourcesExecution {@link MavenResourcesExecution} + * @throws MojoExecutionException in case of wrong lookup. * @throws MavenFilteringException in case of failure. * @since 2.5 */ protected void executeUserFilterComponents( MavenResourcesExecution mavenResourcesExecution ) - throws MojoExecutionException, MavenFilteringException + throws MojoExecutionException, MavenFilteringException { if ( mavenFilteringHints != null ) { for ( String hint : mavenFilteringHints ) { - try + MavenResourcesFiltering userFilterComponent = mavenResourcesFilteringMap.get( hint ); + if ( userFilterComponent != null ) { - // CHECKSTYLE_OFF: LineLength - mavenFilteringComponents.add( (MavenResourcesFiltering) plexusContainer.lookup( MavenResourcesFiltering.class.getName(), - hint ) ); - // CHECKSTYLE_ON: LineLength + getLog().debug( "added user filter component with hint: " + hint ); + mavenFilteringComponents.add( userFilterComponent ); } - catch ( ComponentLookupException e ) + else { - throw new MojoExecutionException( e.getMessage(), e ); + throw new MojoExecutionException( + "User filter with hint `" + hint + "` requested, but not present. Discovered filters are: " + + mavenResourcesFilteringMap.keySet() ); } } } else { - getLog().debug( "no use filter components" ); + getLog().debug( "no user filter components" ); } if ( mavenFilteringComponents != null && !mavenFilteringComponents.isEmpty() ) diff --git a/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java b/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java index adaf44c..a1865e4 100644 --- a/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java +++ b/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java @@ -18,6 +18,9 @@ */ package org.apache.maven.plugins.resources.filters; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -28,14 +31,14 @@ import org.apache.maven.shared.filtering.MavenFilteringException; import org.apache.maven.shared.filtering.MavenResourcesExecution; import org.apache.maven.shared.filtering.MavenResourcesFiltering; -import org.codehaus.plexus.component.annotations.Component; /** * @author Olivier Lamy * @since 2.5 * @version $Id$ */ -@Component(role = org.apache.maven.shared.filtering.MavenResourcesFiltering.class, hint = "itFilter") +@Singleton +@Named("itFilter") public class ItFilter implements MavenResourcesFiltering {