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); }
final String[] includedFiles = fileSetManager.getIncludedFiles(fileSet); for (String include : includedFiles) { final File includeFile = new File(fileSet.getDirectory(), include).getAbsoluteFile();
/** * @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; } }
/** * 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; }
@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; }
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); } }
/** * 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; }
/** * 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; }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (!apiOutputDirectory.exists()) { getLog().info("generating AS3 localization api stubs into: " + apiOutputDirectory.getPath()); getLog().debug("created " + apiOutputDirectory.mkdirs()); } File resourceDirectory = getSourceDirectory(); if (properties == null) { properties = new FileSet(); properties.setDirectory(resourceDirectory.getAbsolutePath()); properties.addInclude("**/*.properties"); } List<File> sourceFiles = new ArrayList<>(10); for (String srcFileRelativePath : new FileSetManager().getIncludedFiles(properties)) { sourceFiles.add(new File(resourceDirectory,srcFileRelativePath)); } Propc generator = new Propc(); try { List<File> sourcePath = Collections.singletonList(resourceDirectory.getCanonicalFile()); generator.generateApi(sourceFiles, sourcePath, apiOutputDirectory); } catch (Exception e) { throw new MojoExecutionException("Generation failure", e); } }
public void execute() throws MojoExecutionException { if (soliditySourceFiles.getDirectory() == null) { getLog().info("No solidity directory specified, using default directory [" + DEFAULT_SOLIDITY_SOURCES + "]"); soliditySourceFiles.setDirectory(DEFAULT_SOLIDITY_SOURCES); } if (soliditySourceFiles.getIncludes().isEmpty()) { getLog().info("No solidity contracts specified, using the default [" + DEFAULT_INCLUDE + "]"); soliditySourceFiles.setIncludes(Collections.singletonList(DEFAULT_INCLUDE)); } String[] files = new FileSetManager().getIncludedFiles(soliditySourceFiles); if (files != null) { processContractFile(Stream.of(files) .filter(f -> { getLog().info("Adding to process '" + f + "'"); return true; }) .collect(Collectors.toList())); } }
/** * @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; }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Skipping plugin execution (configured skip)"); return; } FileSetManager mgr = new FileSetManager(); // this seems pretty hacky, but necessary to get the correct result. File inputFilesDirectory = new File(inputFiles.getDirectory()); if (!inputFilesDirectory.isAbsolute()) { inputFiles.setDirectory(new File(project.getBasedir(), inputFiles.getDirectory()).getAbsolutePath()); } final String[] includedFiles = mgr.getIncludedFiles(inputFiles); getLog().info("Processing " + includedFiles.length + " files..."); for (String file : includedFiles) { getLog().info(" -" + file); try { TemplateHelper.INSTANCE.processFile(new File(inputFiles.getDirectory(), file), new File(outputDir, file.replace(".template", ""))); } catch (IOException e) { e.printStackTrace(); throw new MojoExecutionException("failure", e); } } } }
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[] getSchemaFiles() { FileSetManager fsm = new FileSetManager(); FileSet fs = new FileSet(); fs.setDirectory(generatedAvscTarget.getAbsolutePath()); fs.addInclude("**/*.avsc"); fs.setFollowSymlinks(false); return fsm.getIncludedFiles(fs); }
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); }
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); }
public void execute() throws MojoExecutionException, MojoFailureException { if (!generatedSourcesDirectory.exists()) { getLog().info("generating sources into: " + generatedSourcesDirectory.getPath()); getLog().debug("created " + generatedSourcesDirectory.mkdirs()); } if (properties == null) { properties = new FileSet(); properties.setDirectory(resourceDirectory.getAbsolutePath()); properties.addInclude("**/*.properties"); } FileLocations config = new FileLocations(); config.setOutputDirectory(generatedSourcesDirectory); for (String srcFileRelativePath : new FileSetManager().getIncludedFiles(properties)) { config.addSourceFile(new File(resourceDirectory,srcFileRelativePath)); } try { config.setSourcePath(Arrays.asList(resourceDirectory)); } catch (IOException e) { throw new MojoExecutionException("configuration failure", e); } PropertyClassGenerator generator = new PropertyClassGenerator(config); try { generator.generate(); } catch (PropcException e) { throw new MojoExecutionException("Generation failure", e); } }
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); }
public void upload( Wagon wagon, FileSet fileset, Log logger ) throws WagonException { FileSetManager fileSetManager = new FileSetManager( logger, logger.isDebugEnabled() ); String[] files = fileSetManager.getIncludedFiles( fileset ); String url = wagon.getRepository().getUrl() + "/"; if ( files.length == 0 ) { logger.info( "Nothing to upload." ); return; } for ( String file : files ) { String relativeDestPath = StringUtils.replace( file, "\\", "/" ); if ( !StringUtils.isBlank( fileset.getOutputDirectory() ) ) { relativeDestPath = fileset.getOutputDirectory() + "/" + relativeDestPath; } File source = new File( fileset.getDirectory(), file ); logger.info( "Uploading " + source + " to " + url + relativeDestPath + " ..." ); wagon.put( source, relativeDestPath ); } }
private void scan(final File dir) throws IOException { FileSet srcFiles = new FileSet(); srcFiles.setDirectory(dir.getAbsolutePath()); srcFiles.addInclude("**/*." + ComponentType.JavaScript.getExtension()); srcFiles.addExclude("**/*-more." + ComponentType.JavaScript.getExtension()); // exclude special Ext JS files srcFiles.addInclude("**/*." + ComponentType.ActionScript.getExtension()); srcFiles.addInclude("**/*." + ComponentType.EXML.getExtension()); for (String srcFileRelativePath : new FileSetManager().getIncludedFiles(srcFiles)) { File srcFile = new File(dir, srcFileRelativePath); Log.setCurrentFile(srcFile); ComponentType type = ComponentType.from(FileUtils.extension(srcFile.getName())); if (ComponentType.EXML.equals(type)) { ExmlComponentSrcFileScanner.scan(componentSuite, srcFile, type); } else { //parse AS3 or JS files ExtComponentSrcFileScanner.scan(componentSuite, srcFile, type); } } } }