74055
|
1 |
/* Title: Pure/Tools/scala_build.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Manage and build Isabelle/Scala/Java components.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
import java.util.{Properties => JProperties}
|
|
11 |
import java.nio.file.Files
|
|
12 |
|
|
13 |
import scala.jdk.CollectionConverters._
|
|
14 |
|
|
15 |
|
|
16 |
object Scala_Build
|
|
17 |
{
|
74056
|
18 |
class Context private[Scala_Build](java_context: isabelle.setup.Build.Context)
|
|
19 |
{
|
|
20 |
def is_module(path: Path): Boolean =
|
|
21 |
{
|
|
22 |
val module_name: String = java_context.module_name()
|
|
23 |
module_name.nonEmpty && File.eq(java_context.path(module_name).toFile, path.file)
|
|
24 |
}
|
|
25 |
|
|
26 |
def sources: List[Path] =
|
|
27 |
java_context.sources().asScala.toList.map(s => File.path(java_context.path(s).toFile))
|
|
28 |
|
|
29 |
def requirements: List[Path] =
|
|
30 |
(for {
|
|
31 |
s <- java_context.requirements().asScala.iterator
|
|
32 |
p <- java_context.requirement_paths(s).asScala.iterator
|
|
33 |
} yield (File.path(p.toFile))).toList
|
|
34 |
|
|
35 |
def build(fresh: Boolean = false): Unit =
|
|
36 |
isabelle.setup.Build.build(java_context, fresh)
|
|
37 |
}
|
74055
|
38 |
|
|
39 |
def context(dir: Path,
|
|
40 |
component: Boolean = false,
|
|
41 |
more_props: Properties.T = Nil): Context =
|
|
42 |
{
|
|
43 |
val props_name =
|
|
44 |
if (component) isabelle.setup.Build.COMPONENT_BUILD_PROPS
|
|
45 |
else isabelle.setup.Build.BUILD_PROPS
|
|
46 |
val props_path = dir + Path.explode(props_name)
|
|
47 |
|
|
48 |
val props = new JProperties
|
|
49 |
props.load(Files.newBufferedReader(props_path.java_path))
|
|
50 |
for ((a, b) <- more_props) props.put(a, b)
|
|
51 |
|
74056
|
52 |
new Context(new isabelle.setup.Build.Context(dir.java_path, props, props_path.implode))
|
74055
|
53 |
}
|
|
54 |
|
|
55 |
def build(dir: Path,
|
|
56 |
fresh: Boolean = false,
|
|
57 |
component: Boolean = false,
|
|
58 |
more_props: Properties.T = Nil): Unit =
|
|
59 |
{
|
74056
|
60 |
context(dir, component = component, more_props = more_props).build(fresh = fresh)
|
74055
|
61 |
}
|
|
62 |
|
|
63 |
def component_contexts(): List[Context] =
|
74056
|
64 |
isabelle.setup.Build.component_contexts().asScala.toList.map(new Context(_))
|
74055
|
65 |
}
|