src/Pure/Tools/scala_project.scala
author wenzelm
Thu, 01 Jul 2021 14:06:20 +0200
changeset 73912 ac1639349ecf
parent 73907 8cc891183484
child 73987 fc363a3b690a
permissions -rw-r--r--
clarified directories;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/Tools/scala_project.scala
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     3
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     4
Setup Gradle project for Isabelle/Scala/jEdit.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     5
*/
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     6
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     7
package isabelle
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     8
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     9
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    10
object Scala_Project
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    11
{
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    12
  /* groovy syntax */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    13
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    14
  def groovy_string(s: String): String =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    15
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    16
    s.map(c =>
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    17
      c match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    18
        case '\t' | '\b' | '\n' | '\r' | '\f' | '\\' | '\'' | '"' => "\\" + c
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    19
        case _ => c.toString
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    20
      }).mkString("'", "", "'")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    21
  }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    22
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    23
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    24
  /* file and directories */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    25
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    26
  lazy val isabelle_files: List[String] =
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    27
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    28
    val files1 =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    29
    {
73522
b219774a71ae tuned signature -- more explicit types;
wenzelm
parents: 73418
diff changeset
    30
      val isabelle_home = Path.ISABELLE_HOME.canonical
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    31
      Path.split(Isabelle_System.getenv("ISABELLE_CLASSPATH")).
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    32
        map(path => File.relative_path(isabelle_home, path).getOrElse(path).implode)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    33
    }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    34
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    35
    val files2 =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    36
      (for {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    37
        path <-
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    38
          List(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    39
            Path.explode("~~/lib/classes/Pure.shasum"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    40
            Path.explode("~~/src/Tools/jEdit/dist/Isabelle-jEdit.shasum"))
73035
03e78b35ebbc more robust bootstrap: Isabelle-jEdit.shasum could be absent;
wenzelm
parents: 72763
diff changeset
    41
        if path.is_file
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    42
        line <- Library.trim_split_lines(File.read(path))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    43
        name =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    44
          if (line.length > 42 && line(41) == '*') line.substring(42)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    45
          else error("Bad shasum entry: " + quote(line))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    46
        if name != "lib/classes/Pure.jar" &&
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
    47
          name != "src/Tools/jEdit/dist/jedit.jar" &&
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    48
          name != "src/Tools/jEdit/dist/jars/Isabelle-jEdit-base.jar" &&
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    49
          name != "src/Tools/jEdit/dist/jars/Isabelle-jEdit.jar"
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    50
      } yield name)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    51
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    52
    files1 ::: files2
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    53
  }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    54
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    55
  lazy val isabelle_scala_files: Map[String, Path] =
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
    56
    isabelle_files.foldLeft(Map.empty[String, Path]) {
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    57
      case (map, name) =>
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    58
        if (!name.startsWith("src/Tools/jEdit/") && name.endsWith(".scala")) {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    59
          val path = Path.explode("~~/" + name)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    60
          val base = path.base.implode
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    61
          map.get(base) match {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    62
            case None => map + (base -> path)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    63
            case Some(path1) => error("Conflicting base names: " + path + " vs. " + path1)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    64
          }
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    65
        }
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    66
        else map
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
    67
    }
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    68
73675
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    69
  private def guess_package(path: Path): String =
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    70
  {
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    71
    val lines = split_lines(File.read(path))
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    72
    val Package = """\bpackage\b +(?:object +)?\b((?:\w|\.)+)\b""".r
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    73
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    74
    lines.collectFirst({ case Package(name) => name }) getOrElse
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    75
      error("Failed to guess package from " + path)
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    76
  }
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    77
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    78
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    79
  /* compile-time position */
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    80
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    81
  def here: Here =
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    82
  {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    83
    val exn = new Exception
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    84
    exn.getStackTrace.toList match {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    85
      case _ :: caller :: _ =>
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    86
        val name = proper_string(caller.getFileName).getOrElse("")
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    87
        val line = caller.getLineNumber
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    88
        new Here(name, line)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    89
      case _ => new Here("", 0)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    90
    }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    91
  }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    92
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    93
  class Here private[Scala_Project](name: String, line: Int)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    94
  {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    95
    override def toString: String = name + ":" + line
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    96
    def position: Position.T =
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    97
      isabelle_scala_files.get(name) match {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    98
        case Some(path) => Position.Line_File(line, path.implode)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    99
        case None => Position.none
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   100
      }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   101
  }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   102
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   103
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   104
  /* scala project */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   105
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 73317
diff changeset
   106
  def scala_project(project_dir: Path, symlinks: Boolean = false): Unit =
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   107
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   108
    if (symlinks && Platform.is_windows)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   109
      error("Cannot create symlinks on Windows")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   110
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   111
    if (project_dir.is_file || project_dir.is_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   112
      error("Project directory already exists: " + project_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   113
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   114
    val java_src_dir = project_dir + Path.explode("src/main/java")
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
   115
    val scala_src_dir = Isabelle_System.make_directory(project_dir + Path.explode("src/main/scala"))
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   116
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   117
    Isabelle_System.copy_dir(Path.explode("~~/src/Tools/jEdit/dist/jEdit"), java_src_dir)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   118
73912
ac1639349ecf clarified directories;
wenzelm
parents: 73907
diff changeset
   119
    val isabelle_setup_dir = Path.explode("~~/src/Tools/Setup/isabelle")
ac1639349ecf clarified directories;
wenzelm
parents: 73907
diff changeset
   120
    if (symlinks) Isabelle_System.symlink(isabelle_setup_dir, java_src_dir)
ac1639349ecf clarified directories;
wenzelm
parents: 73907
diff changeset
   121
    else Isabelle_System.copy_dir(isabelle_setup_dir, java_src_dir)
73907
8cc891183484 clarified Isabelle/Java/Scala project setup;
wenzelm
parents: 73675
diff changeset
   122
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   123
    val files = isabelle_files
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   124
    isabelle_scala_files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   125
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   126
    for (file <- files if file.endsWith(".scala")) {
73675
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
   127
      val path = Path.ISABELLE_HOME + Path.explode(file)
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
   128
      val target = scala_src_dir + Path.basic(guess_package(path))
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 72176
diff changeset
   129
      Isabelle_System.make_directory(target)
73317
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 73035
diff changeset
   130
      if (symlinks) Isabelle_System.symlink(path, target)
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 73035
diff changeset
   131
      else Isabelle_System.copy_file(path, target)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   132
    }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   133
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   134
    val jars =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   135
      for (file <- files if file.endsWith(".jar"))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   136
      yield {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   137
        if (file.startsWith("/")) file
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   138
        else Isabelle_System.getenv("ISABELLE_HOME") + "/" + file
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   139
      }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   140
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   141
    File.write(project_dir + Path.explode("settings.gradle"), "rootProject.name = 'Isabelle'\n")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   142
    File.write(project_dir + Path.explode("build.gradle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   143
"""plugins {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   144
  id 'scala'
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   145
}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   146
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   147
repositories {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   148
  mavenCentral()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   149
}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   150
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   151
dependencies {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   152
  implementation 'org.scala-lang:scala-library:""" + scala.util.Properties.versionNumberString + """'
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   153
  compile files(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   154
    """ + jars.map(jar => groovy_string(File.platform_path(jar))).mkString("", ",\n    ", ")") +
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   155
"""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   156
}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   157
""")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   158
  }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   159
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   160
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   161
  /* Isabelle tool wrapper */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   162
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   163
  val isabelle_tool =
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   164
    Isabelle_Tool("scala_project", "setup Gradle project for Isabelle/Scala/jEdit",
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   165
      Scala_Project.here, args =>
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   166
    {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   167
      var symlinks = false
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   168
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   169
      val getopts = Getopts("""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   170
Usage: isabelle scala_project [OPTIONS] PROJECT_DIR
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   171
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   172
  Options are:
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   173
    -L           make symlinks to original scala files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   174
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   175
  Setup Gradle project for Isabelle/Scala/jEdit --- to support Scala IDEs
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   176
  such as IntelliJ IDEA.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   177
""",
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   178
        "L" -> (_ => symlinks = true))
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   179
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   180
      val more_args = getopts(args)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   181
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   182
      val project_dir =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   183
        more_args match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   184
          case List(dir) => Path.explode(dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   185
          case _ => getopts.usage()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   186
        }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   187
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   188
      scala_project(project_dir, symlinks = symlinks)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   189
    })
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   190
}