--- a/src/Pure/Tools/scala_project.scala Fri Apr 01 11:51:42 2022 +0200
+++ b/src/Pure/Tools/scala_project.scala Fri Apr 01 17:06:10 2022 +0200
@@ -8,15 +8,13 @@
package isabelle
-object Scala_Project
-{
+object Scala_Project {
/** build tools **/
def java_version: String = "15"
def scala_version: String = scala.util.Properties.versionNumberString
- abstract class Build_Tool
- {
+ abstract class Build_Tool {
def project_root: Path
def init_project(dir: Path, jars: List[Path]): Unit
@@ -27,8 +25,7 @@
(dir + project_root).is_file &&
(dir + scala_src_dir).is_dir
- def package_dir(source_file: Path): Path =
- {
+ def package_dir(source_file: Path): Path = {
val dir =
package_name(source_file) match {
case Some(name) => Path.explode(space_explode('.', name).mkString("/"))
@@ -43,15 +40,13 @@
/* Gradle */
- object Gradle extends Build_Tool
- {
+ object Gradle extends Build_Tool {
override def toString: String = "Gradle"
val project_settings: Path = Path.explode("settings.gradle")
override val project_root: Path = Path.explode("build.gradle")
- private def groovy_string(s: String): String =
- {
+ private def groovy_string(s: String): String = {
s.map(c =>
c match {
case '\t' | '\b' | '\n' | '\r' | '\f' | '\\' | '\'' | '"' => "\\" + c
@@ -59,8 +54,7 @@
}).mkString("'", "", "'")
}
- override def init_project(dir: Path, jars: List[Path]): Unit =
- {
+ override def init_project(dir: Path, jars: List[Path]): Unit = {
File.write(dir + project_settings, "rootProject.name = 'Isabelle'\n")
File.write(dir + project_root,
"""plugins {
@@ -84,16 +78,13 @@
/* Maven */
- object Maven extends Build_Tool
- {
+ object Maven extends Build_Tool {
override def toString: String = "Maven"
override val project_root: Path = Path.explode("pom.xml")
- override def init_project(dir: Path, jars: List[Path]): Unit =
- {
- def dependency(jar: Path): String =
- {
+ override def init_project(dir: Path, jars: List[Path]): Unit = {
+ def dependency(jar: Path): String = {
val name = jar.expand.drop_ext.base.implode
val system_path = File.platform_path(jar.absolute)
""" <dependency>
@@ -143,8 +134,7 @@
/* plugins: modules with dynamic build */
- class Plugin(dir: Path) extends Isabelle_System.Service
- {
+ class Plugin(dir: Path) extends Isabelle_System.Service {
def context(): Scala_Build.Context = Scala_Build.context(dir)
}
@@ -153,8 +143,7 @@
/* file and directories */
- lazy val isabelle_files: (List[Path], List[Path]) =
- {
+ lazy val isabelle_files: (List[Path], List[Path]) = {
val contexts = Scala_Build.component_contexts() ::: plugins.map(_.context())
val jars1 = Path.split(Isabelle_System.getenv("ISABELLE_CLASSPATH"))
@@ -173,8 +162,7 @@
(jars, sources)
}
- lazy val isabelle_scala_files: Map[String, Path] =
- {
+ lazy val isabelle_scala_files: Map[String, Path] = {
val context = Scala_Build.context(Path.ISABELLE_HOME, component = true)
context.sources.iterator.foldLeft(Map.empty[String, Path]) {
case (map, path) =>
@@ -192,8 +180,7 @@
/* compile-time position */
- def here: Here =
- {
+ def here: Here = {
val exn = new Exception
exn.getStackTrace.toList match {
case _ :: caller :: _ =>
@@ -204,8 +191,7 @@
}
}
- class Here private[Scala_Project](name: String, line: Int)
- {
+ class Here private[Scala_Project](name: String, line: Int) {
override def toString: String = name + ":" + line
def position: Position.T =
isabelle_scala_files.get(name) match {
@@ -219,8 +205,7 @@
val default_project_dir = Path.explode("$ISABELLE_HOME_USER/scala_project")
- def package_name(source_file: Path): Option[String] =
- {
+ def package_name(source_file: Path): Option[String] = {
val lines = Library.trim_split_lines(File.read(source_file))
val Package = """\s*\bpackage\b\s*(?:object\b\s*)?((?:\w|\.)+)\b.*""".r
lines.collectFirst({ case Package(name) => name })
@@ -232,8 +217,8 @@
more_sources: List[Path] = Nil,
symlinks: Boolean = false,
force: Boolean = false,
- progress: Progress = new Progress): Unit =
- {
+ progress: Progress = new Progress
+ ): Unit = {
if (project_dir.file.exists) {
val detect = project_dir.is_dir && build_tools.exists(_.detect_project(project_dir))
@@ -272,8 +257,8 @@
val isabelle_tool =
Isabelle_Tool("scala_project", "setup IDE project for Isabelle/Java/Scala sources",
- Scala_Project.here, args =>
- {
+ Scala_Project.here,
+ args => {
var build_tool: Option[Build_Tool] = None
var project_dir = default_project_dir
var symlinks = false