2009-08-21 14:12:43 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2009 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package xsbt.boot
|
|
|
|
|
|
2009-09-09 05:13:30 +02:00
|
|
|
import BootConfiguration.{IvyPackage, JLinePackagePath, SbtBootPackage, ScalaPackage}
|
2009-08-21 14:12:43 +02:00
|
|
|
|
|
|
|
|
/** A custom class loader to ensure the main part of sbt doesn't load any Scala or
|
|
|
|
|
* Ivy classes from the jar containing the loader. */
|
2009-08-24 04:21:15 +02:00
|
|
|
private[boot] final class BootFilteredLoader(parent: ClassLoader) extends ClassLoader(parent) with NotNull
|
2009-08-21 14:12:43 +02:00
|
|
|
{
|
|
|
|
|
@throws(classOf[ClassNotFoundException])
|
|
|
|
|
override final def loadClass(className: String, resolve: Boolean): Class[_] =
|
|
|
|
|
{
|
2009-09-09 05:13:30 +02:00
|
|
|
// note that we allow xsbti.* and jline.*
|
2009-08-21 14:12:43 +02:00
|
|
|
if(className.startsWith(ScalaPackage) || className.startsWith(IvyPackage) || className.startsWith(SbtBootPackage))
|
|
|
|
|
throw new ClassNotFoundException(className)
|
|
|
|
|
else
|
|
|
|
|
super.loadClass(className, resolve)
|
|
|
|
|
}
|
2009-09-09 05:13:30 +02:00
|
|
|
override def getResources(name: String) = if(includeResource(name)) super.getResources(name) else null
|
|
|
|
|
override def getResource(name: String) = if(includeResource(name)) super.getResource(name) else null
|
|
|
|
|
def includeResource(name: String) = name.startsWith(JLinePackagePath)
|
2009-08-21 14:12:43 +02:00
|
|
|
}
|