Package org.codehaus.plexus.util

Examples of org.codehaus.plexus.util.DirectoryScanner


            {
                log.info("Additional resource directory does not exist: " + resourceDirectory);
                continue;
            }

            DirectoryScanner scanner = new DirectoryScanner();

            scanner.setBasedir(resourceDirectory);
            if (fileSet.getIncludes() != null && !fileSet.getIncludes().isEmpty())
                //noinspection unchecked
                scanner.setIncludes((String[]) fileSet.getIncludes().toArray(emptyStrArray));
            else
                scanner.setIncludes(DEFAULT_INCLUDES);

            if (fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty())
                //noinspection unchecked
                scanner.setExcludes((String[]) fileSet.getExcludes().toArray(emptyStrArray));

            scanner.addDefaultExcludes();
            scanner.scan();

            List includedFiles = Arrays.asList(scanner.getIncludedFiles());

            log.info("Copying " + includedFiles.size() + " web resource" + (includedFiles.size() > 1 ? "s" : ""));

            for (Object includedFile : includedFiles)
            {
View Full Code Here


        }
    }

    private String[] findArtifacts(String path) throws MojoExecutionException
    {
        DirectoryScanner scanner = new DirectoryScanner();

        FileSet fileSet = new FileSet();
        fileSet.setDirectory(path);

        if (policy.toLowerCase().equals("snapshot"))
        {
            prepareInclusionSet(fileSet);
            // fileSet.addInclude(SNAPSHOT_JARS);
            // fileSet.addInclude(SNAPSHOT_WARS);
            prepareExclusionSet(fileSet);
        }
        else
        {
            prepareInclusionSet(fileSet);
            prepareExclusionSet(fileSet);

            fileSet.addExclude(SNAPSHOT_JARS);
            fileSet.addExclude(SNAPSHOT_WARS);
        }

        // Include default artifact types:
        // fileSet.addInclude(INCLUDES_JARS);
        // fileSet.addInclude(INCLUDES_WARS);

        File resourceDirectory = new File(fileSet.getDirectory());
        String[] finalIncludes = new String[fileSet.getIncludes().size()];
        String[] finalExcludes = new String[fileSet.getExcludes().size()];

        finalIncludes = fileSet.getIncludes().toArray(finalIncludes);
        finalExcludes = fileSet.getExcludes().toArray(finalExcludes);

        System.out.println("Includes: " + Arrays.toString(finalIncludes));
        System.out.println("Excludes: " + Arrays.toString(finalExcludes));

        scanner.setBasedir(resourceDirectory);
        scanner.setIncludes(finalIncludes);

        if (fileSet.getExcludes() != null && !fileSet.getExcludes().isEmpty())
            scanner.setExcludes(finalExcludes);

        scanner.addDefaultExcludes();
        scanner.scan();

        return scanner.getIncludedFiles();
    }
View Full Code Here

            return;
        }
        if (destRoot == null) {
            throw new MojoFailureException("destination directory for " + srcRoot + " is null");
        }
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(srcRoot);
        if ( (srcIncludes != null) && !srcIncludes.isEmpty() ) {
            scanner.setIncludes( srcIncludes.toArray( EMPTY_STRING_ARRAY ) );
        } else {
            scanner.setIncludes(getDefaultIncludes());
        }
        if ( (srcExcludes != null) && !srcExcludes.isEmpty() ) {
            scanner.setExcludes( srcExcludes.toArray( EMPTY_STRING_ARRAY ) );
        }
        if ((excludes != null) && !excludes.isEmpty()) {
            scanner.setExcludes( excludes.toArray( EMPTY_STRING_ARRAY ) );
        }
        scanner.addDefaultExcludes();
        scanner.scan();
        for(String name :scanner.getIncludedFiles() ) {
            SourceFile src = new SourceFile(srcRoot, destRoot, name, destAsSource);
            jsErrorReporter_.setDefaultFileName("..." + src.toFile().getAbsolutePath().substring(project.getBasedir().getAbsolutePath().length()));
            processFile(src);
        }
    }
