}
final List includes = optimizeIncludes != null ? optimizeIncludes : (surefireIncludes != null) ? surefireIncludes : DEFAULT_INCLUDES;
final List excludes = optimizeExcludes != null ? optimizeExcludes : surefireExcludes;
final CloverOptimizedTestSet testsToRun = new CloverOptimizedTestSet();
testsToRun.setProject(antProj);
testsToRun.setLogger(new MvnLogger(getLog()));
testsToRun.setFullRunEvery(fullRunEvery);
testsToRun.setDebug(debug);
testsToRun.setSnapshotFile(new ConfigUtil(this).resolveSnapshotFile(snapshot));
if (ordering != null) {
CloverOptimizedTestSet.TestOrdering order = new CloverOptimizedTestSet.TestOrdering();
order.setValue(ordering);
testsToRun.setOrdering(order);
}
testsToRun.setMinimize(minimize);
testsToRun.setEnabled(enabled);
antProj.setProperty(CloverNames.PROP_INITSTRING, resolveCloverDatabase());
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().debug("Appending includes: " + includes);
if (excludes != null && excludes.size() > 0) {
testFileSet.appendExcludes((String[]) excludes.toArray(new String[excludes.size()]));
getLog().debug("Appending excludes: " + excludes);
}
testsToRun.add(testFileSet);
if (alwaysRunTests != null) {
// create fileset
final FileSet alwaysRunFileSet = new FileSet();
alwaysRunFileSet.setProject(antProj);
alwaysRunFileSet.setDir(testRootDir);
alwaysRunFileSet.appendIncludes((String[]) alwaysRunTests.toArray(new String[alwaysRunTests.size()]));
// add it to an AlwaysRunTestSet
final CloverAlwaysRunTestSet alwaysRunTestSet = new CloverAlwaysRunTestSet();
alwaysRunTestSet.setProject(antProj);
alwaysRunTestSet.add(alwaysRunFileSet);
// then add that to the OptimizedTestSet
testsToRun.add(alwaysRunTestSet);
}
}
return testsToRun.getOptimizedTestResource();
}