Example usage for org.apache.maven.project MavenProject getResources

List of usage examples for org.apache.maven.project MavenProject getResources

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getResources.

Prototype

public List<Resource> getResources() 

Source Link

Usage

From source file:org.jszip.maven.RunMojo.java

License:Apache License

private long processResourceSourceChanges(List<MavenProject> reactorProjects, MavenProject project,
        long lastModified) throws ArtifactFilterException {
    long newLastModified = lastModified;
    getLog().debug("Last modified for resource sources = " + lastModified);

    Set<File> checked = new HashSet<File>();
    for (Artifact a : getOverlayArtifacts(project, scope)) {
        MavenProject p = findProject(reactorProjects, a);
        if (p == null || p.getBuild() == null || p.getBuild().getResources() == null) {
            continue;
        }//from   ww w.  ja  v  a2s . co  m
        boolean changed = false;
        boolean changedFiltered = false;
        for (org.apache.maven.model.Resource r : p.getBuild().getResources()) {
            File dir = new File(r.getDirectory());
            getLog().debug("Checking last modified for " + dir);
            if (checked.contains(dir)) {
                continue;
            }
            checked.add(dir);
            long dirLastModified = recursiveLastModified(dir);
            if (lastModified < dirLastModified) {
                changed = true;
                if (r.isFiltering()) {
                    changedFiltered = true;
                }
            }
        }
        if (changedFiltered) {
            getLog().info("Detected change in resources of " + ArtifactUtils.versionlessKey(a) + "...");
            getLog().debug("Resource filtering is used by project, invoking Maven to handle update");
            // need to let Maven handle it as its the only (although slower) safe way to do it right with filters
            InvocationRequest request = new DefaultInvocationRequest();
            request.setPomFile(p.getFile());
            request.setInteractive(false);
            request.setRecursive(false);
            request.setGoals(Collections.singletonList("process-resources"));

            Invoker invoker = new DefaultInvoker();
            invoker.setLogger(new MavenProxyLogger());
            try {
                invoker.execute(request);
                newLastModified = System.currentTimeMillis();
                getLog().info("Change in resources of " + ArtifactUtils.versionlessKey(a) + " processed");
            } catch (MavenInvocationException e) {
                getLog().info(e);
            }
        } else if (changed) {
            getLog().info("Detected change in resources of " + ArtifactUtils.versionlessKey(a) + "...");
            getLog().debug("Resource filtering is not used by project, handling update ourselves");
            // can do it fast ourselves
            MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution(p.getResources(),
                    new File(p.getBuild().getOutputDirectory()), p,
                    p.getProperties().getProperty("project.build.sourceEncoding"), Collections.emptyList(),
                    Collections.<String>emptyList(), session);
            try {
                mavenResourcesFiltering.filterResources(mavenResourcesExecution);
                newLastModified = System.currentTimeMillis();
                getLog().info("Change in resources of " + ArtifactUtils.versionlessKey(a) + " processed");
            } catch (MavenFilteringException e) {
                getLog().info(e);
            }
        }
    }
    return newLastModified;
}

From source file:org.maven.ide.eclipse.wtp.AbstractProjectConfiguratorDelegate.java

License:Open Source License

