22 |
22 |
23 def is_module(path: Path): Boolean = |
23 def is_module(path: Path): Boolean = |
24 { |
24 { |
25 val module_name = java_context.module_name() |
25 val module_name = java_context.module_name() |
26 module_name.nonEmpty && File.eq(java_context.path(module_name).toFile, path.file) |
26 module_name.nonEmpty && File.eq(java_context.path(module_name).toFile, path.file) |
|
27 } |
|
28 |
|
29 def module_result: Option[Path] = |
|
30 { |
|
31 java_context.module_result() match { |
|
32 case "" => None |
|
33 case module => Some(File.path(java_context.path(module).toFile)) |
|
34 } |
27 } |
35 } |
28 |
36 |
29 def sources: List[Path] = |
37 def sources: List[Path] = |
30 java_context.sources().asScala.toList.map(s => File.path(java_context.path(s).toFile)) |
38 java_context.sources().asScala.toList.map(s => File.path(java_context.path(s).toFile)) |
31 |
39 |
85 { |
93 { |
86 context(dir, component = component, no_title = no_title, do_build = do_build, module = module) |
94 context(dir, component = component, no_title = no_title, do_build = do_build, module = module) |
87 .build(fresh = fresh) |
95 .build(fresh = fresh) |
88 } |
96 } |
89 |
97 |
90 sealed case class Result(output: String, jar: Bytes) |
98 sealed case class Result(output: String, jar_bytes: Bytes, jar_path: Option[Path]) |
|
99 { |
|
100 def write(): Unit = |
|
101 { |
|
102 if (jar_path.isDefined) { |
|
103 Isabelle_System.make_directory(jar_path.get.dir) |
|
104 Bytes.write(jar_path.get, jar_bytes) |
|
105 } |
|
106 } |
|
107 } |
91 |
108 |
92 def build_result(dir: Path, component: Boolean = false): Result = |
109 def build_result(dir: Path, component: Boolean = false): Result = |
93 { |
110 { |
94 Isabelle_System.with_tmp_file("result", "jar")(tmp_file => |
111 Isabelle_System.with_tmp_file("result", "jar")(tmp_file => |
95 { |
112 { |
96 val output = |
113 val output = |
97 build(dir, component = component, no_title = true, do_build = true, module = Some(tmp_file)) |
114 build(dir, component = component, no_title = true, do_build = true, module = Some(tmp_file)) |
98 val jar = Bytes.read(tmp_file) |
115 val jar_bytes = Bytes.read(tmp_file) |
99 Result(output, jar) |
116 val jar_path = context(dir, component = component).module_result |
|
117 Result(output, jar_bytes, jar_path) |
100 }) |
118 }) |
101 } |
119 } |
102 |
120 |
103 def component_contexts(): List[Context] = |
121 def component_contexts(): List[Context] = |
104 isabelle.setup.Build.component_contexts().asScala.toList.map(new Context(_)) |
122 isabelle.setup.Build.component_contexts().asScala.toList.map(new Context(_)) |