src/Pure/Tools/scala_project.scala
author wenzelm
Sat, 24 Jul 2021 12:24:56 +0200
changeset 74054 9ce319c846d9
parent 74032 c9ec6f03ab91
child 74055 0ee44ed80290
permissions -rw-r--r--
tuned comments;
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
74054
9ce319c846d9 tuned comments;
wenzelm
parents: 74032
diff changeset
     4
Manage Isabelle/Scala/Java project sources, with output to Gradle for
9ce319c846d9 tuned comments;
wenzelm
parents: 74032
diff changeset
     5
IntelliJ IDEA.
71378
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     8
package isabelle
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
     9
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    10
import scala.jdk.CollectionConverters._
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    11
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    12
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    13
object Scala_Project
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    14
{
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    15
  /* groovy syntax */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    16
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    17
  def groovy_string(s: String): String =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    18
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    19
    s.map(c =>
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    20
      c match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    21
        case '\t' | '\b' | '\n' | '\r' | '\f' | '\\' | '\'' | '"' => "\\" + c
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    22
        case _ => c.toString
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    23
      }).mkString("'", "", "'")
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    24
  }
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
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    27
  /* file and directories */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    28
74032
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    29
  def plugin_contexts(): List[isabelle.setup.Build.Context] =
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    30
    for (plugin <- List("jedit_base", "jedit_main"))
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    31
    yield {
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    32
      val dir = Path.explode("$ISABELLE_HOME/src/Tools/jEdit") + Path.basic(plugin)
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    33
      isabelle.setup.Build.directory_context(dir.java_path)
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    34
    }
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    35
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    36
  lazy val isabelle_files: (List[Path], List[Path]) =
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    37
  {
74032
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    38
    val contexts =
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    39
      isabelle.setup.Build.component_contexts().asScala.toList :::
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    40
        plugin_contexts()
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    41
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    42
    val jars1 = Path.split(Isabelle_System.getenv("ISABELLE_CLASSPATH"))
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    43
    val jars2 =
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    44
      (for {
74032
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    45
        context <- contexts.iterator
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    46
        s <- context.requirements().asScala.iterator
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    47
        path <- context.requirement_paths(s).asScala.iterator
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    48
      } yield File.path(path.toFile)).toList
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    49
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    50
    val jar_files =
74032
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    51
      Library.distinct(jars1 ::: jars2).filterNot(path =>
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    52
        contexts.exists(context =>
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    53
        {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    54
          val name: String = context.module_name()
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    55
          name.nonEmpty && File.eq(context.path(name).toFile, path.file)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    56
        }))
73987
fc363a3b690a build.props for isabelle.jar, including isabelle.jedit;
wenzelm
parents: 73912
diff changeset
    57
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    58
    val source_files =
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    59
      (for {
74032
c9ec6f03ab91 more complete scala_project, including Isabelle/jEdit plugins;
wenzelm
parents: 74030
diff changeset
    60
        context <- contexts.iterator
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    61
        file <- context.sources.asScala.iterator
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    62
        if file.endsWith(".scala") || file.endsWith(".java")
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    63
      } yield File.path(context.path(file).toFile)).toList
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    64
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    65
    (jar_files, source_files)
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    66
  }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    67
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    68
  lazy val isabelle_scala_files: Map[String, Path] =
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    69
  {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    70
    val context = isabelle.setup.Build.component_context(Path.ISABELLE_HOME.java_path)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    71
    context.sources().asScala.iterator.foldLeft(Map.empty[String, Path]) {
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    72
      case (map, name) =>
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    73
        if (name.endsWith(".scala")) {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    74
        val path = File.path(context.path(name).toFile)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    75
        val base = path.base.implode
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    76
          map.get(base) match {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    77
            case None => map + (base -> path)
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
    78
            case Some(path2) => error("Conflicting base names: " + path + " vs. " + path2)
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    79
          }
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    80
        }
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
    81
        else map
73359
d8a0e996614b tuned --- fewer warnings;
wenzelm
parents: 73340
diff changeset
    82
    }
73675
6c56f2ebe157 guess package more directly;
wenzelm
parents: 73522
diff changeset
    83
  }
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    84
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
    85
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    86
  /* compile-time position */
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    87
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    88
  def here: Here =
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    89
  {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    90
    val exn = new Exception
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    91
    exn.getStackTrace.toList match {
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    92
      case _ :: caller :: _ =>
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    93
        val name = proper_string(caller.getFileName).getOrElse("")
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    94
        val line = caller.getLineNumber
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    95
        new Here(name, line)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    96
      case _ => new Here("", 0)
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    97
    }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    98
  }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
    99
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   100
  class Here private[Scala_Project](name: String, line: Int)
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
    override def toString: String = name + ":" + line
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   103
    def position: Position.T =
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   104
      isabelle_scala_files.get(name) match {
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   105
        case Some(path) => Position.Line_File(line, path.implode)
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   106
        case None => Position.none
72755
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   107
      }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   108
  }
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   109
8dffbe01a3e1 support for Scala compile-time positions;
wenzelm
parents: 72748
diff changeset
   110
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   111
  /* scala project */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   112
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   113
  def package_dir(source_file: Path): Option[Path] =
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   114
  {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   115
    val is_java = source_file.file_name.endsWith(".java")
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   116
    val lines = split_lines(File.read(source_file))
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   117
    val Package = """\s*\bpackage\b\s*(?:object\b\s*)?((?:\w|\.)+)\b.*""".r
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   118
    lines.collectFirst(
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   119
      {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   120
        case Package(name) =>
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   121
          if (is_java) Path.explode(space_explode('.', name).mkString("/"))
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   122
          else Path.basic(name)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   123
      })
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   124
  }
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   125
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   126
  def the_package_dir(source_file: Path): Path =
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   127
    package_dir(source_file) getOrElse error("Failed to guess package from " + source_file)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   128
