src/Pure/Tools/scala_project.scala
author wenzelm
Sat, 28 Nov 2020 15:15:53 +0100
changeset 72755 8dffbe01a3e1
parent 72748 04d5f6d769a7
child 72762 d9a54c4c9da9
permissions -rw-r--r--
support for Scala compile-time positions;
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    26
  def isabelle_files(): List[String] =
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
    {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    30
      val isabelle_home = Path.explode("~~").canonical
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"))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    41
        line <- Library.trim_split_lines(File.read(path))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    42
        name =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    43
          if (line.length > 42 && line(41) == '*') line.substring(42)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    44
          else error("Bad shasum entry: " + quote(line))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    45
        if name != "lib/classes/Pure.jar" &&
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
    46
          name != "src/Tools/jEdit/dist/jedit.jar" &&
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    47
          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
    48
          name != "src/Tools/jEdit/dist/jars/Isabelle-jEdit.jar"
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    49
      } yield name)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    50
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    51
    files1 ::: files2
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    52
  }
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
  val isabelle_dirs: List[(String, Path)] =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    55
    List(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    56
      "src/Pure/" -> Path.explode("isabelle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    57
      "src/Tools/Graphview/" -> Path.explode("isabelle.graphview"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    58
      "src/Tools/VSCode/" -> Path.explode("isabelle.vscode"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    59
      "src/Tools/jEdit/src-base/" -> Path.explode("isabelle.jedit_base"),
72176
22c11f65ddf9 rudiments of Scala interface for Kodkod;
wenzelm
parents: 71524
diff changeset
    60
      "src/Tools/jEdit/src/" -> Path.explode("isabelle.jedit"),
72748
04d5f6d769a7 more flexible syntax for theory load commands via Isabelle/Scala;
wenzelm
parents: 72376
diff changeset
    61
      "src/HOL/SPARK/Tools" -> Path.explode("isabelle.spark"),
72176
22c11f65ddf9 rudiments of Scala interface for Kodkod;
wenzelm
parents: 71524
diff changeset
    62
      "src/HOL/Tools/Nitpick" -> Path.explode("isabelle.nitpick"))
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    63
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    64
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    65
  /* compile-time position */
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    66
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    67
  def here: Here =
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    68
  {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    69
    val exn = new Exception
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    70
    exn.getStackTrace.toList match {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    71
      case _ :: caller :: _ =>
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    72
        val name = proper_string(caller.getFileName).getOrElse("")
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    73
        val line = caller.getLineNumber
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    74
        new Here(name, line)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    75
      case _ => new Here("", 0)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    76
    }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    77
  }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    78
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    79
  class Here private[Scala_Project](name: String, line: Int)
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
    override def toString: String = name + ":" + line
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    82
    def position: Position.T =
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    83
    {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    84
      if (name.startsWith("<")) Position.none
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    85
      else {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    86
        val suffix = "/" + name
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    87
        isabelle_files().find(_.endsWith(suffix)) match {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    88
          case None => Position.none
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    89
          case Some(file) => Position.Line_File(line, "$ISABELLE_HOME/" + file)
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
  }
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
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    96
  /* scala project */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    97
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    98
  def scala_project(project_dir: Path, symlinks: Boolean = false)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    99
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   100
    if (symlinks && Platform.is_windows)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   101
      error("Cannot create symlinks on Windows")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   102
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   103
    if (project_dir.is_file || project_dir.is_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   104
      error("Project directory already exists: " + project_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   105
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   106
    val src_dir = project_dir + Path.explode("src/main/scala")
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   107
    val java_src_dir = project_dir + Path.explode("src/main/java")
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
   108
    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
   109
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   110
    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
   111
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   112
    val files = isabelle_files()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   113
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   114
    for (file <- files if file.endsWith(".scala")) {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   115
      val (path, target) =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   116
        isabelle_dirs.collectFirst({
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   117
          case (prfx, p) if file.startsWith(prfx) =>
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   118
            (Path.explode("~~") + Path.explode(file), scala_src_dir + p)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   119
        }).getOrElse(error("Unknown directory prefix for " + quote(file)))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   120
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 72176
diff changeset
   121
      Isabelle_System.make_directory(target)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   122
      if (symlinks) File.link(path, target) else File.copy(path, target)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   123
    }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   124
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   125
    val jars =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   126
      for (file <- files if file.endsWith(".jar"))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   127
      yield {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   128
        if (file.startsWith("/")) file
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   129
        else Isabelle_System.getenv("ISABELLE_HOME") + "/" + file
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   130
      }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   131
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   132
    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
   133
    File.write(project_dir + Path.explode("build.gradle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   134
"""plugins {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   135
  id 'scala'
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   136
}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   137
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   138
repositories {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   139
  mavenCentral()
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   142
dependencies {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   143
  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
   144
  compile files(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   145
    """ + 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
   146
"""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   147
}
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   148
""")
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   152
  /* Isabelle tool wrapper */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   153
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   154
  val isabelle_tool =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   155
    Isabelle_Tool("scala_project", "setup Gradle project for Isabelle/Scala/jEdit", args =>
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
      var symlinks = false
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
      val getopts = Getopts("""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   160
Usage: isabelle scala_project [OPTIONS] PROJECT_DIR
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   161
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   162
  Options are:
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   163
    -L           make symlinks to original scala files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   164
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   165
  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
   166
  such as IntelliJ IDEA.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   167
""",
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   168
        "L" -> (_ => symlinks = true))
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   169
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   170
      val more_args = getopts(args)
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
      val project_dir =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   173
        more_args match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   174
          case List(dir) => Path.explode(dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   175
          case _ => getopts.usage()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   176
        }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   177
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   178
      scala_project(project_dir, symlinks = symlinks)
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
}