protected void configureWtpUtil(IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
    // Adding utility facet on JEE projects is not allowed
    IProject project = facade.getProject();
    MavenProject mavenProject = facade.getMavenProject();
    if (!WTPProjectsUtil.isJavaProject(facade) || WTPProjectsUtil.isJavaEEProject(project)
            || WTPProjectsUtil.isQualifiedAsWebFragment(facade)) {
        return;//from   www. j a  v  a 2s . co  m
    }

    //MECLIPSEWTP-66 delete extra MANIFEST.MF
    // 1 - predict where the MANIFEST.MF will be created
    IFolder firstInexistentfolder = null;
    IPath[] sourceRoots = MavenProjectUtils.getSourceLocations(project, mavenProject.getCompileSourceRoots());
    IPath[] resourceRoots = MavenProjectUtils.getResourceLocations(project, mavenProject.getResources());

    //MECLIPSEWTP-182 check if the Java Project configurator has been successfully run before doing anything : 
    if (!checkJavaConfiguration(project, sourceRoots, resourceRoots)) {
        LOG.warn("{} Utility Facet configuration is aborted as the Java Configuration is inconsistent",
                project.getName());
        return;
    }

    boolean isDebugEnabled = DebugUtilities.isDebugEnabled();
    if (isDebugEnabled) {
        DebugUtilities.debug(DebugUtilities.dumpProjectState("Before configuration ", project));
    }

    IPath sourceFolder = null;
    if ((sourceRoots == null || sourceRoots.length == 0) || !project.getFolder(sourceRoots[0]).exists()) {
        sourceRoots = MavenProjectUtils.getResourceLocations(project, mavenProject.getResources());
    }
    if ((sourceRoots != null && sourceRoots.length > 0 && project.getFolder(sourceRoots[0]).exists())) {
        sourceFolder = sourceRoots[0];
    }
    IContainer contentFolder = sourceFolder == null ? project : project.getFolder(sourceFolder);
    IFile manifest = contentFolder.getFile(new Path("META-INF/MANIFEST.MF"));

    // 2 - check if the manifest already exists, and its parent folder
    boolean manifestAlreadyExists = manifest.exists();
    if (!manifestAlreadyExists) {
        firstInexistentfolder = findFirstInexistentFolder(project, contentFolder, manifest);
    }

    IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
    Set<Action> actions = new LinkedHashSet<Action>();
    installJavaFacet(actions, project, facetedProject);

    if (!facetedProject.hasProjectFacet(WTPProjectsUtil.UTILITY_FACET)) {
        actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, WTPProjectsUtil.UTILITY_10,
                null));
    } else if (!facetedProject.hasProjectFacet(WTPProjectsUtil.UTILITY_10)) {
        actions.add(new IFacetedProject.Action(IFacetedProject.Action.Type.VERSION_CHANGE,
                WTPProjectsUtil.UTILITY_10, null));
    }

    if (!actions.isEmpty()) {
        facetedProject.modify(actions, monitor);
    }

    fixMissingModuleCoreNature(project, monitor);

    if (isDebugEnabled) {
        DebugUtilities.debug(DebugUtilities.dumpProjectState("after configuration ", project));
    }
    //MNGECLIPSE-904 remove tests folder links for utility jars
    removeTestFolderLinks(project, mavenProject, monitor, "/");

    //Remove "library unavailable at runtime" warning.
    if (isDebugEnabled) {
        DebugUtilities.debug(DebugUtilities.dumpProjectState("after removing test folders ", project));
    }

    setNonDependencyAttributeToContainer(project, monitor);

    //MECLIPSEWTP-66 delete extra MANIFEST.MF
    // 3 - Remove extra manifest if necessary and its the parent hierarchy 
    if (firstInexistentfolder != null && firstInexistentfolder.exists()) {
        firstInexistentfolder.delete(true, monitor);
    }
    if (!manifestAlreadyExists && manifest.exists()) {
        manifest.delete(true, monitor);
    }

    WTPProjectsUtil.removeWTPClasspathContainer(project);
}

From source file:org.maven.ide.eclipse.wtp.ConnectorProjectConfiguratorDelegate.java

License:Open Source License

private void removeSourceLinks(IProject project, MavenProject mavenProject, IProgressMonitor monitor,
        String folder) throws CoreException {
    IVirtualComponent component = ComponentCore.createComponent(project);
    if (component != null) {
        IVirtualFolder jsrc = component.getRootFolder().getFolder(folder);
        for (IPath location : MavenProjectUtils.getSourceLocations(project,
                mavenProject.getCompileSourceRoots())) {
            jsrc.removeLink(location, 0, monitor);
        }//ww w .j  a  v a  2  s.co m
        for (IPath location : MavenProjectUtils.getResourceLocations(project, mavenProject.getResources())) {
            jsrc.removeLink(location, 0, monitor);
        }
    }
}

From source file:org.mobicents.maven.plugin.eclipse.ClasspathWriter.java

License:Open Source License

/**
 * Writes the source roots for the given project.
 * /* ww  w. j a  va2  s  .  c om*/
 * @param project
 *            the project for which to write the source roots.
 * @param rootDirectory
 *            the root project's base directory
 * @param writer
 *            the XMLWriter used to write the source roots.
 * @param includeResourcesDirectory
 */