73340
0ffcad1f6130 tuned --- fewer warnings;
wenzelm
parents: 73317
diff changeset
   129
  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
   130
  {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   131
    if (symlinks && Platform.is_windows)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   132
      error("Cannot create symlinks on Windows")
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
    if (project_dir.is_file || project_dir.is_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   135
      error("Project directory already exists: " + project_dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   136
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   137
    val java_src_dir = Isabelle_System.make_directory(project_dir + Path.explode("src/main/java"))
72376
04bce3478688 clarified signature;
wenzelm
parents: 72375
diff changeset
   138
    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
   139
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   140
    val (jar_files, source_files) = isabelle_files
72762
d9a54c4c9da9 more robust isabelle_scala_files;
wenzelm
parents: 72755
diff changeset
   141
    isabelle_scala_files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   142
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   143
    for (source <- source_files) {
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   144
      val dir = if (source.file_name.endsWith(".java")) java_src_dir else scala_src_dir
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   145
      val target = dir + the_package_dir(source)
72375
e48d93811ed7 clarified signature;
wenzelm
parents: 72176
diff changeset
   146
      Isabelle_System.make_directory(target)
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   147
      if (symlinks) Isabelle_System.symlink(source, target)
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   148
      else Isabelle_System.copy_file(source, target)
71378
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
    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
   152
    File.write(project_dir + Path.explode("build.gradle"),
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   153
"""plugins {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   154
  id 'scala'
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
repositories {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   158
  mavenCentral()
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
dependencies {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   162
  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
   163
  compile files(
74030
39e05601faeb more accurate scala_project, based on build.props of components;
wenzelm
parents: 73987
diff changeset
   164
    """ + jar_files.map(jar => groovy_string(File.platform_path(jar))).mkString("", ",\n    ", ")") +
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   165
"""
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
""")
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
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
  /* Isabelle tool wrapper */
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   172
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   173
  val isabelle_tool =
72763
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   174
    Isabelle_Tool("scala_project", "setup Gradle project for Isabelle/Scala/jEdit",
3cc73d00553c added document antiquotation @{tool};
wenzelm
parents: 72762
diff changeset
   175
      Scala_Project.here, args =>
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
      var symlinks = false
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   178
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   179
      val getopts = Getopts("""
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   180
Usage: isabelle scala_project [OPTIONS] PROJECT_DIR
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
  Options are:
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   183
    -L           make symlinks to original scala files
71378
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   184
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   185
  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
   186
  such as IntelliJ IDEA.
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   187
""",
71503
df7494f14388 clarified command line;
wenzelm
parents: 71378
diff changeset
   188
        "L" -> (_ => symlinks = true))
71378
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
      val more_args = getopts(args)
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
      val project_dir =
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   193
        more_args match {
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   194
          case List(dir) => Path.explode(dir)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   195
          case _ => getopts.usage()
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   196
        }
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   197
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   198
      scala_project(project_dir, symlinks = symlinks)
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   199
    })
820cf124dced added "isabelle scala_project" to support e.g. IntelliJ IDEA;
wenzelm
parents:
diff changeset
   200
}