本文整理汇总了Java中org.apache.maven.shared.filtering.MavenResourcesExecution.setEscapeString方法的典型用法代码示例。如果您正苦于以下问题:Java MavenResourcesExecution.setEscapeString方法的具体用法?Java MavenResourcesExecution.setEscapeString怎么用?Java MavenResourcesExecution.setEscapeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.filtering.MavenResourcesExecution
的用法示例。
在下文中一共展示了MavenResourcesExecution.setEscapeString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterAndCopy
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的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);
}
}
示例2: filterSourceToTemporaryDir
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
private void filterSourceToTemporaryDir( final File sourceDirectory, final File temporaryDirectory )
throws MojoExecutionException
{
List<Resource> resources = new ArrayList<Resource>();
Resource resource = new Resource();
resource.setFiltering( true );
logDebug( "Source absolute path: %s", sourceDirectory.getAbsolutePath() );
resource.setDirectory( sourceDirectory.getAbsolutePath() );
resources.add( resource );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, temporaryDirectory, project, encoding,
Collections.<String>emptyList(), Collections.<String>emptyList(), session );
mavenResourcesExecution.setInjectProjectBuildFilters( true );
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setOverwrite( overwrite );
setDelimitersForExecution( mavenResourcesExecution );
try
{
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
buildContext.addMessage( getSourceDirectory(), 1, 1, "Filtering Exception", BuildContext.SEVERITY_ERROR,
e );
throw new MojoExecutionException( e.getMessage(), e );
}
}
示例3: doCopyPreAssembleDirectory
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
protected void doCopyPreAssembleDirectory( final String targetDirectory )
throws MojoFailureException
{
// Create a Resource from the configuration source directory
Resource resource = new Resource();
resource.setDirectory( preAssembleDirectory.getAbsolutePath() );
resource.setFiltering( filterPreAssembleDirectory );
List<Resource> resources = new ArrayList<Resource>();
resources.add( resource );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, new File( targetDirectory ), mavenProject, encoding, buildFilters,
Collections.<String>emptyList(), session );
mavenResourcesExecution.setEscapeString( escapeString );
// Include empty directories, to be backwards compatible
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setUseDefaultFilterWrappers( true );
try
{
getLog().info( "Copy pre-assemble files from " + this.preAssembleDirectory.getAbsolutePath() + " to "
+ targetDirectory );
// Use a MavenResourcesFiltering component to filter and copy the configuration files
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException mfe )
{
throw new MojoFailureException( "Failed to copy/filter the configuration files." );
}
}
示例4: copyFileToDir
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的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);
}
}
}
示例5: buildWebapp
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
/**
* Builds the webapp for the specified project with the new packaging task thingy
* <p/>
* Classes, libraries and tld files are copied to the <tt>webappDirectory</tt> during this phase.
*
* @param mavenProject the maven project
* @param webapplicationDirectory the target directory
* @throws MojoExecutionException if an error occurred while packaging the webapp
* @throws MojoFailureException if an unexpected error occurred while packaging the webapp
* @throws IOException if an error occurred while copying the files
*/
@SuppressWarnings( "unchecked" )
public void buildWebapp( MavenProject mavenProject, File webapplicationDirectory )
throws MojoExecutionException, MojoFailureException, IOException
{
WebappStructure cache;
if ( useCache && cacheFile.exists() )
{
// CHECKSTYLE_OFF: LineLength
cache = new WebappStructure( mavenProject.getDependencies(), webappStructureSerialier.fromXml( cacheFile ) );
// CHECKSTYLE_ON: LineLength
}
else
{
cache = new WebappStructure( mavenProject.getDependencies(), null );
}
// CHECKSTYLE_OFF: LineLength
final long startTime = System.currentTimeMillis();
getLog().info( "Assembling webapp [" + mavenProject.getArtifactId() + "] in [" + webapplicationDirectory + "]" );
final OverlayManager overlayManager =
new OverlayManager( overlays, mavenProject, dependentWarIncludes, dependentWarExcludes,
currentProjectOverlay );
final List<WarPackagingTask> packagingTasks = getPackagingTasks( overlayManager );
// CHECKSTYLE_ON: LineLength
List<FileUtils.FilterWrapper> defaultFilterWrappers;
try
{
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
mavenResourcesExecution.setMavenProject( mavenProject );
if ( filters == null )
{
filters = getProject().getBuild().getFilters();
}
mavenResourcesExecution.setFilters( filters );
mavenResourcesExecution.setEscapedBackslashesInFilePath( escapedBackslashesInFilePath );
mavenResourcesExecution.setMavenSession( this.session );
mavenResourcesExecution.setEscapeString( this.escapeString );
mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
getLog().error( "fail to build filering wrappers " + e.getMessage() );
throw new MojoExecutionException( e.getMessage(), e );
}
final WarPackagingContext context =
new DefaultWarPackagingContext( webapplicationDirectory, cache, overlayManager, defaultFilterWrappers,
getNonFilteredFileExtensions(), filteringDeploymentDescriptors,
this.artifactFactory, resourceEncoding, useJvmChmod );
for ( WarPackagingTask warPackagingTask : packagingTasks )
{
warPackagingTask.performPackaging( context );
}
// Post packaging
final List<WarPostPackagingTask> postPackagingTasks = getPostPackagingTasks();
for ( WarPostPackagingTask task : postPackagingTasks )
{
task.performPostPackaging( context );
}
getLog().info( "Webapp assembled in [" + ( System.currentTimeMillis() - startTime ) + " msecs]" );
}
示例6: execute
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException, MojoFailureException {
try {
if (StringUtils.isEmpty(encoding) && isFilteringEnabled(getResources())) {
getLog().warn("File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!");
}
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(getResources(),
getLarStagingDir(), getProject(), encoding, filters, Collections.<String> emptyList(),
getSession());
mavenResourcesExecution.setEscapeWindowsPaths(escapeWindowsPaths);
mavenResourcesExecution.setInjectProjectBuildFilters(useBuildFilters);
mavenResourcesExecution.setEscapeString(escapeString);
mavenResourcesExecution.setOverwrite(overwrite);
mavenResourcesExecution.setIncludeEmptyDirs(includeEmptyDirs);
mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering);
// if these are NOT set, just use the defaults, which are '${*}' and
// '@'.
if (delimiters != null && !delimiters.isEmpty()) {
LinkedHashSet<String> delims = new LinkedHashSet<String>();
if (useDefaultDelimiters) {
delims.addAll(mavenResourcesExecution.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);
}
}
mavenResourcesExecution.setDelimiters(delims);
}
if (nonFilteredFileExtensions != null) {
mavenResourcesExecution.setNonFilteredFileExtensions(nonFilteredFileExtensions);
}
mavenResourcesFiltering.filterResources(mavenResourcesExecution);
executeUserFilterComponents(mavenResourcesExecution);
} catch (MavenFilteringException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
示例7: filterResources
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
protected void filterResources( File outputDirectory )
throws MojoExecutionException
{
Resource res = new Resource();
// TODO: Check how to prevent hard coding here?
res.setDirectory( getSourceDirectory().getAbsolutePath() );
res.setFiltering( true );
// TODO: Check if it makes sense to make this list configurable?
res.setIncludes( Collections.singletonList( "**/*" ) );
List<String> filtersFile = new ArrayList<String>();
MavenResourcesExecution execution =
new MavenResourcesExecution( Collections.singletonList( res ), outputDirectory, getMavenProject(),
getEncoding(), filtersFile, getNonFilteredFileExtensions(),
getMavenSession() );
execution.setEscapeString( getEscapeString() );
execution.setSupportMultiLineFiltering( isSupportMultiLineFiltering() );
execution.setIncludeEmptyDirs( isIncludeEmptyDirs() );
execution.setEscapeWindowsPaths( isEscapeWindowsPaths() );
execution.setFilterFilenames( isFileNameFiltering() );
//// execution.setFilters( filters );
//
// // TODO: Check if we need a parameter?
execution.setOverwrite( true );
execution.setDelimiters( getDelimiters(), isUseDefaultDelimiters() );
execution.setEncoding( getEncoding() );
//
// execution.setUseDefaultFilterWrappers( true );
if ( getNonFilteredFileExtensions() != null )
{
execution.setNonFilteredFileExtensions( getNonFilteredFileExtensions() );
}
try
{
mavenResourcesFiltering.filterResources( execution );
}
catch ( MavenFilteringException e )
{
getLog().error( "Failure during filtering.", e );
throw new MojoExecutionException( "Failure during filtering", e );
}
}
示例8: doCopyConfigurationDirectory
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
protected void doCopyConfigurationDirectory( final String targetDirectory )
throws MojoFailureException
{
getLog().debug( "copying configuration directory." );
// Create a Resource from the configuration source directory
Resource resource = new Resource();
resource.setDirectory( configurationSourceDirectory.getAbsolutePath() );
resource.setFiltering( filterConfigurationDirectory );
resource.setTargetPath( configurationDirectory );
List<Resource> resources = new ArrayList<Resource>();
resources.add( resource );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, new File( targetDirectory ), mavenProject, encoding, buildFilters,
Collections.<String>emptyList(), session );
mavenResourcesExecution.setEscapeString( escapeString );
// Include empty directories, to be backwards compatible
mavenResourcesExecution.setIncludeEmptyDirs( true );
mavenResourcesExecution.setUseDefaultFilterWrappers( true );
// @todo Possible future enhancements
// mavenResourcesExecution.setEscapedBackslashesInFilePath( escapedBackslashesInFilePath );
// mavenResourcesExecution.setOverwrite( overwrite );
// mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
try
{
getLog().debug( "Will try to copy configuration files from "
+ configurationSourceDirectory.getAbsolutePath() + " to " + targetDirectory
+ FileUtils.FS + configurationDirectory );
// Use a MavenResourcesFiltering component to filter and copy the configuration files
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException mfe )
{
throw new MojoFailureException( "Failed to copy/filter the configuration files." );
}
}
示例9: execute
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException
{
if ( skipPoms && "pom".equals( project.getPackaging() ) )
{
getLog().debug(
"Skipping a POM project type. Change a `skipPoms` to false to run anyway." );
return;
}
try
{
copied = 0;
File sourceDirectory = getSourceDirectory();
getLog().debug( "source=" + sourceDirectory + " target=" + getOutputDirectory() );
if ( !(sourceDirectory != null && sourceDirectory.exists()) )
{
getLog().info(
"Request to add '" + sourceDirectory + "' folder. Not added since it does not exist." );
return;
}
// 1 Copy with filtering the given source to target dir
List<Resource> resources = new ArrayList<Resource>();
Resource resource = new Resource();
resource.setFiltering( true );
getLog().debug( sourceDirectory.getAbsolutePath() );
resource.setDirectory( sourceDirectory.getAbsolutePath() );
resources.add( resource );
Path basedir = project.getBasedir().getCanonicalFile().toPath();
String target = project.getBuild().getDirectory();
File tmp = basedir.resolve( target ).resolve( "templates-tmp" ).toFile();
MavenResourcesExecution mavenResourcesExecution
= new MavenResourcesExecution( resources, tmp, project, encoding, Collections.emptyList(),
Collections.<String>emptyList(), session );
mavenResourcesExecution.setInjectProjectBuildFilters( false );
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setOverwrite( overwrite );
setDelimiters( mavenResourcesExecution );
try
{
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
// 2 Copy if needed
copyDirectoryStructure( tmp, getOutputDirectory(), getOutputDirectory() );
FileUtils.forceDelete( tmp );
if ( getLog().isInfoEnabled() )
{
if ( copied > 0 )
{
getLog().info( "Copied `" + copied + "` to output directory: " + getOutputDirectory() );
}
else
{
getLog().info( "No files have bean copied. Up to date." );
}
}
// 3 Add that dir to sources
addSourceFolderToProject( this.project );
if ( getLog().isInfoEnabled() )
{
getLog().info( "Source directory: " + getOutputDirectory() + " added." );
}
}
catch ( IOException ex )
{
throw new MojoExecutionException( ex.getMessage(), ex );
}
}
示例10: buildWebapp
import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
/**
* Builds the webapp for the specified project with the new packaging task
* thingy
* <p/>
* Classes, libraries and tld files are copied to
* the <tt>webappDirectory</tt> during this phase.
*
* @param project the maven project
* @param webappDirectory the target directory
* @throws MojoExecutionException if an error occurred while packaging the webapp
* @throws MojoFailureException if an unexpected error occurred while packaging the webapp
* @throws IOException if an error occurred while copying the files
*/
public void buildWebapp( MavenProject project, File webappDirectory )
throws MojoExecutionException, MojoFailureException, IOException
{
WebappStructure cache;
if ( useCache && cacheFile.exists() )
{
cache = new WebappStructure( project.getDependencies(), webappStructureSerialier.fromXml( cacheFile ) );
}
else
{
cache = new WebappStructure( project.getDependencies(), null );
}
final long startTime = System.currentTimeMillis();
getLog().info( "Assembling webapp [" + project.getArtifactId() + "] in [" + webappDirectory + "]" );
final OverlayManager overlayManager =
new OverlayManager( overlays, project, dependentWarIncludes, dependentWarExcludes, currentProjectOverlay );
final List packagingTasks = getPackagingTasks( overlayManager );
List defaultFilterWrappers = null;
try
{
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
mavenResourcesExecution.setEscapeString( escapeString );
defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers( project, filters,
escapedBackslashesInFilePath,
this.session, mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
getLog().error( "fail to build filering wrappers " + e.getMessage() );
throw new MojoExecutionException( e.getMessage(), e );
}
final WarPackagingContext context = new DefaultWarPackagingContext( webappDirectory, cache, overlayManager,
defaultFilterWrappers,
getNonFilteredFileExtensions(),
filteringDeploymentDescriptors,
this.artifactFactory );
final Iterator it = packagingTasks.iterator();
while ( it.hasNext() )
{
WarPackagingTask warPackagingTask = (WarPackagingTask) it.next();
warPackagingTask.performPackaging( context );
}
// Post packaging
final List postPackagingTasks = getPostPackagingTasks();
final Iterator it2 = postPackagingTasks.iterator();
while ( it2.hasNext() )
{
WarPostPackagingTask task = (WarPostPackagingTask) it2.next();
task.performPostPackaging( context );
}
getLog().info( "Webapp assembled in [" + ( System.currentTimeMillis() - startTime ) + " msecs]" );
}