src/Pure/Tools/scala_project.scala
author wenzelm
Thu, 04 Mar 2021 15:41:46 +0100
changeset 73359 d8a0e996614b
parent 73340 0ffcad1f6130
child 73418 7d7d959547a1
permissions -rw-r--r--
tuned --- fewer warnings;
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
    {
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"))
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
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    69
  val isabelle_dirs: List[(String, Path)] =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    70
    List(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    71
      "src/Pure/" -> Path.explode("isabelle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    72
      "src/Tools/Graphview/" -> Path.explode("isabelle.graphview"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    73
      "src/Tools/VSCode/" -> Path.explode("isabelle.vscode"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    74
      "src/Tools/jEdit/src-base/" -> Path.explode("isabelle.jedit_base"),
72176
22c11f65ddf9 rudiments of Scala interface for Kodkod;
wenzelm
parents: 71524
diff changeset
    75
      "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
    76
      "src/HOL/SPARK/Tools" -> Path.explode("isabelle.spark"),
72176
22c11f65ddf9 rudiments of Scala interface for Kodkod;
wenzelm
parents: 71524
diff changeset
    77
      "src/HOL/Tools/Nitpick" -> Path.explode("isabelle.nitpick"))
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    78
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    79
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    80
  /* compile-time position */
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    81
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    82
  def here: Here =
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
    val exn = new Exception
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    85
    exn.getStackTrace.toList match {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    86
      case _ :: caller :: _ =>
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    87
        val name = proper_string(caller.getFileName).getOrElse("")
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    88
        val line = caller.getLineNumber
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    89
        new Here(name, line)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    90
      case _ => new Here("", 0)
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
  class Here private[Scala_Project](name: String, line: Int)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    95
  {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    96
    override def toString: String = name + ":" + line
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    97
    def position: Position.T =
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    98
      isabelle_scala_files.get(name) match {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    99
        case Some(path) => Position.Line_File(line, path.implode)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   100
        case None => Position.none
72755
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
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   104
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   105
  /* scala project */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   106
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 73317
diff changeset
   107
  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
   108
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   109
    if (symlinks && Platform.is_windows)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   110
      error("Cannot create symlinks on Windows")
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
    if (project_dir.is_file || project_dir.is_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   113
      error("Project directory already exists: " + project_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   114
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   115
    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
   116
    val java_src_dir = project_dir + Path.explode("src/main/java")
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
   117
    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
   118
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   119
    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
   120
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   121
    val files = isabelle_files
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   122
    isabelle_scala_files
71378
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
    for (file <- files if file.endsWith(".scala")) {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   125
      val (path, target) =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   126
        isabelle_dirs.collectFirst({
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   127
          case (prfx, p) if file.startsWith(prfx) =>
71524
4b908e70d642 copy jEdit sources instead of jar, for better browsing experience;
wenzelm
parents: 71503
diff changeset
   128
            (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
   129
        }).getOrElse(error("Unknown directory prefix for " + quote(file)))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   130
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 72176
diff changeset
   131
      Isabelle_System.make_directory(target)
73317
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 73035
diff changeset
   132
      if (symlinks) Isabelle_System.symlink(path, target)
df49ca5da9d0 clarified modules: more like ML;
wenzelm
parents: 73035
diff changeset
   133
      else Isabelle_System.copy_file(path, target)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   134
    }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   135
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   136
    val jars =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   137
      for (file <- files if file.endsWith(".jar"))
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   138
      yield {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   139
        if (file.startsWith("/")) file
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   140
        else Isabelle_System.getenv("ISABELLE_HOME") + "/" + file
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   143
    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
   144
    File.write(project_dir + Path.explode("build.gradle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   145
"""plugins {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   146
  id 'scala'
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
repositories {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   150
  mavenCentral()
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   153
dependencies {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   154
  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
   155
  compile files(
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   156
    """ + 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
   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
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
  /* Isabelle tool wrapper */
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
  val isabelle_tool =
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   166
    Isabelle_Tool("scala_project", "setup Gradle project for Isabelle/Scala/jEdit",
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   167
      Scala_Project.here, args =>
71378
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
      var symlinks = false
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   170
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   171
      val getopts = Getopts("""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   172
Usage: isabelle scala_project [OPTIONS] PROJECT_DIR
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   173
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   174
  Options are:
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   175
    -L           make symlinks to original scala files
71378
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
  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
   178
  such as IntelliJ IDEA.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   179
""",
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   180
        "L" -> (_ => symlinks = true))
71378
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 more_args = getopts(args)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   183
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   184
      val project_dir =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   185
        more_args match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   186
          case List(dir) => Path.explode(dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   187
          case _ => getopts.usage()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   188
        }
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
      scala_project(project_dir, symlinks = symlinks)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   191
    })
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   192
}