private Set<String> collectSourceRoots(final MavenProject project, final String rootDirectory,
        final XMLWriter writer, boolean includeResourcesDirectory) {

    Set<String> sourcePaths = new TreeSet<String>();

    // collect source roots
    List<String> sourceRoots = new ArrayList<String>();
    sourceRoots.addAll(project.getCompileSourceRoots());
    sourceRoots.addAll(project.getTestCompileSourceRoots());
    for (String s : sourceRoots) {
        final String sourceRoot = PathNormalizer.normalizePath(s);
        if (new File(sourceRoot).isDirectory()) {
            String sourceRootPath = StringUtils.replace(sourceRoot, rootDirectory, "");
            if (sourceRootPath.startsWith("/")) {
                sourceRootPath = sourceRootPath.substring(1, sourceRootPath.length());
            }
            sourcePaths.add(sourceRootPath);
        }
    }

    if (includeResourcesDirectory) {

        // collect resources
        List<Resource> resources = new ArrayList<Resource>();
        resources.addAll(project.getResources());
        resources.addAll(project.getTestResources());
        for (Resource resource : resources) {
            final String resourceRoot = PathNormalizer.normalizePath(resource.getDirectory());
            File resourceDirectory = new File(resourceRoot);
            if (resourceDirectory.exists() && resourceDirectory.isDirectory()) {
                String resourceSourceRootPath = StringUtils.replace(resourceRoot, rootDirectory, "");
                if (resourceSourceRootPath.startsWith("/")) {
                    resourceSourceRootPath = resourceSourceRootPath.substring(1,
                            resourceSourceRootPath.length());
                }
                // we need to avoid nested paths, eclipse doesn't
                // support them
                // check if there is already a parent resource path
                boolean add = true;
                for (String resourcePath : sourcePaths) {
                    if (resourceSourceRootPath.startsWith(resourcePath)) {
                        // the one we are processing is a child folder,
                        // ignore it
                        add = false;
                        break;
                    }
                }
                if (add) {
                    for (String resourcePath : sourcePaths) {
                        if (resourcePath.startsWith(resourceSourceRootPath)) {
                            // the one we are processing is a parent
                            // folder, remove the child
                            sourcePaths.remove(resourcePath);
                        }
                    }
                    sourcePaths.add(resourceSourceRootPath);
                }
            }
        }
    }
    return sourcePaths;
}

From source file:org.netbeans.modules.jackpot30.maven.RunJackpot30.java

License:Open Source License

@SuppressWarnings("unchecked")
public static List<String> sourceAndCompileClassPaths(Iterable<? extends MavenProject> projects)
        throws DependencyResolutionRequiredException {
    List<String> compileSourceRoots = new ArrayList<String>();
    List<String> compileClassPath = new ArrayList<String>();

    for (MavenProject project : projects) {
        compileSourceRoots.addAll((List<String>) project.getCompileSourceRoots());

        for (Resource r : (List<Resource>) project.getResources()) {
            compileSourceRoots.add(r.getDirectory());
        }//from  w  w w. j  ava2  s  .  co  m

        compileClassPath.addAll((List<String>) project.getCompileClasspathElements());
    }

    return Arrays.asList("--sourcepath", toClassPathString(compileSourceRoots), "--classpath",
            toClassPathString(compileClassPath));
}

From source file:org.richfaces.builder.mojo.GenerateMojo.java

License:Open Source License

protected CdkClassLoader createProjectClassLoader(MavenProject project) {
    CdkClassLoader classLoader = null;//from w ww.  j av a  2 s . com

    try {
        // This Mojo executed befor process-resources phase, therefore we have to use original resource folders.
        List<Resource> resources = project.getResources();
        List<File> urls = new ArrayList<File>(classpathElements.size() + resources.size());
        for (Resource resource : resources) {
            String directory = resource.getDirectory();
            // TODO - use includes/excludes and target path.
            urls.add(resolveRelativePath(new File(directory)));
        }
        for (Iterator<String> iter = classpathElements.iterator(); iter.hasNext();) {
            String element = iter.next();

            urls.add(new File(element));
        }

        classLoader = new CdkClassLoader(urls);
    } catch (MalformedURLException e) {
        getLog().error("Bad URL in classpath", e);
    }

    return classLoader;
}

From source file:org.switchyard.tools.ui.common.impl.SwitchYardProject.java

License:Open Source License

