use of org.codehaus.plexus.util.DirectoryScanner in project aries by apache.
the class EsaMojo method copyEsaSourceFiles.
/**
* Copies source files to the esa
*
* @throws MojoExecutionException
*/
private void copyEsaSourceFiles() throws MojoExecutionException {
try {
File esaSourceDir = esaSourceDirectory;
if (esaSourceDir.exists()) {
getLog().info("Copy esa resources to " + getBuildDir().getAbsolutePath());
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(esaSourceDir.getAbsolutePath());
scanner.setIncludes(DEFAULT_INCLUDES);
scanner.addDefaultExcludes();
scanner.scan();
String[] dirs = scanner.getIncludedDirectories();
for (int j = 0; j < dirs.length; j++) {
new File(getBuildDir(), dirs[j]).mkdirs();
}
String[] files = scanner.getIncludedFiles();
for (int j = 0; j < files.length; j++) {
File targetFile = new File(getBuildDir(), files[j]);
targetFile.getParentFile().mkdirs();
File file = new File(esaSourceDir, files[j]);
FileUtils.copyFileToDirectory(file, targetFile.getParentFile());
}
}
} catch (Exception e) {
throw new MojoExecutionException("Error copying esa resources", e);
}
}
use of org.codehaus.plexus.util.DirectoryScanner in project jena by apache.
the class SchemagenMojo method matchFileNames.
/**
* Return a list of the file names to be processed by schemagen. These are
* determined by processing the Ant style paths given in the <code>includes</code>
* and <code>excludes</code> parameters.
*
* @return Non-null but possibly empty list of files to process, sorted into lexical order
*/
protected List<String> matchFileNames() {
DirectoryScanner ds = new DirectoryScanner();
ds.setExcludes(excludes);
ds.setIncludes(includes);
ds.setBasedir(getBaseDir());
ds.scan();
List<String> files = new ArrayList<>(Arrays.asList(ds.getIncludedFiles()));
Collections.sort(files);
//add http includes
for (String include : includes) {
if (include.startsWith("http:") || include.startsWith("https:")) {
files.add(include);
}
}
return files;
}
use of org.codehaus.plexus.util.DirectoryScanner in project maven-plugins by apache.
the class JavadocUtil method addFilesFromSource.
/**
* Convenience method that gets the files to be included in the javadoc.
*
* @param sourceDirectory the directory where the source files are located
* @param files the variable that contains the appended filenames of the files to be included in the javadoc
* @param excludePackages the packages to be excluded in the javadocs
* @param sourceFileIncludes files to include.
* @param sourceFileExcludes files to exclude.
*/
protected static void addFilesFromSource(List<String> files, File sourceDirectory, List<String> sourceFileIncludes, List<String> sourceFileExcludes, String[] excludePackages) {
DirectoryScanner ds = new DirectoryScanner();
if (sourceFileIncludes == null) {
sourceFileIncludes = Collections.singletonList("**/*.java");
}
ds.setIncludes(sourceFileIncludes.toArray(new String[sourceFileIncludes.size()]));
if (sourceFileExcludes != null && sourceFileExcludes.size() > 0) {
ds.setExcludes(sourceFileExcludes.toArray(new String[sourceFileExcludes.size()]));
}
ds.setBasedir(sourceDirectory);
ds.scan();
String[] fileList = ds.getIncludedFiles();
String[] pathList = new String[fileList.length];
for (int x = 0; x < fileList.length; x++) {
pathList[x] = new File(sourceDirectory, fileList[x]).getAbsolutePath();
}
if (pathList.length != 0) {
List<String> tmpFiles = getIncludedFiles(sourceDirectory, pathList, excludePackages);
files.addAll(tmpFiles);
}
}
use of org.codehaus.plexus.util.DirectoryScanner in project sling by apache.
the class ValidationMojo method execute.
/**
* @see org.apache.maven.plugin.AbstractMojo#execute()
*/
public void execute() throws MojoExecutionException {
if (this.skip) {
getLog().info("Validation is skipped.");
return;
}
final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
while (rsrcIterator.hasNext()) {
final Resource rsrc = rsrcIterator.next();
final File directory = new File(rsrc.getDirectory());
if (directory.exists()) {
getLog().debug("Scanning " + rsrc.getDirectory());
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(directory);
if (rsrc.getExcludes() != null && rsrc.getExcludes().size() > 0) {
scanner.setExcludes((String[]) rsrc.getExcludes().toArray(new String[rsrc.getExcludes().size()]));
}
scanner.addDefaultExcludes();
if (rsrc.getIncludes() != null && rsrc.getIncludes().size() > 0) {
scanner.setIncludes((String[]) rsrc.getIncludes().toArray(new String[rsrc.getIncludes().size()]));
}
scanner.scan();
final String[] files = scanner.getIncludedFiles();
if (files != null) {
for (int m = 0; m < files.length; m++) {
this.validate(directory, files[m]);
}
}
}
}
}
use of org.codehaus.plexus.util.DirectoryScanner in project webservices-axiom by apache.
the class PostProcessMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!classesDir.exists()) {
return;
}
DirectoryScanner ds = new DirectoryScanner();
ds.setIncludes(new String[] { "**/*.class" });
ds.setBasedir(classesDir);
ds.scan();
for (String relativePath : ds.getIncludedFiles()) {
File file = new File(classesDir, relativePath);
ClassWriter classWriter;
try {
InputStream in = new FileInputStream(file);
try {
ClassReader classReader = new ClassReader(in);
classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
ClassVisitor classVisitor = classWriter;
if (relativePath.equals("org/apache/axiom/om/OMText.class")) {
classVisitor = new GetDataHandlerBridgeMethodInjector(classVisitor);
}
classVisitor = new AspectJCodeRemover(classVisitor);
classReader.accept(classVisitor, 0);
} finally {
in.close();
}
} catch (IOException ex) {
throw new MojoExecutionException("Failed to read " + relativePath + ": " + ex.getMessage(), ex);
}
try {
OutputStream out = new FileOutputStream(file);
try {
out.write(classWriter.toByteArray());
} finally {
out.close();
}
} catch (IOException ex) {
throw new MojoExecutionException("Failed to write " + relativePath + ": " + ex.getMessage(), ex);
}
}
}
Aggregations