mirror of https://github.com/sbt/sbt.git
Add extra classpath to the metabuild
When sbt was entered through xMain.run and the classloaders do not have the expected format, sbt recreates the classloaders for itself. Unfortunately the extra classpath was not added to the classloader. This caused project/extra to fail if it was entered from RunFromSourceMain rather than with the launcher.
This commit is contained in:
parent
86eaf9d572
commit
15d3ed1298
|
|
@ -11,6 +11,8 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import xsbti.AppProvider;
|
import xsbti.AppProvider;
|
||||||
import xsbti.ScalaProvider;
|
import xsbti.ScalaProvider;
|
||||||
|
|
@ -61,19 +63,27 @@ public final class MetaBuildLoader extends URLClassLoader {
|
||||||
final Pattern pattern = Pattern.compile("test-interface-[0-9.]+\\.jar");
|
final Pattern pattern = Pattern.compile("test-interface-[0-9.]+\\.jar");
|
||||||
final File[] cp = appProvider.mainClasspath();
|
final File[] cp = appProvider.mainClasspath();
|
||||||
final URL[] interfaceURL = new URL[1];
|
final URL[] interfaceURL = new URL[1];
|
||||||
final URL[] rest = new URL[cp.length - 1];
|
final File[] extra =
|
||||||
|
appProvider.id().classpathExtra() == null ? new File[0] : appProvider.id().classpathExtra();
|
||||||
|
final Set<File> bottomClasspath = new LinkedHashSet<>();
|
||||||
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
for (final File file : cp) {
|
||||||
int j = 0; // index into rest
|
|
||||||
while (i < cp.length) {
|
|
||||||
final File file = cp[i];
|
|
||||||
if (pattern.matcher(file.getName()).find()) {
|
if (pattern.matcher(file.getName()).find()) {
|
||||||
interfaceURL[0] = file.toURI().toURL();
|
interfaceURL[0] = file.toURI().toURL();
|
||||||
} else {
|
} else {
|
||||||
rest[j] = file.toURI().toURL();
|
bottomClasspath.add(file);
|
||||||
j += 1;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for (final File file : extra) {
|
||||||
|
bottomClasspath.add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final URL[] rest = new URL[bottomClasspath.size()];
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for (final File file : bottomClasspath) {
|
||||||
|
rest[i] = file.toURI().toURL();
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue