use of org.eclipse.mylyn.wikitext.maven.internal.SourceFileTraversal.Visitor in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
try {
ensureOutputFolderExists();
ensureSourceFolderExists();
ServiceLocator serviceLocator = ServiceLocator.getInstance(MarkupToEclipseHelpMojo.class.getClassLoader());
Set<MarkupLanguage> markupLanguages = serviceLocator.getAllMarkupLanguages();
if (markupLanguages.isEmpty()) {
throw new MojoFailureException("No markup languages are available");
}
getLog().info(format("Generating Eclipse help content from sources: {0} -> {1}", sourceFolder, outputFolder));
final FileToMarkupLanguage fileToMarkupLanguage = new FileToMarkupLanguage(markupLanguages);
SourceFileTraversal fileTraversal = new SourceFileTraversal(sourceFolder);
final AtomicInteger fileCount = new AtomicInteger();
fileTraversal.traverse(new Visitor() {
@Override
public void accept(String relativePath, File sourceFile) {
fileCount.incrementAndGet();
process(sourceFile, relativePath, fileToMarkupLanguage.get(sourceFile));
}
});
getLog().info(format("Processed {0} files", fileCount.get()));
} catch (BuildFailureException e) {
getLog().error(e.getMessage(), e);
throw new MojoFailureException(e.getMessage(), e.getCause());
}
}
use of org.eclipse.mylyn.wikitext.maven.internal.SourceFileTraversal.Visitor in project mylyn.docs by eclipse.
the class SourceFileTraversalTest method traverseRootMatch.
@Test
public void traverseRootMatch() {
File file = mockFile("one.Test");
SourceFileTraversal traversal = new SourceFileTraversal(mockFolder("test", file));
Visitor visitor = mock(Visitor.class);
traversal.traverse(visitor);
verify(visitor).accept(eq(""), same(file));
verifyNoMoreInteractions(visitor);
}
use of org.eclipse.mylyn.wikitext.maven.internal.SourceFileTraversal.Visitor in project mylyn.docs by eclipse.
the class SourceFileTraversalTest method traverseMatchWithPath.
@Test
public void traverseMatchWithPath() {
File file = mockFile("one.Test");
SourceFileTraversal traversal = new SourceFileTraversal(mockFolder("test", mockFolder("depth1", mockFolder("depth2", file))));
Visitor visitor = mock(Visitor.class);
traversal.traverse(visitor);
verify(visitor).accept(eq("depth1" + File.separator + "depth2"), same(file));
verifyNoMoreInteractions(visitor);
}
Aggregations