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 FileSetManager fileSetManager = new FileSetManager(); for (FileSet fileSet : projectScan) { final String[] includedFiles = fileSetManager.getIncludedFiles(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()); }
@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; }
/** * 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); } }
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 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())); } }
@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); } } } }
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 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 ); } }
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 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 ); } } }
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 ); } } }
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 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); } } } }