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


Java Resource.setFiltering方法代码示例

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


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

示例1: filterAndCopy

import org.apache.maven.model.Resource; //导入方法依赖的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

示例2: copyResources

import org.apache.maven.model.Resource; //导入方法依赖的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

示例3: getResources

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected List<Resource> getResources() {
    final Resource resource = new Resource();
    resource.setDirectory(getBuildDirectoryAbsolutePath());
    resource.setTargetPath("/");
    resource.setFiltering(false);
    resource.setIncludes(Arrays.asList("*.jar"));
    return Arrays.asList(resource);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:9,代码来源:PackageMojo.java

示例4: addingCompileSource

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void addingCompileSource()
{
    String generatedSourcePath = getGeneratedResourceFolder();
    File generatedSourcesDir = new File(generatedSourcePath);
    getLog().info("Adding " + generatedSourcePath + " to compile source.");
    project.addCompileSourceRoot(generatedSourcesDir.getAbsolutePath());
    Resource resource = new Resource();
    resource.setDirectory(generatedSourcesDir.getAbsolutePath());
    resource.setFiltering(false);
    project.addResource(resource);
    buildContext.refresh(generatedSourcesDir);
}
 
开发者ID:mytaxi,项目名称:phrase-maven-plugin,代码行数:13,代码来源:PhraseAppMojo.java

示例5: execute

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() {
    try {
        sourceDirectory = makeAbsolute(sourceDirectory);
        outputDirectory = makeAbsolute(outputDirectory);
        if ( ! sourceDirectory.exists() ) return;
        getLog().debug("Running ApiGen\n\tsourceDirectory=" + sourceDirectory +
                       "\n\toutputDirectory=" + outputDirectory);
        ClassLoader cp = getCompileClassLoader();
        ApiGen apiGen = new ApiGen.Builder()
            .withOutputDirectory(outputDirectory.toPath())
            .withGuiceModuleName(guiceModuleName)
            .withDefaultPackageName(defaultPackageName)
            .build();
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cp);
        for ( org.springframework.core.io.Resource resource : resolver.getResources("classpath*:graphql-apigen-schema/*.graphql{,s}") ) {
            URL url = resource.getURL();
            getLog().debug("Processing "+url);
            apiGen.addForReference(url);
        }
        findGraphql(sourceDirectory, apiGen::addForGeneration);
        apiGen.generate();
        Resource schemaResource = new Resource();
        schemaResource.setTargetPath("graphql-apigen-schema");
        schemaResource.setFiltering(false);
        schemaResource.setIncludes(Arrays.asList("*.graphqls","*.graphql"));
        schemaResource.setDirectory(sourceDirectory.toString());
        project.addResource(schemaResource);
        project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
    } catch (Exception e) {
        String msg = e.getMessage();
        if ( null == msg ) msg = e.getClass().getName();
        getLog().error(msg + " when trying to build sources from graphql.", e);
    }
}
 
开发者ID:Distelli,项目名称:graphql-apigen,代码行数:36,代码来源:ApiGenMojo.java

示例6: addResource

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private Resource addResource(File srcDirectory) {
	Resource r = new Resource();

	r.setDirectory(srcDirectory.getAbsolutePath());
	r.setFiltering(true);
	r.addExclude("**/*TestSuite/"); // exclude FCUnit TestSuites

	return r;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:10,代码来源:CopyBWSourcesMojo.java

示例7: convertToMavenResource

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private static Resource convertToMavenResource(MavenResource mavenResource, File projectDir) {
  Resource resource = new Resource();
  resource.setDirectory(relativize(projectDir, mavenResource.getDirectory()));
  resource.setFiltering(mavenResource.isFiltered());
  resource.setTargetPath(mavenResource.getTargetPath());
  resource.setIncludes(mavenResource.getIncludes());
  resource.setExcludes(mavenResource.getExcludes());
  return resource;
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:MavenModelUtil.java

示例8: filterSourceToTemporaryDir

import org.apache.maven.model.Resource; //导入方法依赖的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

示例9: doCopyPreAssembleDirectory

import org.apache.maven.model.Resource; //导入方法依赖的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

示例10: execute

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
  getLog().info("Adding plugin manifest at " + manifestLocation + " as resource");

  Resource resource = new Resource();
  resource.setDirectory(manifestLocation.getParent());
  resource.setIncludes(Collections.singletonList(manifestLocation.getName()));
  resource.setTargetPath("META-INF");
  resource.setFiltering(true);
  project.addResource(resource);
}
 
开发者ID:Guidewire,项目名称:ijplugin-maven-plugin,代码行数:12,代码来源:ManifestMojo.java

示例11: mergeResource_Filtering

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
protected void mergeResource_Filtering( Resource target, Resource source, boolean sourceDominant,
                                        Map<Object, Object> context )
{
    String src = source.getFiltering();
    if ( src != null )
    {
        if ( sourceDominant || target.getFiltering() == null )
        {
            target.setFiltering( src );
            target.setLocation( "filtering", source.getLocation( "filtering" ) );
        }
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:14,代码来源:ModelMerger.java

示例12: setupResources

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void setupResources()
{
    Resource resource = new Resource();

    // see MavenProjectBasicStub for details 
    // of getBasedir

    // setup default resources
    resource.setDirectory( getBasedir().getPath() + "/src/main/resources" );
    resource.setFiltering( false );
    resource.setTargetPath( null );
    build.addResource( resource );
}
 
开发者ID:dashie,项目名称:m2e-plugins,代码行数:14,代码来源:MavenProjectResourcesStub.java

示例13: setupTestResources

import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void setupTestResources()
{
    Resource resource = new Resource();

    // see MavenProjectBasicStub for details 
    // of getBasedir      

    // setup default test resources         
    resource.setDirectory( getBasedir().getPath() + "/src/test/resources" );
    resource.setFiltering( false );
    resource.setTargetPath( null );
    build.addTestResource( resource );
}
 
开发者ID:dashie,项目名称:m2e-plugins,代码行数:14,代码来源:MavenProjectResourcesStub.java

示例14: copyFileToDir

import org.apache.maven.model.Resource; //导入方法依赖的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: filterResources

import org.apache.maven.model.Resource; //导入方法依赖的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


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