final List includes = optimizeIncludes != null ? optimizeIncludes : (surefireIncludes != null) ? surefireIncludes : DEFAULT_INCLUDES;
final List excludes = optimizeExcludes != null ? optimizeExcludes : surefireExcludes;
final CloverOptimisedTestSet testsToRun = new CloverOptimisedTestSet();
testsToRun.setProject(antProj);
testsToRun.setLogger(new MvnLogger(getLog()));
antProj.setProperty(CloverNames.PROP_INITSTRING, getCloverDatabase());
antProj.setName(getProject().getName());
final List testSources = getProject().getTestCompileSourceRoots();
for (Iterator iterator = testSources.iterator(); iterator.hasNext();) {
String testRoot = (String) iterator.next();
final File testRootDir = new File(testRoot);
if (!testRootDir.exists()) {
// if the test dir does not exist, do not add this as a fileset.
continue;
}
FileSet testFileSet = new FileSet();
testFileSet.setProject(antProj);
testFileSet.setDir(testRootDir);
testFileSet.appendIncludes((String[]) includes.toArray(new String[includes.size()]));
getLog().info("INCLUDING: " + includes);
if (excludes != null && excludes.size() > 0) {
testFileSet.appendExcludes((String[]) excludes.toArray(new String[excludes.size()]));
getLog().info("EXCLUDING: " + excludes);
}
testsToRun.add(testFileSet);
}
return testsToRun.getOptimisedTestResource();
}