本文整理汇总了Java中org.apache.maven.model.Resource.getIncludes方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getIncludes方法的具体用法?Java Resource.getIncludes怎么用?Java Resource.getIncludes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.model.Resource
的用法示例。
在下文中一共展示了Resource.getIncludes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilesToCopy
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
/**
* Returns a list of filenames that should be copied over to the destination directory.
*
* @param resource the resource to be scanned
* @return the array of filenames, relative to the sourceDir
*/
private String[] getFilesToCopy( Resource resource )
{
// CHECKSTYLE_OFF: LineLength
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( resource.getDirectory() );
if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
{
scanner.setIncludes( (String[]) resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) );
}
else
{
scanner.setIncludes( DEFAULT_INCLUDES );
}
if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
{
scanner.setExcludes( (String[]) resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) );
}
scanner.addDefaultExcludes();
scanner.scan();
return scanner.getIncludedFiles();
// CHECKSTYLE_ON: LineLength
}
示例2: getShortDescription
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
@Override
@Messages({
"# {0} - directory path",
"TIP_Resource1=<html>Resource directory defined in POM.<br><i>Directory: </i><b>{0}</b><br>",
"# {0} - maven resource target path",
"TIP_Resource2=<i>Target Path: </i><b>{0}</b><br>",
"# {0} - boolean value",
"TIP_Resource6=<b><i>Filtering: </i>{0}. Please note that some IDE features rely on non-filtered content only.</b><br>",
"# {0} - includes string value",
"TIP_Resource3=<i>Includes: </i><b>{0}</b><br>",
"# {0} - excludes string value",
"TIP_Resource4=<i>Excludes: </i><b>{0}</b><br>",
"# {0} - directory path",
"TIP_Resource5=<html>Configuration Directory<br><i>Directory: </i><b>{0}</b><br>"})
public String getShortDescription() {
if (group.getResource() != null) {
Resource rs = group.getResource();
String str = TIP_Resource1(rs.getDirectory());
if (rs.getTargetPath() != null) {
str = str + TIP_Resource2(rs.getTargetPath());
}
if (rs.isFiltering()) {
str = str + TIP_Resource6(rs.isFiltering());
}
if (rs.getIncludes() != null && rs.getIncludes().size() > 0) {
str = str + TIP_Resource3(Arrays.toString(rs.getIncludes().toArray()));
}
if (rs.getExcludes() != null && rs.getExcludes().size() > 0) {
str = str + TIP_Resource4(Arrays.toString(rs.getExcludes().toArray()));
}
return str;
} else {
return TIP_Resource5(FileUtil.getFileDisplayName(group.getRootFolder()));
}
}
示例3: visitBuildResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void visitBuildResource( ModelVisitor visitor, Resource resource )
{
List<String> includes = resource.getIncludes();
if ( includes != null )
{
ListIterator<String> includeIterator = includes.listIterator();
while ( includeIterator.hasNext() )
{
String include = includeIterator.next();
visitor.visitBuildResourceInclude( include );
include = visitor.replaceBuildResourceInclude( include );
if ( include == null )
includeIterator.remove();
else
includeIterator.set( include );
}
}
List<String> excludes = resource.getExcludes();
if ( excludes != null )
{
ListIterator<String> excludeIterator = excludes.listIterator();
while ( excludeIterator.hasNext() )
{
String exclude = excludeIterator.next();
visitor.visitBuildResourceExclude( exclude );
exclude = visitor.replaceBuildResourceExclude( exclude );
if ( exclude == null )
excludeIterator.remove();
else
excludeIterator.set( exclude );
}
}
}
示例4: visitBuildTestResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void visitBuildTestResource( ModelVisitor visitor, Resource resource )
{
List<String> includes = resource.getIncludes();
if ( includes != null )
{
ListIterator<String> includeIterator = includes.listIterator();
while ( includeIterator.hasNext() )
{
String include = includeIterator.next();
visitor.visitBuildTestResourceInclude( include );
include = visitor.replaceBuildTestResourceInclude( include );
if ( include == null )
includeIterator.remove();
else
includeIterator.set( include );
}
}
List<String> excludes = resource.getExcludes();
if ( excludes != null )
{
ListIterator<String> excludeIterator = excludes.listIterator();
while ( excludeIterator.hasNext() )
{
String exclude = excludeIterator.next();
visitor.visitBuildTestResourceExclude( exclude );
exclude = visitor.replaceBuildTestResourceExclude( exclude );
if ( exclude == null )
excludeIterator.remove();
else
excludeIterator.set( exclude );
}
}
}
示例5: visitProfileBuildResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void visitProfileBuildResource( ModelVisitor visitor, Resource resource )
{
List<String> includes = resource.getIncludes();
if ( includes != null )
{
ListIterator<String> includeIterator = includes.listIterator();
while ( includeIterator.hasNext() )
{
String include = includeIterator.next();
visitor.visitProfileBuildResourceInclude( include );
include = visitor.replaceProfileBuildResourceInclude( include );
if ( include == null )
includeIterator.remove();
else
includeIterator.set( include );
}
}
List<String> excludes = resource.getExcludes();
if ( excludes != null )
{
ListIterator<String> excludeIterator = excludes.listIterator();
while ( excludeIterator.hasNext() )
{
String exclude = excludeIterator.next();
visitor.visitProfileBuildResourceExclude( exclude );
exclude = visitor.replaceProfileBuildResourceExclude( exclude );
if ( exclude == null )
excludeIterator.remove();
else
excludeIterator.set( exclude );
}
}
}
示例6: visitProfileBuildTestResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void visitProfileBuildTestResource( ModelVisitor visitor, Resource resource )
{
List<String> includes = resource.getIncludes();
if ( includes != null )
{
ListIterator<String> includeIterator = includes.listIterator();
while ( includeIterator.hasNext() )
{
String include = includeIterator.next();
visitor.visitProfileBuildTestResourceInclude( include );
include = visitor.replaceProfileBuildTestResourceInclude( include );
if ( include == null )
includeIterator.remove();
else
includeIterator.set( include );
}
}
List<String> excludes = resource.getExcludes();
if ( excludes != null )
{
ListIterator<String> excludeIterator = excludes.listIterator();
while ( excludeIterator.hasNext() )
{
String exclude = excludeIterator.next();
visitor.visitProfileBuildTestResourceExclude( exclude );
exclude = visitor.replaceProfileBuildTestResourceExclude( exclude );
if ( exclude == null )
excludeIterator.remove();
else
excludeIterator.set( exclude );
}
}
}
示例7: findResource
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private Tuple findResource(List<Resource> resources, Project prj, NbMavenProject nbproj, FileObject child, boolean test) {
LOG.log(Level.FINE, "findResource for {0}", child.getPath());
if (resources == null) {
LOG.log(Level.FINE, "findResource for {0} : No Resources", child.getPath());
return null;
}
FileObject target;
//now figure the destination output folder
File fil = nbproj.getOutputDirectory(test);
File stamp = new File(fil, CosChecker.NB_COS);
if (stamp.exists()) {
target = FileUtil.toFileObject(fil);
} else {
LOG.log(Level.FINE, "findResource for {0} : No Stamp", child.getPath());
// no compile on save stamp, means no copying, classes don't get copied/compiled either.
return null;
}
logResources(child, resources);
resourceLoop:
for (Resource res : resources) {
String dir = res.getDirectory();
if (dir == null) {
continue;
}
URI uri = FileUtilities.getDirURI(prj.getProjectDirectory(), dir);
FileObject fo = FileUtil.toFileObject(Utilities.toFile(uri));
if (fo != null && FileUtil.isParentOf(fo, child)) {
String path = FileUtil.getRelativePath(fo, child);
//now check includes and excludes
List<String> incls = res.getIncludes();
if (incls.isEmpty()) {
incls = Arrays.asList(FilteredResourcesCoSSkipper.DEFAULT_INCLUDES);
}
boolean included = false;
for (String incl : incls) {
if (DirectoryScanner.match(incl, path)) {
included = true;
break;
}
}
if (!included) {
LOG.log(Level.FINE, "findResource for {0} : Not included {1}, {2} ", new Object[] {child.getPath(), included, res});
if(res.isFiltering()) {
continue;
} else {
break;
}
}
List<String> excls = new ArrayList<String>(res.getExcludes());
excls.addAll(Arrays.asList(DirectoryScanner.DEFAULTEXCLUDES));
for (String excl : excls) {
if (DirectoryScanner.match(excl, path)) {
LOG.log(Level.FINER, "findResource for {0} : Excluded {1}, {2} ", new Object[] {child.getPath(), included, res});
continue resourceLoop;
}
}
LOG.log(Level.FINE, "findResource for {0} : Returns {1}, {2}, {3} ", new Object[] {child.getPath(), res, fo.getPath(), target});
return new Tuple(res, fo, target);
} else {
LOG.log(Level.FINE, "findResource {0} does not apply to file {1}", new Object[]{res, child.getPath()});
}
}
LOG.log(Level.FINE, "findResource for {0} : Retuerns Null", child.getPath());
return null;
}
示例8: copyResources
import org.apache.maven.model.Resource; //导入方法依赖的package包/类
private void copyResources() throws MojoExecutionException {
//The following code was taken from the maven bundle plugin and updated suit the purpose
List<Resource> resources = project.getResources();
for (Resource resource : resources){
String sourcePath = resource.getDirectory();
if (new File(sourcePath).exists()){
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( resource.getDirectory() );
if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() ){
scanner.setIncludes((String[])resource.getIncludes().toArray(new String[]{}));
}else{
scanner.setIncludes(new String[]{"**/**"});
}
List<String> excludes = resource.getExcludes();
if (excludes != null && !excludes.isEmpty()){
scanner.setExcludes((String[])excludes.toArray(new String[]{}));
}
scanner.addDefaultExcludes();
scanner.scan();
List<String> includedFiles = Arrays.asList( scanner.getIncludedFiles() );
getLog().info(" " + resource.getDirectory());
for (String name: includedFiles){
File fromPath=new File(sourcePath,name);
File toPath=new File(FOLDER_FEATURES_FEATURE,name);
try {
if (fromPath.isDirectory() && !toPath.exists()){
toPath.mkdirs();
}else{
FileManagementUtil.copy(fromPath, toPath);
}
} catch (IOException e) {
throw new MojoExecutionException("Unable copy resources: " + resource.getDirectory(), e);
}
}
}
}
// List resources = project.getResources();
// if (resources != null) {
// getLog().info("Copying resources");
// for (Object obj : resources) {
// if (obj instanceof Resource) {
// Resource resource = (Resource) obj;
// try {
// File resourceFolder = new File(resource.getDirectory());
// if (resourceFolder.exists()) {
// getLog().info(" " + resource.getDirectory());
// FileManagementUtil.copyDirectory(resourceFolder, FOLDER_FEATURES_FEATURE);
// }
// } catch (IOException e) {
// throw new MojoExecutionException("Unable copy resources: " + resource.getDirectory(), e);
// }
// }
// }
// }
}