Search in sources :

Example 6 with FileSet

use of org.apache.maven.archetype.metadata.FileSet in project maven-archetype by apache.

the class FilesetArchetypeCreator method createArchetypeFiles.

private void createArchetypeFiles(Properties reverseProperties, List<FileSet> fileSets, String packageName, File basedir, File archetypeFilesDirectory, String defaultEncoding, List<String> excludePatterns) throws IOException {
    getLogger().debug("Creating Archetype/Module files from " + basedir + " to " + archetypeFilesDirectory);
    for (FileSet fileSet : fileSets) {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(basedir);
        scanner.setIncludes((String[]) concatenateToList(fileSet.getIncludes(), fileSet.getDirectory()).toArray(new String[fileSet.getIncludes().size()]));
        scanner.setExcludes((String[]) addLists(fileSet.getExcludes(), excludePatterns).toArray(new String[fileSet.getExcludes().size()]));
        scanner.addDefaultExcludes();
        getLogger().debug("Using fileset " + fileSet);
        scanner.scan();
        List<String> fileSetResources = Arrays.asList(scanner.getIncludedFiles());
        getLogger().debug("Scanned " + fileSetResources.size() + " resources");
        if (fileSet.isFiltered()) {
            processFileSet(basedir, archetypeFilesDirectory, fileSet.getDirectory(), fileSetResources, fileSet.isPackaged(), packageName, reverseProperties, defaultEncoding);
            getLogger().debug("Processed " + fileSet.getDirectory() + " files");
        } else {
            copyFiles(basedir, archetypeFilesDirectory, fileSet.getDirectory(), fileSetResources, fileSet.isPackaged(), packageName, reverseProperties);
            getLogger().debug("Copied " + fileSet.getDirectory() + " files");
        }
    }
}
Also used : FileSet(org.apache.maven.archetype.metadata.FileSet) DirectoryScanner(org.codehaus.plexus.util.DirectoryScanner)

Aggregations

FileSet (org.apache.maven.archetype.metadata.FileSet)6 ModuleDescriptor (org.apache.maven.archetype.metadata.ModuleDescriptor)2 Model (org.apache.maven.model.Model)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 TemplateCreationException (org.apache.maven.archetype.exception.TemplateCreationException)1 ArchetypeDescriptor (org.apache.maven.archetype.metadata.ArchetypeDescriptor)1 ArchetypeDescriptorXpp3Writer (org.apache.maven.archetype.metadata.io.xpp3.ArchetypeDescriptorXpp3Writer)1 Resource (org.apache.maven.model.Resource)1 MavenProject (org.apache.maven.project.MavenProject)1 DefaultInvocationRequest (org.apache.maven.shared.invoker.DefaultInvocationRequest)1 InvocationRequest (org.apache.maven.shared.invoker.InvocationRequest)1 InvocationResult (org.apache.maven.shared.invoker.InvocationResult)1 DirectoryScanner (org.codehaus.plexus.util.DirectoryScanner)1 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)1