本文整理汇总了Java中org.apache.maven.model.FileSet类的典型用法代码示例。如果您正苦于以下问题:Java FileSet类的具体用法?Java FileSet怎么用?Java FileSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileSet类属于org.apache.maven.model包,在下文中一共展示了FileSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFileList
import org.apache.maven.model.FileSet; //导入依赖的package包/类
public List<File> toFileList( FileSet fs ) throws MojoExecutionException
{
try
{
if ( fs.getDirectory() != null )
{
File directory = new File( fs.getDirectory() );
String includes = toString( fs.getIncludes() );
String excludes = toString( fs.getExcludes() );
return FileUtils.getFiles( directory, includes, excludes );
}
else
{
getLog().warn( String.format( "Fileset [%s] directory empty", fs.toString() ) );
return new ArrayList<>();
}
}
catch ( IOException e )
{
throw new MojoExecutionException( String.format( "Unable to get paths to fileset [%s]", fs.toString() ),
e );
}
}
示例2: getFilesToProcess
import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected List<File> getFilesToProcess() throws MojoExecutionException
{
List<File> files = new ArrayList<>();
if ( null != getFileset() )
{
if ( null == getFilesets() )
{
filesets = new ArrayList<>();
}
getFilesets().add( getFileset() );
}
if ( null != getFilesets() )
{
for ( FileSet fs : getFilesets() )
{
if ( (null != fs) && (null != fs.getDirectory()) )
{
FileSetTransformer fileMgr = new FileSetTransformer( fs );
files.addAll( fileMgr.toFileList() );
}
}
}
return files;
}
示例3: createIvyArchive
import org.apache.maven.model.FileSet; //导入依赖的package包/类
private void createIvyArchive(File sourceDir, File targetIar) throws MojoExecutionException
{
ZipArchiver archiver = new ZipArchiver();
archiver.setDestFile(targetIar);
archiver.addFileSet(getDefaultFileset(sourceDir));
FileSetConverter fsConverter = new FileSetConverter(project.getBasedir());
for(org.codehaus.plexus.archiver.FileSet fs : fsConverter.toPlexusFileSets(iarFileSets))
{
archiver.addFileSet(fs);
}
try
{
archiver.createArchive();
}
catch (ArchiverException | IOException ex)
{
throw new MojoExecutionException("Failed to create IAR: " + targetIar.getAbsolutePath(), ex);
}
}
示例4: canDefineCustomInclusions
import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test
public void canDefineCustomInclusions() throws Exception
{
IarPackagingMojo mojo = rule.getMojo();
File outputDir = new File(mojo.project.getBasedir(), "target");
File customPomXml = new File(outputDir, "myCustomPom.xml");
FileUtils.write(customPomXml, "customPomContent");
String relativeCustomIncludePath = "target/"+customPomXml.getName();
FileSet fs = new FileSet();
fs.setIncludes(Arrays.asList(relativeCustomIncludePath));
mojo.iarFileSets = new FileSet[]{fs};
mojo.execute();
try(ZipFile archive = new ZipFile(mojo.project.getArtifact().getFile()))
{
assertThat(archive.getEntry(relativeCustomIncludePath)).as("Custom inclusions must be included").isNotNull();
}
}
示例5: testEmptyXmlFileSets
import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test()
public void testEmptyXmlFileSets() throws Exception {
final File testPom = new File("src/test/resources/net/trajano/mojo/cleanpom/cleaner-pom.xml");
final File xml = new File("src/test/resources/net/trajano/mojo/cleanpom/dual-doctype.xml");
final File temp = File.createTempFile("dirty", "");
temp.delete();
temp.mkdirs();
FileUtils.copyFile(xml, new File(temp, "dirty1.xml"));
final CleanXmlMojo mojo = (CleanXmlMojo) rule.lookupMojo("clean-xml", testPom);
mojo.setXmlFileSets(new FileSet[0]);
assertNotNull(mojo);
try {
mojo.execute();
} finally {
FileUtils.deleteDirectory(temp);
}
}
示例6: testFailWithWithDTDs
import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Test(expected = MojoExecutionException.class)
public void testFailWithWithDTDs() throws Exception {
final File testPom = new File("src/test/resources/net/trajano/mojo/cleanpom/cleaner-pom.xml");
final File xml = new File("src/test/resources/net/trajano/mojo/cleanpom/dual-doctype.xml");
final File temp = File.createTempFile("dirty", "");
temp.delete();
temp.mkdirs();
FileUtils.copyFile(xml, new File(temp, "dirty1.xml"));
final CleanXmlMojo mojo = (CleanXmlMojo) rule.lookupMojo("clean-xml", testPom);
final FileSet xmlFiles = new FileSet();
xmlFiles.setDirectory(temp.getAbsolutePath());
xmlFiles.addInclude("**/*.xml");
rule.setVariableValueToObject(mojo, "xmlFileSets", new FileSet[] {
xmlFiles
});
assertNotNull(mojo);
try {
mojo.execute();
} finally {
FileUtils.deleteDirectory(temp);
}
}
示例7: getResourceFiles
import org.apache.maven.model.FileSet; //导入依赖的package包/类
Collection<String> getResourceFiles(final Iterable<? extends FileSet> fileSets,
final boolean followLinks, final boolean allowDuplicates, final boolean allowFiles,
final boolean allowDirs) throws MojoExecutionException {
final Set<String> result = new LinkedHashSet<>();
for (final FileSet fileSet : Objects.requireNonNull(fileSets)) {
final Collection<String> files =
getResourceFiles(fileSet, followLinks, allowDuplicates, allowFiles, allowDirs);
for (final String file : files) {
if (!result.add(file) && !allowDuplicates) {
getLog()
.error(
String.format("a duplicate file %s under directory %s", file,
fileSet.getDirectory()));
throw new MojoExecutionException(String.format("a duplicate file %s under directory %s",
file, fileSet.getDirectory()));
}
}
}
return result;
}
示例8: updateFileSet
import org.apache.maven.model.FileSet; //导入依赖的package包/类
/**
* Method updateFileSet
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
protected void updateFileSet( FileSet value, String xmlTag, Counter counter, Element element )
{
boolean shouldExist = value != null;
Element root = updateElement( counter, element, xmlTag, shouldExist );
if ( shouldExist )
{
Counter innerCount = new Counter( counter.getDepth() + 1 );
findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
findAndReplaceSimpleLists( innerCount, root, value.getIncludes(), "includes", "include" );
findAndReplaceSimpleLists( innerCount, root, value.getExcludes(), "excludes", "exclude" );
}
}
示例9: toFileList
import org.apache.maven.model.FileSet; //导入依赖的package包/类
private static List<File> toFileList(FileSet fileSet)
throws IOException {
File directory = new File(fileSet.getDirectory());
if (directory.exists()) {
String includes = toString(fileSet.getIncludes());
String excludes = toString(fileSet.getExcludes());
return FileUtils.getFiles(directory, includes, excludes);
}
return Collections.<File>emptyList();
}
示例10: getTmlFiles
import org.apache.maven.model.FileSet; //导入依赖的package包/类
private Set<String> getTmlFiles() throws IOException {
Set<String> files = new HashSet<>();
for (FileSet fileSet : tmls) {
File directory = (fileSet.getDirectory() == null) ?
this.project.getBasedir() : new File(fileSet.getDirectory());
String includes = StringUtils.join(fileSet.getIncludes(), ',');
String excludes = StringUtils.join(fileSet.getExcludes(), ',');
for (File file : FileUtils.getFiles(directory, includes, excludes)) {
files.add(file.getAbsolutePath());
}
}
return files;
}
示例11: initFiles
import org.apache.maven.model.FileSet; //导入依赖的package包/类
/**
* This method retrieves a list of ".aliaslib" files to process in the
* source directory (usually "target/src") which is a copy of the actual
* source directory used to compile the TIBCO BusinessWorks EAR.
*/
private List<File> initFiles() throws IOException {
FileSet restriction = new FileSet();
File directory = buildSrcDirectory;
if (directory == null) {
directory = new File(".");
getLog().warn(SRC_NOT_SET);
}
getLog().debug(directory.getAbsolutePath());
restriction.setDirectory(directory.getAbsolutePath());
restriction.addInclude("**/*.aliaslib");
List<File> result = AbstractProjectsListMojo.toFileList(restriction);
if (customAliasLibDirectories != null && !customAliasLibDirectories.isEmpty()) {
for (File customDirectory : customAliasLibDirectories) {
getLog().debug("Looking for '.aliaslib' files in custom directory: " + customDirectory);
FileSet customRestriction = new FileSet();
customRestriction.setDirectory(customDirectory.getAbsolutePath());
customRestriction.addInclude("**/*.aliaslib");
result.addAll(AbstractProjectsListMojo.toFileList(customRestriction));
}
}
getLog().debug("List of '.aliaslib' files to update: " + result);
return result;
}
示例12: initProjects
import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected final void initProjects(String mandatoryFilename, HashMap<String, String> m, Class<? extends AbstractProject> classAbstractProject) throws IOException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException, XmlPullParserException {
projects = new ArrayList<AbstractProject>();
restriction= new FileSet();
restriction.setDirectory(workspaceRoot.getAbsolutePath());
if (recursive) {
for (String p : patterns) {
restriction.addInclude(p + mandatoryFilename);
}
} else {
restriction.addInclude(mandatoryFilename); // we are only looking in the "workspaceRoot" directory
}
restriction.addExclude("**/target/**/" + mandatoryFilename);
restriction.addExclude("**/bin/" + mandatoryFilename);
List<File> files = toFileList(restriction);
for (File f : files) {
Constructor<? extends AbstractProject> ctor = classAbstractProject.getConstructor();
AbstractProject ap = ctor.newInstance();
ap.initialize(f, workspaceRoot, m, mandatoryFilename, getLog());
if (!ap.isIgnored()) {
projects.add(ap);
} else {
getLog().debug("Ignoring project '" + ap.getProjectName() + "'");
}
}
}
示例13: initFiles
import org.apache.maven.model.FileSet; //导入依赖的package包/类
protected List<File> initFiles() throws IOException {
getLog().debug("Looking for files to process...");
FileSet restriction = new FileSet();
File directory = getDirectoryToProcess();
if (directory == null) {
directory = new File(".");
}
restriction.setDirectory(directory.getAbsolutePath());
restriction.addInclude("**/*.process");
return AbstractProjectsListMojo.toFileList(restriction);
}
示例14: initFiles
import org.apache.maven.model.FileSet; //导入依赖的package包/类
@Override
protected List<File> initFiles() throws IOException {
getLog().debug("Looking for files to process...");
FileSet restriction = new FileSet();
restriction.setDirectory(getDirectoryToProcess().getAbsolutePath());
restriction.addInclude("**/*.xml");
return AbstractProjectsListMojo.toFileList(restriction);
}
示例15: scan
import org.apache.maven.model.FileSet; //导入依赖的package包/类
/**
* A {@link DirectoryScanner} boiler plate.
*
* @param fileSet {@link FileSet} to scan
* @return the included paths
*/
private String[] scan( FileSet fileSet )
{
File basedir = new File( fileSet.getDirectory() );
if ( !basedir.exists() || !basedir.isDirectory() )
{
return null;
}
DirectoryScanner scanner = new DirectoryScanner();
List<String> includes = fileSet.getIncludes();
List<String> excludes = fileSet.getExcludes();
if ( includes != null && includes.size() > 0 )
{
scanner.setIncludes( includes.toArray( new String[0] ) );
}
if ( excludes != null && excludes.size() > 0 )
{
scanner.setExcludes( excludes.toArray( new String[0] ) );
}
scanner.setBasedir( basedir );
scanner.scan();
return scanner.getIncludedFiles();
}