# HG changeset patch # User wenzelm # Date 1635858302 -3600 # Node ID 0659536b150be16fc74ebb0c925e452ec0e3ee76 # Parent cd674ebf6cac34bc8ba4c877433097bd01aabb25 more robust "isabelle scala_project": Gradle has been replaced by Maven; diff -r cd674ebf6cac -r 0659536b150b NEWS --- a/NEWS Mon Nov 01 23:13:14 2021 +0100 +++ b/NEWS Tue Nov 02 14:05:02 2021 +0100 @@ -532,7 +532,8 @@ - sources of for the jEdit text editor and the Isabelle/jEdit plugins (jedit_base and jedit_main) are included by default, - more sources may be given on the command-line, - - options -f and -D make the tool more convenient. + - options -f and -D make the tool more convenient, + - Gradle has been replaced by Maven (less ambitious and more robust). * Remote provers from SystemOnTPTP (notably for Sledgehammer) are now managed via Isabelle/Scala instead of perl; the dependency on diff -r cd674ebf6cac -r 0659536b150b src/Doc/System/Scala.thy --- a/src/Doc/System/Scala.thy Mon Nov 01 23:13:14 2021 +0100 +++ b/src/Doc/System/Scala.thy Tue Nov 02 14:05:02 2021 +0100 @@ -278,11 +278,11 @@ -L make symlinks to original source files -f force update of existing directory - Setup Gradle project for Isabelle/Scala/jEdit --- to support Scala IDEs + Setup Maven project for Isabelle/Scala/jEdit --- to support common IDEs such as IntelliJ IDEA.\} - The generated configuration is for Gradle\<^footnote>\\<^url>\https://gradle.org\\, but the - main purpose is to import it into common Scala IDEs, such as IntelliJ + The generated configuration is for Maven\<^footnote>\\<^url>\https://maven.apache.org\\, but + the main purpose is to import it into common IDEs, such as IntelliJ IDEA\<^footnote>\\<^url>\https://www.jetbrains.com/idea\\. This allows to explore the sources with static analysis and other hints in real-time. diff -r cd674ebf6cac -r 0659536b150b src/Pure/Tools/scala_project.scala --- a/src/Pure/Tools/scala_project.scala Mon Nov 01 23:13:14 2021 +0100 +++ b/src/Pure/Tools/scala_project.scala Tue Nov 02 14:05:02 2021 +0100 @@ -1,7 +1,7 @@ /* Title: Pure/Tools/scala_project.scala Author: Makarius -Manage Isabelle/Scala/Java project sources, with output to Gradle for +Manage Isabelle/Scala/Java project sources, with output to Maven for IntelliJ IDEA. */ @@ -10,15 +10,56 @@ object Scala_Project { - /* groovy syntax */ + /* Maven project */ - def groovy_string(s: String): String = + def java_version: String = "11" + def scala_version: String = scala.util.Properties.versionNumberString + + def maven_project(jars: List[Path]): String = { - s.map(c => - c match { - case '\t' | '\b' | '\n' | '\r' | '\f' | '\\' | '\'' | '"' => "\\" + c - case _ => c.toString - }).mkString("'", "", "'") + def dependency(jar: Path): String = + { + val name = jar.expand.drop_ext.base.implode + val system_path = File.platform_path(jar.absolute) + """ + classpath + """ + XML.text(name) + """ + 0 + system + """ + XML.text(system_path) + """ + """ + } + + """ + + 4.0.0 + + isabelle + isabelle + 0 + + + UTF-8 + """ + java_version + """ + """ + java_version + """ + + + + + + net.alchim31.maven + scala-maven-plugin + 4.5.3 + + """ + scala_version + """ + + + + + + """" + jars.map(dependency).mkString("\n", "\n", "\n") + """ +""" } @@ -127,7 +168,7 @@ if (project_dir.file.exists) { val detect = project_dir.is_dir && - (project_dir + Path.explode("build.gradle")).is_file && + (project_dir + Path.explode("pom.xml")).is_file && (project_dir + Path.explode("src/main/scala")).is_dir if (force && detect) { @@ -146,6 +187,8 @@ val (jars, sources) = isabelle_files isabelle_scala_files + File.write(project_dir + Path.explode("pom.xml"), maven_project(jars)) + for (source <- sources ::: more_sources) { val dir = (if (source.is_java) java_src_dir else scala_src_dir) + the_package_dir(source) val target_dir = project_dir + dir @@ -156,31 +199,13 @@ if (symlinks) Isabelle_System.symlink(source.absolute, target_dir, native = true) else Isabelle_System.copy_file(source, target_dir) } - - File.write(project_dir + Path.explode("settings.gradle"), "rootProject.name = 'Isabelle'\n") - File.write(project_dir + Path.explode("build.gradle"), -"""plugins { - id 'scala' -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.scala-lang:scala-library:""" + scala.util.Properties.versionNumberString + """' - compileOnly files( - """ + jars.map(jar => groovy_string(File.platform_path(jar))).mkString("", ",\n ", ")") + -""" -} -""") } /* Isabelle tool wrapper */ val isabelle_tool = - Isabelle_Tool("scala_project", "setup Gradle project for Isabelle/Scala/jEdit", + Isabelle_Tool("scala_project", "setup Maven project for Isabelle/Scala/jEdit", Scala_Project.here, args => { var project_dir = default_project_dir @@ -195,7 +220,7 @@ -L make symlinks to original source files -f force update of existing directory - Setup Gradle project for Isabelle/Scala/jEdit --- to support Scala IDEs + Setup Maven project for Isabelle/Scala/jEdit --- to support common IDEs such as IntelliJ IDEA. """, "D:" -> (arg => project_dir = Path.explode(arg)),