private String[] getIncludedFiles(String absPath, String[] excludes, String[] includes) { FileSetManager fileSetManager = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(absPath); fs.setFollowSymlinks(false); //exclude imports directory since it has already been compiled. if (imports != null) { String importExclude = null; for (String importFile : this.imports) { File file = new File(importFile); if (file.isDirectory()) { importExclude = file.getName() + "/**"; } else if (file.isFile()) { importExclude = "**/" + file.getName(); } fs.addExclude(importExclude); } } for (String include : includes) { fs.addInclude(include); } for (String exclude : excludes) { fs.addExclude(exclude); } return fileSetManager.getIncludedFiles(fs); }
public void execute( Map context ) throws Exception { Project project = store.getProject( getProjectId( context ) ); File workingDirectory = workingDirectoryService.getWorkingDirectory( project ); if ( workingDirectory.exists() ) { FileSetManager fileSetManager = new FileSetManager(); FileSet fileSet = new FileSet(); fileSet.setDirectory( workingDirectory.getPath() ); fileSet.addInclude( "**/**" ); // TODO : this with a configuration option somewhere ? fileSet.setFollowSymlinks( false ); fileSetManager.delete( fileSet ); } } }
/** * @return the selected set of files. */ public Collection<File> getSelectedFiles() { // Because of a symlink issue on OpenJDK, we cannot use the FileSetManager directory, because we need to // override a method from the DirectoryScanner. // The exception is: java.lang.ClassNotFoundException: sun/nio/fs/AixFileSystemProvider final FileSet set = getFileset(); String[] names = FILESET_MANAGER.getIncludedFiles(set); List<File> files = new ArrayList<>(); File base = new File(set.getDirectory()); for (String n : names) { files.add(new File(base, n)); } return files; } }
FileSetManager fileSetManager = new FileSetManager( getLog() ); Map<String, String> includedFiles = fileSetManager.mapIncludedFiles( fileSet );
public CodeGenerator() { typeToObjectTypeMap = new HashMap<String,String>(); typeToObjectTypeMap.put("boolean", "Boolean"); typeToObjectTypeMap.put("byte", "Byte"); typeToObjectTypeMap.put("char", "Character"); typeToObjectTypeMap.put("int", "Integer"); typeToObjectTypeMap.put("short", "Short"); typeToObjectTypeMap.put("long", "Long"); typeToObjectTypeMap.put("float", "Float"); typeToObjectTypeMap.put("double", "Double"); fileSetManager = new FileSetManager(getLog()); }
throws IOException Set<String> deletablePaths = findDeletablePaths( fileSet ); if ( fileSet.isFollowSymlinks() || !isSymlink( file ) ) removeDir( file, fileSet.isFollowSymlinks(), throwsError, warnMessages ); if ( !delete( file ) )
/** * Delete the matching files and directories for the given file-set definition. * * @param fileSet The file-set matching rules, along with search base directory * @throws IOException If a matching file cannot be deleted */ public void delete( FileSet fileSet ) throws IOException { delete( fileSet, true ); }
public void execute( Map context ) throws Exception { Project project = ContinuumBuildAgentUtil.getProject( context ); File workingDirectory = buildAgentConfigurationService.getWorkingDirectory( project.getId() ); if ( workingDirectory.exists() ) { getLogger().debug( "Cleaning working directory " + workingDirectory.getAbsolutePath() ); FileSetManager fileSetManager = new FileSetManager(); FileSet fileSet = new FileSet(); fileSet.setDirectory( workingDirectory.getPath() ); fileSet.addInclude( "**/**" ); // TODO : this with a configuration option somewhere ? fileSet.setFollowSymlinks( false ); fileSetManager.delete( fileSet ); } } }
/** * Gets the Groovy sources without the Java sources (since the Java sources don't have Javadoc). * * @param sourceDirectories the source directories to get the Groovy sources from * @param fileSetManager the FileSetmanager to use to get the included files * @return the groovy sources */ protected List<String> setupGroovyDocSources(final FileSet[] sourceDirectories, final FileSetManager fileSetManager) { List<String> javaSources = new ArrayList<String>(); List<String> groovySources = new ArrayList<String>(); List<String> possibleGroovyStubs = new ArrayList<String>(); for (FileSet sourceDirectory : sourceDirectories) { String[] sources = fileSetManager.getIncludedFiles(sourceDirectory); for (String source : sources) { if (source.endsWith(".java") && !javaSources.contains(source)) { javaSources.add(source); } else if (!groovySources.contains(source)) { groovySources.add(source); possibleGroovyStubs.add(source.replaceFirst("\\." + FileUtils.getFileExtension(source), ".java")); } } } javaSources.removeAll(possibleGroovyStubs); List<String> groovyDocSources = new ArrayList<String>(); groovyDocSources.addAll(javaSources); groovyDocSources.addAll(groovySources); return groovyDocSources; }
FileSetManager fileSetManager = new FileSetManager( getLog() ); Map<String, String> includedFiles = fileSetManager.mapIncludedFiles( fileSet );
Object fileOutputTool = invokeConstructor(findConstructor(fileOutputToolClass)); Object classpathResourceManager = invokeConstructor(findConstructor(classpathResourceManagerClass)); FileSetManager fileSetManager = new FileSetManager(getLog()); List<String> sourceDirectoriesStrings = new ArrayList<String>(); for (FileSet sourceDirectory : sourceDirectories) {
final FileSetManager fileSetManager = new FileSetManager(); for (FileSet fileSet : projectScan) { final String[] includedFiles = fileSetManager.getIncludedFiles(fileSet); for (String include : includedFiles) { final File includeFile = new File(fileSet.getDirectory(), include).getAbsoluteFile();
public void execute( Map context ) throws Exception { Project project = projectDao.getProject( getProjectId( context ) ); List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context ); String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() ); File workingDirectory = workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot ); if ( workingDirectory.exists() ) { FileSetManager fileSetManager = new FileSetManager(); FileSet fileSet = new FileSet(); fileSet.setDirectory( workingDirectory.getPath() ); fileSet.addInclude( "**/**" ); // TODO : this with a configuration option somewhere ? fileSet.setFollowSymlinks( false ); fileSetManager.delete( fileSet ); } } }
private void runGeneration(String thisSourceRoot, VelocityEngine engine, File thisOutputDirectory, File thisDoNotReplaceDirectory, String[] excludes) throws MojoExecutionException { FileSet fileSet = new FileSet(); fileSet.setDirectory(thisSourceRoot); List<String> includes = new ArrayList<String>(); includes.add("**/*.java.t"); fileSet.setIncludes(includes); String[] includedFiles = fileSetManager.getIncludedFiles(fileSet); for (String template : includedFiles) { File templateFile = new File(thisSourceRoot, template); String subpath = templateFile.getParentFile().getPath().substring( fileSet.getDirectory().length()); thisOutputDirectory.mkdirs(); File thisDoNotReplaceFull = new File(thisDoNotReplaceDirectory, subpath); processOneTemplate(engine, template, thisOutputDirectory, thisDoNotReplaceFull, subpath.substring(1), excludes); } }
@Override protected VelocityContext getVelocityContext() throws MojoExecutionException { VelocityContext context = super.getVelocityContext(); List<File> includedFiles = new LinkedList<File>(); FileSetManager fileSetManager = new FileSetManager(); for(FileSet fileSet : externcInput) { String[] fileSetIncludes = fileSetManager.getIncludedFiles(fileSet); if((fileSetIncludes != null) && (fileSetIncludes.length > 0)) { for(String include : fileSetIncludes) { includedFiles.add(new File(fileSet.getDirectory(), include)); } } } context.put("sourcePath", includedFiles); if(externcConfig != null) { context.put("classExcludes", externcConfig.classExcludes); context.put("fieldExcludes", externcConfig.fieldExcludes); context.put("excludes", externcConfig.excludes); } return context; }
FileSetManager fileSetManager = new FileSetManager(); fileSetManager.delete( fileset );
/** * @param fileSet {@link FileSet} * @return the included files as map * @throws MapperException if any * @see #getIncludedFiles(FileSet) */ public Map<String, String> mapIncludedFiles( FileSet fileSet ) throws MapperException { String[] sourcePaths = getIncludedFiles( fileSet ); Map<String, String> mappedPaths = new LinkedHashMap<String, String>(); FileNameMapper fileMapper = MapperUtil.getFileNameMapper( fileSet.getMapper() ); for ( int i = 0; i < sourcePaths.length; i++ ) { String sourcePath = sourcePaths[i]; String destPath; if ( fileMapper != null ) { destPath = fileMapper.mapFileName( sourcePath ); } else { destPath = sourcePath; } mappedPaths.put( sourcePath, destPath ); } return mappedPaths; }
/** * Gets the set of stub files in specified directory. * * @return The set of stub files in specified directory */ protected Set<File> getStubs(File outputDirectory) { Set<File> files = new HashSet<File>(); FileSetManager fileSetManager = new FileSetManager(getLog()); FileSet fileSet = new FileSet(); fileSet.setDirectory(outputDirectory.getAbsolutePath()); fileSet.setIncludes(singletonList(JAVA_SOURCES_PATTERN)); for (String file : fileSetManager.getIncludedFiles(fileSet)) { files.add(new File(outputDirectory, file)); } return files; }
String[] includedFiles = fileSetManager.getIncludedFiles(fs);