362362951c regressed handling of optional dependencies.

This commit is contained in:
Jesse Glick committed 2013-01-30 15:13:12 -05:00
1 parent 8035cda484
commit e11c01cde7
1 file changed
+12
@@ -1467,10 +1467,22 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
if(dependencies!=null) {
MavenEmbedder embedder = MavenUtil.createEmbedder(new StreamTaskListener(System.out,Charset.defaultCharset()),(File)null,null);
for( String dep : dependencies.split(",")) {
String suffix = ";resolution:=optional";
boolean optional = dep.endsWith(suffix);
if (optional) {
dep = dep.substring(0, dep.length() - suffix.length());
}
String[] tokens = dep.split(":");
String artifactId = tokens[0];
String version = tokens[1];
File dependencyJar=resolveDependencyJar(embedder,artifactId,version);
if (dependencyJar == null) {
if (optional) {
System.err.println("cannot resolve optional dependency " + dep + " of " + shortName + "; skipping");
continue;
}
throw new IOException("Could not resolve " + dep);
}
File dst = new File(home, "plugins/" + artifactId + ".jpi");
if(!dst.exists() || dst.lastModified()!=dependencyJar.lastModified()) {