I am trying to write a new class while extending Jan Berkel's Android Plugin using which I would like to provide a functionality of pushing entire scala library to rooted phones.
So far, I have the code that uses local versions of Scala you have already downloaded to your computer, however, I'd like to be able to download a version of Scala if it's not there.
Here is the relevant part of code:
def makePermission(version: String) {
val home = JSystem.getProperty("user.home")
val scalaFolder = new JFile(home + "/.sbt/boot/scala-" + version)
if (!scalaFolder.exists) {
// TODO: Try to download the Scala version in "version"
}
val permission = new JFile(scalaFolder, "scala-library.xml")
if (scalaFolder.exists && !permission.exists) {
val writer = new PrintWriter(permission)
writer.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
writer.println("")
writer.println("<permissions>")
writer.println(" <library")
writer.println(" name=\"scala-library-" + version + "\"")
writer.println(" file=\"/system/framework/scala-library-" + version + "\"")
writer.println(" />")
writer.println("</permissions>")
writer.close
}
}
For example, calling my function like this:
makePermission("2.9.1")
will see that I have Scala 2.9.1 and make scala-library.xml in scala-2.9.1
folder.
Doing this:
makePermission("2.8.1")
will see that I don't have Scala 2.8.1, download it and make scala-library.xml in scala-2.8.1
folder.
However, doing this:
makePermission("3.0.0")
will see that I don't have Scala 3.0.0, try to download it but see it doesn't exist nad skip the rest.
I'm puzzled how to do the TODO
part, so any help is appreciated. :D