mirror of https://github.com/sbt/sbt.git
extra component for supporting dynamic changes to sbt's classpath. fixes #83
This commit is contained in:
parent
8d922b61ab
commit
5f8a73cc21
|
|
@ -184,6 +184,8 @@ class ComponentProvider(baseDirectory: File, lockBoot: Boolean) extends xsbti.Co
|
|||
else
|
||||
Copy(files.toList, location)
|
||||
}
|
||||
def addToComponent(id: String, files: Array[File]): Boolean =
|
||||
Copy(files.toList, componentLocation(id))
|
||||
def lockFile = if(lockBoot) ComponentProvider.lockFile(baseDirectory) else null // null for the Java interface
|
||||
}
|
||||
object ComponentProvider
|
||||
|
|
|
|||
|
|
@ -13,15 +13,21 @@ object Using
|
|||
|
||||
object Copy
|
||||
{
|
||||
def apply(files: List[File], toDirectory: File): Unit = files.foreach(file => apply(file, toDirectory))
|
||||
def apply(file: File, toDirectory: File)
|
||||
def apply(files: List[File], toDirectory: File): Boolean = files.map(file => apply(file, toDirectory)).contains(true)
|
||||
def apply(file: File, toDirectory: File): Boolean =
|
||||
{
|
||||
toDirectory.mkdirs()
|
||||
Using(new FileInputStream(file)) { in =>
|
||||
Using(new FileOutputStream(new File(toDirectory, file.getName))) { out =>
|
||||
transfer(in, out)
|
||||
val to = new File(toDirectory, file.getName)
|
||||
val missing = !to.exists
|
||||
if(missing)
|
||||
{
|
||||
Using(new FileInputStream(file)) { in =>
|
||||
Using(new FileOutputStream(to)) { out =>
|
||||
transfer(in, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
missing
|
||||
}
|
||||
def transfer(in: InputStream, out: OutputStream)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import java.io.File;
|
|||
|
||||
public interface ComponentProvider
|
||||
{
|
||||
public File componentLocation(String id);
|
||||
public File[] component(String componentID);
|
||||
public void defineComponent(String componentID, File[] components);
|
||||
public boolean addToComponent(String componentID, File[] components);
|
||||
// null if locking disabled
|
||||
public File lockFile();
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
name: sbt
|
||||
version: read(sbt.version)[${{sbt.version}}]
|
||||
class: ${sbt.main.class-sbt.xMain}
|
||||
components: xsbti
|
||||
components: xsbti,extra
|
||||
cross-versioned: true
|
||||
|
||||
[repositories]
|
||||
|
|
|
|||
Loading…
Reference in New Issue