private void init() {
    _version = null;/*from   w  ww .ja  va  2 s .c  o  m*/
    _versionPropertyKey = SWITCHYARD_VERSION;
    _components = Collections.emptySet();
    _rawVersionString = null;
    _usingDependencyManagement = false;
    _plugin = new SwitchYardConfigurePlugin();
    _switchYardConfigurationFile = null;

    MavenProject mavenProject = getMavenProject();
    if (mavenProject == null) {
        return;
    }

    _version = readSwitchYardVersion(mavenProject);
    _versionPropertyKey = readSwitchYardVersionPropertyKey(mavenProject);
    _rawVersionString = readRawVersionString(mavenProject);
    if (_rawVersionString == null) {
        _usingDependencyManagement = true;
    } else if (_rawVersionString == UNKNOWN_VERSION_STRING) {
        if (_version == null) {
            _usingDependencyManagement = false;
            _rawVersionString = "${" + _versionPropertyKey + "}"; //$NON-NLS-1$ //$NON-NLS-2$
        } else {
            _usingDependencyManagement = true;
            _rawVersionString = null;
        }
    }
    _components = readComponents(mavenProject);

    for (IPath resourceLocation : MavenProjectUtils.getResourceLocations(_project,
            mavenProject.getResources())) {
        IFile temp = _project.getFolder(resourceLocation).getFile("META-INF/switchyard.xml"); //$NON-NLS-1$
        if (_switchYardConfigurationFile == null) {
            _switchYardConfigurationFile = temp;
        }
        if (temp.exists()) {
            _switchYardConfigurationFile = temp;
            break;
        }
    }

    for (IPath resourceLocation : MavenProjectUtils.getResourceLocations(_project,
            mavenProject.getResources())) {
        IFile temp = _project.getFolder(resourceLocation).getFile("features.xml"); //$NON-NLS-1$
        if (_featuresFile == null) {
            _featuresFile = temp;
        }
        if (temp.exists()) {
            _featuresFile = temp;
            break;
        }
    }
}

From source file:org.wisdom.maven.utils.MavenUtils.java

License:Apache License

/**
 * Gets the default set of properties for the given project.
 *
 * @param currentProject the project/*from   w w  w . j a  v a2  s  . c  om*/
 * @return the set of properties, containing default bundle packaging instructions.
 */
public static Properties getDefaultProperties(MavenProject currentProject) {
    Properties properties = new Properties();
    String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact());

    // Setup defaults
    properties.put(MAVEN_SYMBOLICNAME, bsn);
    properties.put("bundle.file.name",
            DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact()));
    properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn);
    properties.put(Analyzer.IMPORT_PACKAGE, "*");
    properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion()));

    header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription());
    StringBuilder licenseText = printLicenses(currentProject.getLicenses());
    if (licenseText != null) {
        header(properties, Analyzer.BUNDLE_LICENSE, licenseText);
    }
    header(properties, Analyzer.BUNDLE_NAME, currentProject.getName());

    if (currentProject.getOrganization() != null) {
        if (currentProject.getOrganization().getName() != null) {
            String organizationName = currentProject.getOrganization().getName();
            header(properties, Analyzer.BUNDLE_VENDOR, organizationName);
            properties.put("project.organization.name", organizationName);
            properties.put("pom.organization.name", organizationName);
        }
        if (currentProject.getOrganization().getUrl() != null) {
            String organizationUrl = currentProject.getOrganization().getUrl();
            header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl);
            properties.put("project.organization.url", organizationUrl);
            properties.put("pom.organization.url", organizationUrl);
        }
    }

    properties.putAll(currentProject.getModel().getProperties());

    for (String s : currentProject.getFilters()) {
        File filterFile = new File(s);
        if (filterFile.isFile()) {
            properties.putAll(PropertyUtils.loadProperties(filterFile));
        }
    }

    properties.putAll(getProperties(currentProject.getModel(), "project.build."));
    properties.putAll(getProperties(currentProject.getModel(), "pom."));
    properties.putAll(getProperties(currentProject.getModel(), "project."));

    properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath());
    properties.put("project.build.directory", currentProject.getBuild().getDirectory());
    properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory());

    properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots()));
    properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots()));

    properties.put("project.resources", toString(currentProject.getResources()));
    properties.put("project.testResources", toString(currentProject.getTestResources()));

    return properties;
}

From source file:se.jguru.nazgul.tools.plugin.checkstyle.exec.DefaultCheckstyleExecutor.java

License:Apache License

public CheckstyleResults executeCheckstyle(CheckstyleExecutorRequest request)
        throws CheckstyleExecutorException, CheckstyleException {

    // Checkstyle will always use the context classloader in order
    // to load resources (dtds), so we have to fix it
    // olamy this hack is not anymore needed in Maven 3.x
    ClassLoader checkstyleClassLoader = PackageNamesLoader.class.getClassLoader();
    Thread.currentThread().setContextClassLoader(checkstyleClassLoader);

    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executeCheckstyle start headerLocation : " + request.getHeaderLocation());
    }/*from  w  ww  .ja  v  a  2 s .  c  om*/

    MavenProject project = request.getProject();

    configureResourceLocator(locator, request, null);

    configureResourceLocator(licenseLocator, request, request.getLicenseArtifacts());

    // Config is less critical than License, locator can still be used.
    // configureResourceLocator( configurationLocator, request, request.getConfigurationArtifacts() );

    List<File> files;
    try {
        files = getFilesToProcess(request);
    } catch (IOException e) {
        throw new CheckstyleExecutorException("Error getting files to process", e);
    }

    final String suppressionsFilePath = getSuppressionsFilePath(request);
    FilterSet filterSet = getSuppressionsFilterSet(suppressionsFilePath);

    Checker checker = new Checker();

    // setup classloader, needed to avoid "Unable to get class information for ..." errors
    List<String> classPathStrings = new ArrayList<>();
    List<String> outputDirectories = new ArrayList<>();

    // stand-alone
    Collection<File> sourceDirectories = null;
    Collection<File> testSourceDirectories = request.getTestSourceDirectories();

    // aggregator
    Map<MavenProject, Collection<File>> sourceDirectoriesByProject = new HashMap<>();
    Map<MavenProject, Collection<File>> testSourceDirectoriesByProject = new HashMap<>();

    if (request.isAggregate()) {
        for (MavenProject childProject : request.getReactorProjects()) {
            sourceDirectories = new ArrayList<>(childProject.getCompileSourceRoots().size());
            List<String> compileSourceRoots = childProject.getCompileSourceRoots();
            for (String compileSourceRoot : compileSourceRoots) {
                sourceDirectories.add(new File(compileSourceRoot));
            }
            sourceDirectoriesByProject.put(childProject, sourceDirectories);

            testSourceDirectories = new ArrayList<>(childProject.getTestCompileSourceRoots().size());
            List<String> testCompileSourceRoots = childProject.getTestCompileSourceRoots();
            for (String testCompileSourceRoot : testCompileSourceRoots) {
                testSourceDirectories.add(new File(testCompileSourceRoot));
            }
            testSourceDirectoriesByProject.put(childProject, testSourceDirectories);

            prepareCheckstylePaths(request, childProject, classPathStrings, outputDirectories,
                    sourceDirectories, testSourceDirectories);
        }
    } else {
        sourceDirectories = request.getSourceDirectories();
        prepareCheckstylePaths(request, project, classPathStrings, outputDirectories, sourceDirectories,
                testSourceDirectories);
    }

    final List<URL> urls = new ArrayList<>(classPathStrings.size());

    for (String path : classPathStrings) {
        try {
            urls.add(new File(path).toURL());
        } catch (MalformedURLException e) {
            throw new CheckstyleExecutorException(e.getMessage(), e);
        }
    }

    for (String outputDirectoryString : outputDirectories) {
        try {
            if (outputDirectoryString != null) {
                File outputDirectoryFile = new File(outputDirectoryString);
                if (outputDirectoryFile.exists()) {
                    URL outputDirectoryUrl = outputDirectoryFile.toURL();
                    getLogger().debug("Adding the outputDirectory " + outputDirectoryUrl.toString()
                            + " to the Checkstyle class path");
                    urls.add(outputDirectoryUrl);
                }
            }
        } catch (MalformedURLException e) {
            throw new CheckstyleExecutorException(e.getMessage(), e);
        }
    }

    URLClassLoader projectClassLoader = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() {
        public URLClassLoader run() {
            return new URLClassLoader(urls.toArray(new URL[urls.size()]), null);
        }
    });

    checker.setClassLoader(projectClassLoader);

    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());

    if (filterSet != null) {
        checker.addFilter(filterSet);
    }
    Configuration configuration = getConfiguration(request);
    checker.configure(configuration);

    AuditListener listener = request.getListener();

    if (listener != null) {
        checker.addListener(listener);
    }

    if (request.isConsoleOutput()) {
        checker.addListener(request.getConsoleListener());
    }

    CheckstyleCheckerListener checkerListener = new CheckstyleCheckerListener(configuration);
    if (request.isAggregate()) {
        for (MavenProject childProject : request.getReactorProjects()) {
            sourceDirectories = sourceDirectoriesByProject.get(childProject);
            testSourceDirectories = testSourceDirectoriesByProject.get(childProject);
            addSourceDirectory(checkerListener, sourceDirectories, testSourceDirectories,
                    childProject.getResources(), request);
        }
    } else {
        addSourceDirectory(checkerListener, sourceDirectories, testSourceDirectories, request.getResources(),
                request);
    }

    checker.addListener(checkerListener);

    int nbErrors = checker.process(files);

    checker.destroy();

    if (projectClassLoader instanceof Closeable) {
        try {
            ((Closeable) projectClassLoader).close();
        } catch (IOException ex) {
            // Nothing we can do - and not detrimental to the build (save running out of file handles).
            getLogger().info("Failed to close custom Classloader - this indicated a bug in the code.", ex);
        }
    }

    if (request.getStringOutputStream() != null) {
        String message = request.getStringOutputStream().toString().trim();

        if (message.length() > 0) {
            getLogger().info(message);
        }
    }

    if (nbErrors > 0) {
        StringBuilder message = new StringBuilder("There ");
        if (nbErrors == 1) {
            message.append("is");
        } else {
            message.append("are");
        }
        message.append(" ");
        message.append(nbErrors);
        message.append(" error");
        if (nbErrors != 1) {
            message.append("s");
        }
        message.append(" reported by Checkstyle");
        String version = getCheckstyleVersion();
        if (version != null) {
            message.append(" ");
            message.append(version);
        }
        message.append(" with ");
        message.append(request.getConfigLocation());
        message.append(" ruleset.");

        if (request.isFailsOnError()) {
            // TODO: should be a failure, not an error. Report is not meant to
            // throw an exception here (so site would
            // work regardless of config), but should record this information
            throw new CheckstyleExecutorException(message.toString());
        } else {
            getLogger().info(message.toString());
        }
    }

    return checkerListener.getResults();
}