View Full Code Here

        return back;
    }

    private void addInto(String include, List<File> includedFiles) throws Exception {
        if (include.indexOf('*') > -1) {
            DirectoryScanner scanner = newScanner();
            scanner.setIncludes(new String[] { include });
            scanner.scan();
            String[] rpaths = scanner.getIncludedFiles();
            Arrays.sort(rpaths);
            for (String rpath : rpaths) {
                File file = new File(scanner.getBasedir(), rpath);
                if (!includedFiles.contains(file)) {
                    includedFiles.add(file);
                }
            }
        } else {
View Full Code Here

            }
        }
    }

    private DirectoryScanner newScanner() throws Exception {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(inputDir);
        if ((excludes != null) && (excludes.length != 0)) {
            scanner.setExcludes(excludes);
        }
        scanner.addDefaultExcludes();
        return scanner;
    }
View Full Code Here

        // so that velocity can easily process any resources inside the JAR that need to be processed.

        RemoteResourcesBundle remoteResourcesBundle = new RemoteResourcesBundle();
        remoteResourcesBundle.setSourceEncoding( sourceEncoding );

        DirectoryScanner scanner = new DirectoryScanner();

        scanner.setBasedir( resourcesDirectory );
        if ( includes != null && includes.length != 0 )
        {
            scanner.setIncludes( includes );
        }
        else
        {
            scanner.setIncludes( DEFAULT_INCLUDES );
        }

        if ( excludes != null && excludes.length != 0 )
        {
            scanner.setExcludes( excludes );
        }

        scanner.addDefaultExcludes();
        scanner.scan();

        List<String> includedFiles = Arrays.asList( scanner.getIncludedFiles() );

        for ( String resource : includedFiles )
        {
            remoteResourcesBundle.addRemoteResource( StringUtils.replace( resource, '\\', '/' ) );
        }
View Full Code Here

     *
     * @return A container of files, which are being checked.
     */
    protected IReportable getResources()
    {
        final DirectoryScanner ds = new DirectoryScanner();
        ds.setBasedir( basedir );
        setExcludes( ds );
        setIncludes( ds );
        ds.scan();
        whenDebuggingLogExcludedFiles(ds);
        final String[] files = ds.getIncludedFiles();
        logAboutIncludedFiles(files);
        try
        {
            return new FilesReportable( basedir, files );
        }
View Full Code Here

        if ( pSource.isDirectory() )
        {
            if ( !pTarget.isDirectory()  &&  !pTarget.mkdirs() ) {
                throw new IOException("Unable to create directory: " + pTarget);
            }
            final DirectoryScanner scanner = new DirectoryScanner();
            scanner.setBasedir(pSource);
            scanner.addDefaultExcludes();
            scanner.setIncludes(new String[]{"*"});
            scanner.scan();
            final String[] dirs = scanner.getIncludedDirectories();

            for (final String dir : dirs) {
                if (!"".equals(dir)) {
                    copy(new File(pSource, dir), new File(pTarget, dir));
                }
            }
            final String[] files = scanner.getIncludedFiles();
            for (String file : files) {
                copy(new File(pSource, file), new File(pTarget, file));
            }
        }
        else if ( pSource.isFile() )
View Full Code Here

    }

    private String[] getRelativePaths( File baseDir, String pattern )
            throws MojoFailureException
    {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir( baseDir );
        scanner.setIncludes( new String[] { pattern } );
        scanner.scan();

        return scanner.getIncludedFiles();
    }
View Full Code Here

            }
        }
    }

    private void compile(String pattern, File sourceDir, File outputDir, Compiler compiler) {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(sourceDir);
        scanner.setIncludes(new String[]{ pattern });
       
        scanner.scan();
        compiler.compile(Lists.newArrayList(scanner.getIncludedFiles()), sourceDir, outputDir);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.DirectoryScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.