use of org.apache.maven.shared.model.fileset.util.FileSetManager in project jangaroo-tools by CoreMedia.
the class PropertiesMojo method execute.
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);
}
}
use of org.apache.maven.shared.model.fileset.util.FileSetManager in project asterixdb by apache.
the class TestDataGeneratorMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
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);
}
}
}
use of org.apache.maven.shared.model.fileset.util.FileSetManager in project jacoco by jacoco.
the class MergeMojo method load.
private void load(final ExecFileLoader loader) throws MojoExecutionException {
final FileSetManager fileSetManager = new FileSetManager(getLog());
for (final FileSet fileSet : fileSets) {
for (final String includedFilename : fileSetManager.getIncludedFiles(fileSet)) {
final File inputFile = new File(fileSet.getDirectory(), includedFilename);
if (inputFile.isDirectory()) {
continue;
}
try {
getLog().info("Loading execution data file " + inputFile.getAbsolutePath());
loader.load(inputFile);
} catch (final IOException e) {
throw new MojoExecutionException("Unable to read " + inputFile.getAbsolutePath(), e);
}
}
}
}
use of org.apache.maven.shared.model.fileset.util.FileSetManager in project maven-dependency-plugin by apache.
the class DependencyTestUtils method removeDirectory.
/**
* Deletes a directory and its contents.
*
* @param dir {@link File} The base directory of the included and excluded files.
* @throws IOException in case of an error. When a directory failed to get deleted.
*/
public static void removeDirectory(File dir) throws IOException {
if (dir != null) {
Log log = new SilentLog();
FileSetManager fileSetManager = new FileSetManager(log, false);
FileSet fs = new FileSet();
fs.setDirectory(dir.getPath());
fs.addInclude("**/**");
fileSetManager.delete(fs);
}
}
use of org.apache.maven.shared.model.fileset.util.FileSetManager in project maven-scm by apache.
the class AbstractScmMojo method handleExcludesIncludesAfterCheckoutAndExport.
protected void handleExcludesIncludesAfterCheckoutAndExport(File checkoutDirectory) throws MojoExecutionException {
List<String> includes = new ArrayList<String>();
if (!StringUtils.isBlank(this.getIncludes())) {
String[] tokens = StringUtils.split(this.getIncludes(), ",");
for (int i = 0; i < tokens.length; ++i) {
includes.add(tokens[i]);
}
}
List<String> excludes = new ArrayList<String>();
if (!StringUtils.isBlank(this.getExcludes())) {
String[] tokens = StringUtils.split(this.getExcludes(), ",");
for (int i = 0; i < tokens.length; ++i) {
excludes.add(tokens[i]);
}
}
if (includes.isEmpty() && excludes.isEmpty()) {
return;
}
FileSetManager fileSetManager = new FileSetManager();
FileSet fileset = new FileSet();
fileset.setDirectory(checkoutDirectory.getAbsolutePath());
// revert the order to do the delete
fileset.setIncludes(excludes);
fileset.setExcludes(includes);
fileset.setUseDefaultExcludes(false);
try {
fileSetManager.delete(fileset);
} catch (IOException e) {
throw new MojoExecutionException("Error found while cleaning up output directory base on " + "excludes/includes configurations.", e);
}
}
Aggregations