From source file:se.jguru.nazgul.tools.plugin.checkstyle.exec.DefaultCheckstyleExecutor.java

License:Apache License

private List<File> getFilesToProcess(CheckstyleExecutorRequest request) throws IOException {
    StringBuilder excludesStr = new StringBuilder();

    if (StringUtils.isNotEmpty(request.getExcludes())) {
        excludesStr.append(request.getExcludes());
    }//from w ww  .j  ava2s.  com

    String[] defaultExcludes = FileUtils.getDefaultExcludes();
    for (String defaultExclude : defaultExcludes) {
        if (excludesStr.length() > 0) {
            excludesStr.append(",");
        }

        excludesStr.append(defaultExclude);
    }

    Set<File> files = new LinkedHashSet<>();
    if (request.isAggregate()) {
        for (MavenProject project : request.getReactorProjects()) {
            Set<File> sourceDirectories = new LinkedHashSet<>();

            // CompileSourceRoots are absolute paths
            List<String> compileSourceRoots = project.getCompileSourceRoots();
            for (String compileSourceRoot : compileSourceRoots) {
                sourceDirectories.add(new File(compileSourceRoot));
            }

            Set<File> testSourceDirectories = new LinkedHashSet<>();
            // CompileSourceRoots are absolute paths
            List<String> testCompileSourceRoots = project.getTestCompileSourceRoots();
            for (String testCompileSourceRoot : testCompileSourceRoots) {
                testSourceDirectories.add(new File(testCompileSourceRoot));
            }

            addFilesToProcess(request, sourceDirectories, project.getResources(), project.getTestResources(),
                    files, testSourceDirectories);
        }
    } else {
        Collection<File> sourceDirectories = request.getSourceDirectories();
        addFilesToProcess(request, sourceDirectories, request.getResources(), request.getTestResources(), files,
                request.getTestSourceDirectories());
    }

    getLogger().debug("Added " + files.size() + " files to process.");

    return new ArrayList<>(files);
}