本文整理汇总了Java中org.apache.maven.shared.filtering.MavenResourcesFiltering.filterResources方法的典型用法代码示例。如果您正苦于以下问题:Java MavenResourcesFiltering.filterResources方法的具体用法?Java MavenResourcesFiltering.filterResources怎么用?Java MavenResourcesFiltering.filterResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.filtering.MavenResourcesFiltering
的用法示例。
在下文中一共展示了MavenResourcesFiltering.filterResources方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeUserFilterComponents
import org.apache.maven.shared.filtering.MavenResourcesFiltering; //导入方法依赖的package包/类
protected void executeUserFilterComponents(MavenResourcesExecution mavenResourcesExecution)
throws MojoExecutionException, MavenFilteringException {
if (mavenFilteringHints != null) {
for (String hint : mavenFilteringHints) {
try {
mavenFilteringComponents.add((MavenResourcesFiltering) plexusContainer
.lookup(MavenResourcesFiltering.class.getName(), hint));
} catch (ComponentLookupException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
} else {
getLog().debug("no use filter components");
}
if (mavenFilteringComponents != null && !mavenFilteringComponents.isEmpty()) {
getLog().debug("execute user filters");
for (MavenResourcesFiltering filter : mavenFilteringComponents) {
filter.filterResources(mavenResourcesExecution);
}
}
}
示例2: filterAndCopy
import org.apache.maven.shared.filtering.MavenResourcesFiltering; //导入方法依赖的package包/类
private static void filterAndCopy(AbstractWisdomMojo mojo, MavenResourcesFiltering filtering, File in, File out) throws IOException {
Resource resource = new Resource();
resource.setDirectory(in.getAbsolutePath());
resource.setFiltering(true);
resource.setTargetPath(out.getAbsolutePath());
List<String> excludedExtensions = new ArrayList<>();
excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);
MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), out, mojo.project,
"UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
exec.setEscapeString("\\");
try {
filtering.filterResources(exec);
} catch (MavenFilteringException e) {
throw new IOException("Error while copying resources", e);
}
}
示例3: executeUserFilterComponents
import org.apache.maven.shared.filtering.MavenResourcesFiltering; //导入方法依赖的package包/类
/**
* @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 {
if (mavenFilteringHints != null) {
for (String hint : mavenFilteringHints) {
try {
// CHECKSTYLE_OFF: LineLength
mavenFilteringComponents.add((MavenResourcesFiltering) plexusContainer.lookup(MavenResourcesFiltering.class.getName(), hint));
// CHECKSTYLE_ON: LineLength
} catch (ComponentLookupException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
} else {
getLog().debug("no use filter components");
}
if (mavenFilteringComponents != null && !mavenFilteringComponents.isEmpty()) {
getLog().debug("execute user filters");
for (MavenResourcesFiltering filter : mavenFilteringComponents) {
filter.filterResources(mavenResourcesExecution);
}
}
}
示例4: copyResources
import org.apache.maven.shared.filtering.MavenResourcesFiltering; //导入方法依赖的package包/类
/**
* Copy resources to target directory using Maven resource filtering so that we don't have to handle
* recursive directory listing and pattern matching.
* In order to disable filtering, the "filtering" property is force set to False.
*
* @param project
* @param session
* @param filtering
* @param resources
* @param targetDirectory
* @throws IOException
*/
public static void copyResources(final MavenProject project, final MavenSession session,
final MavenResourcesFiltering filtering, final List<Resource> resources,
final String targetDirectory) throws IOException {
for (final Resource resource : resources) {
resource.setTargetPath(Paths.get(targetDirectory, resource.getTargetPath()).toString());
resource.setFiltering(false);
}
final MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
resources,
new File(targetDirectory),
project,
"UTF-8",
null,
Collections.EMPTY_LIST,
session
);
// Configure executor
mavenResourcesExecution.setEscapeWindowsPaths(true);
mavenResourcesExecution.setInjectProjectBuildFilters(false);
mavenResourcesExecution.setOverwrite(true);
mavenResourcesExecution.setIncludeEmptyDirs(false);
mavenResourcesExecution.setSupportMultiLineFiltering(false);
// Filter resources
try {
filtering.filterResources(mavenResourcesExecution);
} catch (MavenFilteringException ex) {
throw new IOException("Failed to copy resources", ex);
}
}
示例5: copyFileToDir
import org.apache.maven.shared.filtering.MavenResourcesFiltering; //导入方法依赖的package包/类
/**
* Copies the file <tt>file</tt> to the directory <tt>dir</tt>, keeping the structure relative to <tt>rel</tt>.
*
* @param file the file to copy
* @param rel the base 'relative'
* @param dir the directory
* @param mojo the mojo
* @param filtering the filtering component
* @param additionalProperties additional properties
* @throws IOException if the file cannot be copied.
*/
public static void copyFileToDir(File file, File rel, File dir, AbstractWisdomMojo mojo, MavenResourcesFiltering
filtering, Properties additionalProperties) throws
IOException {
if (filtering == null) {
File out = computeRelativeFile(file, rel, dir);
if (out.getParentFile() != null) {
mojo.getLog().debug("Creating " + out.getParentFile() + " : " + out.getParentFile().mkdirs());
FileUtils.copyFileToDirectory(file, out.getParentFile());
} else {
throw new IOException("Cannot copy file - parent directory not accessible for "
+ file.getAbsolutePath());
}
} else {
Resource resource = new Resource();
resource.setDirectory(rel.getAbsolutePath());
resource.setFiltering(true);
resource.setTargetPath(dir.getAbsolutePath());
resource.setIncludes(ImmutableList.of("**/" + file.getName()));
List<String> excludedExtensions = new ArrayList<>();
excludedExtensions.addAll(filtering.getDefaultNonFilteredFileExtensions());
excludedExtensions.addAll(NON_FILTERED_EXTENSIONS);
MavenResourcesExecution exec = new MavenResourcesExecution(ImmutableList.of(resource), dir, mojo.project,
"UTF-8", Collections.<String>emptyList(), excludedExtensions, mojo.session);
if (additionalProperties != null) {
exec.setAdditionalProperties(additionalProperties);
}
exec.setEscapeString("\\");
try {
filtering.filterResources(exec);
} catch (MavenFilteringException e) {
throw new IOException("Error while copying resources", e);
}
}
}