src/Pure/Tools/scala_build.scala
changeset 75869 ee2f93fa2440
parent 75687 c8dc5d1adc7b
child 77027 ac7af931189f
equal deleted inserted replaced
75868:e7b04452eef3 75869:ee2f93fa2440
     8 
     8 
     9 
     9 
    10 import java.util.{Properties => JProperties}
    10 import java.util.{Properties => JProperties}
    11 import java.io.{ByteArrayOutputStream, PrintStream}
    11 import java.io.{ByteArrayOutputStream, PrintStream}
    12 import java.nio.file.Files
    12 import java.nio.file.Files
       
    13 import java.nio.file.{Path => JPath}
    13 
    14 
    14 import scala.jdk.CollectionConverters._
    15 import scala.jdk.CollectionConverters._
    15 
    16 
    16 
    17 
    17 object Scala_Build {
    18 object Scala_Build {
    37       (for {
    38       (for {
    38         s <- java_context.requirements().asScala.iterator
    39         s <- java_context.requirements().asScala.iterator
    39         p <- java_context.requirement_paths(s).asScala.iterator
    40         p <- java_context.requirement_paths(s).asScala.iterator
    40       } yield (File.path(p.toFile))).toList
    41       } yield (File.path(p.toFile))).toList
    41 
    42 
    42     def build(fresh: Boolean = false): String = {
    43     def build(
       
    44       classpath: List[Path] = Path.split(Isabelle_System.getenv("ISABELLE_CLASSPATH")),
       
    45       fresh: Boolean = false
       
    46     ): String = {
       
    47       val java_classpath = new java.util.LinkedList[JPath]
       
    48       classpath.foreach(path => java_classpath.add(path.java_path))
       
    49 
    43       val output0 = new ByteArrayOutputStream
    50       val output0 = new ByteArrayOutputStream
    44       val output = new PrintStream(output0)
    51       val output = new PrintStream(output0)
    45       def get_output(): String = {
    52       def get_output(): String = {
    46         output.flush()
    53         output.flush()
    47         Library.trim_line(output0.toString(UTF8.charset))
    54         Library.trim_line(output0.toString(UTF8.charset))
    48       }
    55       }
       
    56 
    49       try {
    57       try {
    50         isabelle.setup.Build.build(output, java_context, fresh)
    58         isabelle.setup.Build.build(java_classpath, output, java_context, fresh)
    51         get_output()
    59         get_output()
    52       }
    60       }
    53       catch { case ERROR(msg) => cat_error(get_output(), msg) }
    61       catch { case ERROR(msg) => cat_error(get_output(), msg) }
    54     }
    62     }
    55   }
    63   }
    85 
    93 
    86   def build_result(dir: Path, component: Boolean = false): Result = {
    94   def build_result(dir: Path, component: Boolean = false): Result = {
    87     Isabelle_System.with_tmp_file("result", "jar") { tmp_file =>
    95     Isabelle_System.with_tmp_file("result", "jar") { tmp_file =>
    88       val output =
    96       val output =
    89         context(dir, component = component, no_title = true, do_build = true,
    97         context(dir, component = component, no_title = true, do_build = true,
    90           module = Some(tmp_file)).build()
    98           module = Some(tmp_file)).build(classpath = Classpath().jars.map(File.path))
    91       val jar_bytes = Bytes.read(tmp_file)
    99       val jar_bytes = Bytes.read(tmp_file)
    92       val jar_path = context(dir, component = component).module_result
   100       val jar_path = context(dir, component = component).module_result
    93       Result(output, jar_bytes, jar_path)
   101       Result(output, jar_bytes, jar_path)
    94     }
   102     }
    95   }
   103   }