use of org.kohsuke.stapler.jelly.JellyClassLoaderTearOff in project hudson-2.x by hudson.
the class JellyTestSuiteBuilder method build.
/**
* Given a jar file or a class file directory, recursively search all the Jelly files and build a {@link TestSuite}
* that performs static syntax checks.
*/
public static TestSuite build(File res) throws Exception {
TestSuite ts = new JellyTestSuite();
final JellyClassLoaderTearOff jct = new MetaClassLoader(JellyTestSuiteBuilder.class.getClassLoader()).loadTearOff(JellyClassLoaderTearOff.class);
if (res.isDirectory()) {
for (final File jelly : (Collection<File>) FileUtils.listFiles(res, new String[] { "jelly" }, true)) ts.addTest(new JellyCheck(jelly.toURI().toURL(), jct));
}
if (res.getName().endsWith(".jar")) {
String jarUrl = res.toURI().toURL().toExternalForm();
JarFile jf = new JarFile(res);
Enumeration<JarEntry> e = jf.entries();
while (e.hasMoreElements()) {
JarEntry ent = e.nextElement();
if (ent.getName().endsWith(".jelly"))
ts.addTest(new JellyCheck(new URL("jar:" + jarUrl + "!/" + ent.getName()), jct));
}
jf.close();
}
return ts;
}
Aggregations