本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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." );
}
}
示例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);
}
示例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" ) );
}
}
}
示例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 );
}
示例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 );
}
示例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);
}
}
}
示例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 );
}
}