Search in sources :

Example 1 with FileSetManager

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);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PropertyClassGenerator(net.jangaroo.properties.PropertyClassGenerator) PropcException(net.jangaroo.properties.api.PropcException) IOException(java.io.IOException) File(java.io.File) FileLocations(net.jangaroo.utils.FileLocations) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 2 with FileSetManager

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);
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) File(java.io.File) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 3 with FileSetManager

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);
            }
        }
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) File(java.io.File) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 4 with FileSetManager

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);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) Log(org.apache.maven.plugin.logging.Log) SilentLog(org.apache.maven.plugin.testing.SilentLog) SilentLog(org.apache.maven.plugin.testing.SilentLog) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Example 5 with FileSetManager

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);
    }
}
Also used : FileSet(org.apache.maven.shared.model.fileset.FileSet) ScmFileSet(org.apache.maven.scm.ScmFileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) FileSetManager(org.apache.maven.shared.model.fileset.util.FileSetManager)

Aggregations

FileSetManager (org.apache.maven.shared.model.fileset.util.FileSetManager)6 FileSet (org.apache.maven.shared.model.fileset.FileSet)5 IOException (java.io.IOException)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 File (java.io.File)3 Log (org.apache.maven.plugin.logging.Log)2 SilentLog (org.apache.maven.plugin.testing.SilentLog)2 ArrayList (java.util.ArrayList)1 PropertyClassGenerator (net.jangaroo.properties.PropertyClassGenerator)1 PropcException (net.jangaroo.properties.api.PropcException)1 FileLocations (net.jangaroo.utils.FileLocations)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1