for (Object obj : paths) {
String path = (String) obj;
if (StringUtils.endsWith(path, ".jar")) {
- libs.add(StringUtils.removeStart(path, "/WEB-INF/lib/"));
+ String filename = StringUtils.removeStart(path, "/WEB-INF/lib/");
+ if (!isIgnored(filename)) {
+ libs.add(filename);
+ }
}
}
return libs;
}
+ private static String[] IGNORE = { "derby", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty" };
+
+ /**
+ * Dirty hack to disable downloading for certain files.
+ */
+ static boolean isIgnored(String filename) {
+ for (String prefix : IGNORE) {
+ if (StringUtils.startsWith(filename, prefix)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @return part of request URL after servlet path
*/
assertThat(servlet.getLibs().size(), is(1));
assertThat(servlet.getLibs().get(0), is("sonar-core-2.6.jar"));
}
+
+ @Test
+ public void shouldIgnore() {
+ assertThat(BatchResourcesServlet.isIgnored("sonar-batch-2.6-SNAPSHOT.jar"), is(false));
+ assertThat(BatchResourcesServlet.isIgnored("derby-10.6.1.0.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("derbyclient-10.6.1.0.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("derbynet-10.6.1.0.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("mysql-connector-java-5.1.13.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("postgresql-9.0-801.jdbc3.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("jtds-1.2.4.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("jfreechart-1.0.9.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("eastwood-1.1.0.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("jetty-util-6.1.24.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("jruby-complete-1.5.6.jar"), is(true));
+ assertThat(BatchResourcesServlet.isIgnored("jruby-rack-1.0.5.jar"), is(true));
+ }
}