Class DefaultMavenResourcesFiltering
- java.lang.Object
-
- org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering
-
- All Implemented Interfaces:
MavenResourcesFiltering
@Singleton @Named public class DefaultMavenResourcesFiltering extends java.lang.Object implements MavenResourcesFiltering
-
-
Field Summary
Fields Modifier and Type Field Description private org.sonatype.plexus.build.incremental.BuildContextbuildContextprivate static java.lang.String[]DEFAULT_INCLUDESprivate java.util.List<java.lang.String>defaultNonFilteredFileExtensionsprivate static java.lang.String[]EMPTY_STRING_ARRAYprivate static org.slf4j.LoggerLOGGERprivate MavenFileFiltermavenFileFilter
-
Constructor Summary
Constructors Constructor Description DefaultMavenResourcesFiltering(MavenFileFilter mavenFileFilter, org.sonatype.plexus.build.incremental.BuildContext buildContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcopyDirectoryLayout(java.io.File sourceDirectory, java.io.File destinationDirectory, org.codehaus.plexus.util.Scanner scanner)booleanfilteredFileExtension(java.lang.String fileName, java.util.List<java.lang.String> userNonFilteredFileExtensions)private java.lang.StringfilterFileName(java.lang.String name, java.util.List<FilterWrapper> wrappers)voidfilterResources(MavenResourcesExecution mavenResourcesExecution)java.util.List<java.lang.String>getDefaultNonFilteredFileExtensions()return the List of the non filtered extensions (jpg,jpeg,gif,bmp,png,ico)private java.io.FilegetDestinationFile(java.io.File outputDirectory, java.lang.String targetPath, java.lang.String name, MavenResourcesExecution mavenResourcesExecution)(package private) static java.lang.StringgetEncoding(java.io.File file, java.lang.String encoding, java.lang.String propertiesEncoding)Get the encoding to use when filtering the specified file.private static java.lang.StringgetExtension(java.lang.String fileName)private java.lang.StringgetRelativeOutputDirectory(MavenResourcesExecution execution)private voidhandleDefaultFilterWrappers(MavenResourcesExecution mavenResourcesExecution)(package private) static booleanisPropertiesFile(java.io.File file)Determine whether a file is a properties file or not.private java.lang.String[]setupScanner(org.apache.maven.model.Resource resource, org.codehaus.plexus.util.Scanner scanner, boolean addDefaultExcludes)
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
EMPTY_STRING_ARRAY
private static final java.lang.String[] EMPTY_STRING_ARRAY
-
DEFAULT_INCLUDES
private static final java.lang.String[] DEFAULT_INCLUDES
-
defaultNonFilteredFileExtensions
private final java.util.List<java.lang.String> defaultNonFilteredFileExtensions
-
mavenFileFilter
private final MavenFileFilter mavenFileFilter
-
buildContext
private final org.sonatype.plexus.build.incremental.BuildContext buildContext
-
-
Constructor Detail
-
DefaultMavenResourcesFiltering
@Inject public DefaultMavenResourcesFiltering(MavenFileFilter mavenFileFilter, org.sonatype.plexus.build.incremental.BuildContext buildContext)
-
-
Method Detail
-
filteredFileExtension
public boolean filteredFileExtension(java.lang.String fileName, java.util.List<java.lang.String> userNonFilteredFileExtensions)- Specified by:
filteredFileExtensionin interfaceMavenResourcesFiltering- Parameters:
fileName- the file nameuserNonFilteredFileExtensions- an extra list of file extensions- Returns:
- true if filtering can be applied to the file (means extensions.lowerCase is in the default List or in the user defined extension List)
-
getExtension
private static java.lang.String getExtension(java.lang.String fileName)
-
getDefaultNonFilteredFileExtensions
public java.util.List<java.lang.String> getDefaultNonFilteredFileExtensions()
Description copied from interface:MavenResourcesFilteringreturn the List of the non filtered extensions (jpg,jpeg,gif,bmp,png,ico)- Specified by:
getDefaultNonFilteredFileExtensionsin interfaceMavenResourcesFiltering- Returns:
ListofString
-
filterResources
public void filterResources(MavenResourcesExecution mavenResourcesExecution) throws MavenFilteringException
- Specified by:
filterResourcesin interfaceMavenResourcesFiltering- Parameters:
mavenResourcesExecution-MavenResourcesExecution- Throws:
MavenFilteringException- in case of failure.
-
getEncoding
static java.lang.String getEncoding(java.io.File file, java.lang.String encoding, java.lang.String propertiesEncoding)Get the encoding to use when filtering the specified file. Properties files can be configured to use a different encoding than regular files.- Parameters:
file- The file to checkencoding- The encoding to use for regular filespropertiesEncoding- The encoding to use for properties files- Returns:
- The encoding to use when filtering the specified file
- Since:
- 3.2.0
-
isPropertiesFile
static boolean isPropertiesFile(java.io.File file)
Determine whether a file is a properties file or not.- Parameters:
file- The file to check- Returns:
trueif the file name has an extension of "properties", otherwisefalse- Since:
- 3.2.0
-
handleDefaultFilterWrappers
private void handleDefaultFilterWrappers(MavenResourcesExecution mavenResourcesExecution) throws MavenFilteringException
- Throws:
MavenFilteringException
-
getDestinationFile
private java.io.File getDestinationFile(java.io.File outputDirectory, java.lang.String targetPath, java.lang.String name, MavenResourcesExecution mavenResourcesExecution) throws MavenFilteringException- Throws:
MavenFilteringException
-
setupScanner
private java.lang.String[] setupScanner(org.apache.maven.model.Resource resource, org.codehaus.plexus.util.Scanner scanner, boolean addDefaultExcludes)
-
copyDirectoryLayout
private void copyDirectoryLayout(java.io.File sourceDirectory, java.io.File destinationDirectory, org.codehaus.plexus.util.Scanner scanner) throws java.io.IOException- Throws:
java.io.IOException
-
getRelativeOutputDirectory
private java.lang.String getRelativeOutputDirectory(MavenResourcesExecution execution)
-
filterFileName
private java.lang.String filterFileName(java.lang.String name, java.util.List<FilterWrapper> wrappers) throws MavenFilteringException- Throws:
MavenFilteringException
-
-