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); }
/** * 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 ); }
private Set<String> findDeletablePaths( FileSet fileSet ) { Set<String> includes = findDeletableDirectories( fileSet ); includes.addAll( findDeletableFiles( fileSet, includes ) ); return includes; }
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 ); } } }
/** * 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; }
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()); }
/** * Get all the filenames which have been included by the rules in this fileset. * * @param fileSet The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of matching filenames, relative to the basedir of the file-set. */ public String[] getIncludedFiles( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getIncludedFiles(); } return EMPTY_STRING_ARRAY; }
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 ); } } }
/** * @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; } }
/** * Get all the directory names which have been included by the rules in this fileset. * * @param fileSet The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of matching dirnames, relative to the basedir of the file-set. */ public String[] getIncludedDirectories( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getIncludedDirectories(); } return EMPTY_STRING_ARRAY; }
public String[] getSchemaFiles() { FileSetManager fsm = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(generatedAvscTarget.getAbsolutePath()); fs.addInclude("**/*.avsc"); fs.setFollowSymlinks(false); return fsm.getIncludedFiles(fs); }
/** * Get all the directory names which have been excluded by the rules in this fileset. * * @param fileSet The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of non-matching dirnames, relative to the basedir of the file-set. */ public String[] getExcludedDirectories( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getExcludedDirectories(); } return EMPTY_STRING_ARRAY; }
public String[] getSourceFiles(final String pattern) { FileSetManager fsm = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(sourceDirectory.getAbsolutePath()); fs.addInclude(pattern); fs.setFollowSymlinks(false); return fsm.getIncludedFiles(fs); }
/** * Get all the filenames which have been excluded by the rules in this fileset. * * @param fileSet The fileset defining rules for inclusion/exclusion, and base directory. * @return the array of non-matching filenames, relative to the basedir of the file-set. */ public String[] getExcludedFiles( FileSet fileSet ) { DirectoryScanner scanner = scan( fileSet ); if ( scanner != null ) { return scanner.getExcludedFiles(); } return EMPTY_STRING_ARRAY; }
public static String[] getFiles(final File directory, final String pattern) { FileSetManager fsm = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(directory.getAbsolutePath()); fs.addInclude(pattern); fs.setFollowSymlinks(false); return fsm.getIncludedFiles(fs); }
private String[] scanIncludedFiles(final String dir, final String[] includes, final String[] excludes) { final FileSet set = new FileSet(); this.log.debug("Scanning " + dir); set.setDirectory(dir); if (includes != null) { for (final String include : includes) { this.log.debug(" including " + include); set.addInclude(include); } } if (excludes != null) { for (final String exclude : excludes) { this.log.debug(" excluding " + exclude); set.addExclude(exclude); } } return new FileSetManager().getIncludedFiles(set); }
public String[] getSourceFiles() { FileSetManager fsm = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(sourceDirectory.getAbsolutePath()); fs.addInclude("**/*.avsc"); fs.addInclude("**/*.avpr"); fs.addInclude("**/*.avdl"); fs.setFollowSymlinks(false); return fsm.getIncludedFiles(fs); }
/** * Gets the set of included files from the specified source files or source * directory (if sources are null). * * @param fromSources The sources to get the included files from * @param defaultSourceDirectory The source directory to fall back on if sources are null * @param includeJavaSources Whether to include Java sources * @return The included files from the specified sources */ protected Set<File> getFiles(final FileSet[] fromSources, final String defaultSourceDirectory, final boolean includeJavaSources) { Set<File> files = new HashSet<File>(); FileSetManager fileSetManager = new FileSetManager(getLog()); for (FileSet fileSet : getFilesets(fromSources, defaultSourceDirectory, includeJavaSources)) { for (String include : fileSetManager.getIncludedFiles(fileSet)) { files.add(new File(fileSet.getDirectory(), include)); } } return files; }
/** * 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; }