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


Java MavenResourcesExecution类代码示例

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


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

示例1: execute

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    initializeHandlers();

    for (AppBuildHandler appBuildHandler : appBuildHandlers) {
        appBuildHandler.handle();
    }

    final Build build = project.getBuild();
    final List<String> nonFilteredFileExtensions = getNonFilteredFileExtensions(build.getPlugins());


    MavenResourcesExecution mavenResourcesExecution =
            new MavenResourcesExecution(build.getResources(), new File(outputDirectory), project,
                    ENCODING, build.getFilters(), nonFilteredFileExtensions, session);

    try {
        mavenResourcesFiltering.filterResources(mavenResourcesExecution);
    } catch (MavenFilteringException e) {
        throw new WMRuntimeException("Failed to execute resource filtering ", e);
    }
}
 
开发者ID:wavemaker,项目名称:wavemaker-app-build-tools,代码行数:23,代码来源:AppBuildMojo.java

示例2: executeUserFilterComponents

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的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);
		}
	}
}
 
开发者ID:dajester2013,项目名称:lucee-maven-plugin,代码行数:24,代码来源:LarCopySourcesMojo.java

示例3: testExecute

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
@Test
public void testExecute()
    throws MojoExecutionException, MavenFilteringException
{
    // given
    doAnswer( new MockCopyAnswer() ).when( mavenResourcesFiltering ).filterResources( any( MavenResourcesExecution.class ) );

    // when
    mojo.execute();
    assertThat( mojo.countCopiedFiles() ).isEqualTo( 1 );
    mojo.execute();
    assertThat( mojo.countCopiedFiles() ).isEqualTo( 0 );

    // then
    verify( mavenResourcesFiltering, times( 2 ) ).filterResources( any( MavenResourcesExecution.class ) );
    verify( buildContext, times( 1 ) ).refresh( outputDirectory );
    verify( project, times( 2 ) ).addCompileSourceRoot( outputDirectory.getAbsolutePath() );
}
 
开发者ID:mojohaus,项目名称:templating-maven-plugin,代码行数:19,代码来源:AbstractFilterSourcesMojoTest.java

示例4: copyNbmResources

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
private void copyNbmResources()
    throws MojoExecutionException
{
    try
    {
        if ( StringUtils.isEmpty( encoding ) && isFilteringEnabled( nbmResources ) )
        {
            getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
                               + ", i.e. build is platform dependent!" );
        }
        MavenResourcesExecution mavenResourcesExecution =
            new MavenResourcesExecution( Arrays.asList( nbmResources ), clusterDir, project, encoding,
                                         Collections.EMPTY_LIST, Collections.EMPTY_LIST, session );
        mavenResourcesExecution.setEscapeWindowsPaths( true );
        mavenResourcesFiltering.filterResources( mavenResourcesExecution );
    }
    catch ( MavenFilteringException ex )
    {
        throw new MojoExecutionException( ex.getMessage(), ex );
    }
}
 
开发者ID:bitstrings,项目名称:nbm-maven,代码行数:22,代码来源:CreateNetBeansFileStructure.java

示例5: 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);
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:21,代码来源:ResourceCopy.java

示例6: executeUserFilterComponents

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的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);
        }
    }
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:31,代码来源:MdPageGeneratorMojo.java

示例7: 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

示例8: copyResources

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
@Test
public void copyResources() throws Exception {
    final MavenResourcesFiltering filtering = mock(MavenResourcesFiltering.class);
    final Resource resource = new Resource();
    resource.setTargetPath("/");

    Utils.copyResources(mock(MavenProject.class),
            mock(MavenSession.class),
            filtering,
            Arrays.asList(new Resource[] {resource}),
            "target");
    verify(filtering, times(1)).filterResources(any(MavenResourcesExecution.class));
    verifyNoMoreInteractions(filtering);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:15,代码来源:UtilsTest.java

示例9: 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

示例10: setDelimitersForExecution

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
private void setDelimitersForExecution( MavenResourcesExecution mavenResourcesExecution )
{
    // 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 );
    }
}
 
开发者ID:mojohaus,项目名称:templating-maven-plugin,代码行数:28,代码来源:AbstractFilterSourcesMojo.java

示例11: answer

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
public Void answer( InvocationOnMock invocation )
    throws Throwable
{
    MavenResourcesExecution arg = MavenResourcesExecution.class.cast( invocation.getArguments()[0] );
    File source = new File( arg.getResources().iterator().next().getDirectory() );
    assertThat( source ).exists();
    assertThat( source ).isDirectory();
    File destination = arg.getOutputDirectory();
    assertThat( destination ).doesNotExist();
    FileUtils.copyDirectoryStructure( source, destination );
    return null;
}
 
开发者ID:mojohaus,项目名称:templating-maven-plugin,代码行数:13,代码来源:AbstractFilterSourcesMojoTest.java

示例12: 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." );
    }
}
 
开发者ID:mojohaus,项目名称:appassembler,代码行数:33,代码来源:AbstractScriptGeneratorMojo.java

示例13: setDelimiters

import org.apache.maven.shared.filtering.MavenResourcesExecution; //导入依赖的package包/类
private void setDelimiters( MavenResourcesExecution mavenResourcesExecution )
{
    // 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 );
    }
}
 
开发者ID:wavesoftware,项目名称:templating-maven-plugin-copy,代码行数:28,代码来源:AbstractFilterSourcesMojo.java

示例14: 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);
        }
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:50,代码来源:ResourceCopy.java

示例15: 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]" );

}
 
开发者ID:zhegexiaohuozi,项目名称:maven-seimicrawler-plugin,代码行数:82,代码来源:AbstractWarMojo.java


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