当前位置: 首页>>代码示例>>Java>>正文


Java MavenResourcesExecution.setOverwrite方法代码示例

本文整理汇总了Java中org.apache.maven.shared.filtering.MavenResourcesExecution.setOverwrite方法的典型用法代码示例。如果您正苦于以下问题:Java MavenResourcesExecution.setOverwrite方法的具体用法?Java MavenResourcesExecution.setOverwrite怎么用?Java MavenResourcesExecution.setOverwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.shared.filtering.MavenResourcesExecution的用法示例。


在下文中一共展示了MavenResourcesExecution.setOverwrite方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyResources

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的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);
    }
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:45,代码来源:Utils.java

示例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 );
    }
}
 
开发者ID:mojohaus,项目名称:templating-maven-plugin,代码行数:29,代码来源:AbstractFilterSourcesMojo.java

示例3: 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);
	}
}
 
开发者ID:dajester2013,项目名称:lucee-maven-plugin,代码行数:52,代码来源:LarCopySourcesMojo.java

示例4: 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 );
    }

}
 
开发者ID:khmarbaise,项目名称:multienv-maven-plugin,代码行数:48,代码来源:AbstractMultiEnvMojo.java

示例5: 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 );
    }
}
 
开发者ID:wavesoftware,项目名称:templating-maven-plugin-copy,代码行数:77,代码来源:AbstractFilterSourcesMojo.java

示例6: performMavenPropertyFiltering

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入方法依赖的package包/类
private void performMavenPropertyFiltering(final File inputDirectory, final File outputDirectory, final String inputEncoding) throws MojoExecutionException {
    try {
        List<String> combinedFilters = getCombinedFiltersList();

        List<Resource> resources = new ArrayList<Resource>();
        final Resource resource = new Resource();
        resource.setFiltering(true);
        resource.setDirectory(inputDirectory.getAbsolutePath());

        resources.add(resource);
        MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(
                resources,
                outputDirectory,
                project,
                this.inputEncoding,
                combinedFilters,
                Collections.<String>emptyList(),
                session
        );

        // mavenResourcesExecution.setEscapeWindowsPaths(escapeWindowsPaths);

        // never include project build filters in this call, since we've already accounted for the POM build filters
        // above, in getCombinedFiltersList().
        mavenResourcesExecution.setInjectProjectBuildFilters(false);

        // mavenResourcesExecution.setEscapeString(escapeString);
        mavenResourcesExecution.setOverwrite(true);
        // mavenResourcesExecution.setIncludeEmptyDirs(includeEmptyDirs);
        // mavenResourcesExecution.setSupportMultiLineFiltering(supportMultiLineFiltering);
        // mavenResourcesExecution.setFilterFilenames(fileNameFiltering);
        mavenResourcesExecution.setAddDefaultExcludes(addDefaultExcludes);

        // Handle subject of MRESOURCES-99
        Properties additionalProperties = addSeveralSpecialProperties();
        mavenResourcesExecution.setAdditionalProperties(additionalProperties);

        // if these are NOT set, just use the defaults, which are '${*}' and '@'.
        // mavenResourcesExecution.setDelimiters(delimiters, useDefaultDelimiters);

        if (nonFilteredFileExtensions != null) {
            mavenResourcesExecution.setNonFilteredFileExtensions(nonFilteredFileExtensions);
        }

        mavenResourcesFiltering.filterResources(mavenResourcesExecution);

        executeUserFilterComponents(mavenResourcesExecution);

        mavenResourcesExecution.getOutputDirectory();
    } catch (MavenFilteringException e) {
        throw new MojoExecutionException("Failure while processing/filtering markdown sources: " + e.getMessage(), e);
    }
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:54,代码来源:MdPageGeneratorMojo.java


注:本文中的org.apache.maven.shared.filtering.MavenResourcesExecution.setOverwrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。