discontinued apache-commons in favour of jsoup, which is smaller and more useful;
authorwenzelm
Sat, 11 Mar 2023 21:25:24 +0100
changeset 77619 6d0985955872
parent 77618 0212956aaf73
child 77620 58576816d304
discontinued apache-commons in favour of jsoup, which is smaller and more useful;
Admin/components/components.sha1
Admin/components/main
etc/build.props
src/Pure/Admin/component_jsoup.scala
src/Pure/System/isabelle_tool.scala
src/Pure/Thy/html.scala
--- a/Admin/components/components.sha1	Sat Mar 11 16:21:39 2023 +0100
+++ b/Admin/components/components.sha1	Sat Mar 11 21:25:24 2023 +0100
@@ -273,6 +273,7 @@
 c8a19a36adf6cefa779d85f22ded2f4654e68ea5 jortho-1.0-1.tar.gz
 2155e0bdbd29cd3d2905454de2e7203b9661d239 jortho-1.0-2.tar.gz
 ffe179867cf5ffaabbb6bb096db9bdc0d7110065 jortho-1.0.tar.gz
+df8bb213d39a7eecae97e6af3b11752d6c704c90 jsoup-1.15.4.tar.gz
 6c737137cc597fc920943783382e928ea79e3feb kodkodi-1.2.16.tar.gz
 afb04f4048a87bb888fe7b05b0139cb060c7925b kodkodi-1.5.2-1.tar.gz
 5f95c96bb99927f3a026050f85bd056f37a9189e kodkodi-1.5.2.tar.gz
--- a/Admin/components/main	Sat Mar 11 16:21:39 2023 +0100
+++ b/Admin/components/main	Sat Mar 11 21:25:24 2023 +0100
@@ -1,6 +1,5 @@
 #main components for repository clones or release bundles
 gnu-utils-20211030
-apache-commons-20211211
 bash_process-1.3
 bib2xhtml-20190409
 csdp-6.1.1
@@ -17,6 +16,7 @@
 jedit-20211103
 jfreechart-1.5.3
 jortho-1.0-2
+jsoup-1.15.4
 kodkodi-1.5.7
 lipics-3.1.2
 llncs-2.22
--- a/etc/build.props	Sat Mar 11 16:21:39 2023 +0100
+++ b/etc/build.props	Sat Mar 11 21:25:24 2023 +0100
@@ -28,6 +28,7 @@
   src/Pure/Admin/component_fonts.scala \
   src/Pure/Admin/component_jdk.scala \
   src/Pure/Admin/component_jedit.scala \
+  src/Pure/Admin/component_jsoup.scala \
   src/Pure/Admin/component_lipics.scala \
   src/Pure/Admin/component_llncs.scala \
   src/Pure/Admin/component_minisat.scala \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/Admin/component_jsoup.scala	Sat Mar 11 21:25:24 2023 +0100
@@ -0,0 +1,92 @@
+/*  Title:      Pure/Admin/component_jsoup.scala
+    Author:     Makarius
+
+Build Isabelle jsoup component from official download.
+*/
+
+package isabelle
+
+
+object Component_Jsoup {
+  /* build jsoup */
+
+  val default_download_url =
+    "https://repo1.maven.org/maven2/org/jsoup/jsoup/1.15.4/jsoup-1.15.4.jar"
+
+  def build_jsoup(
+    download_url: String = default_download_url,
+    progress: Progress = new Progress,
+    target_dir: Path = Path.current
+  ): Unit = {
+    val Download_Name = """^.*/([^/]+)\.jar""".r
+    val download_name =
+      download_url match {
+        case Download_Name(download_name) => download_name
+        case _ => error("Malformed jar download URL: " + quote(download_url))
+      }
+
+
+    /* component */
+
+    val component_dir =
+      Components.Directory(target_dir + Path.basic(download_name)).create(progress = progress)
+
+    File.write(component_dir.LICENSE,
+      Url.read("https://raw.githubusercontent.com/jhy/jsoup/master/LICENSE"))
+
+
+    /* README */
+
+    File.write(component_dir.README,
+      "This is " + download_name + " from\n" + download_url +
+        "\n\nSee also https://jsoup.org and https://github.com/jhy/jsoup" +
+        "\n\n        Makarius\n        " + Date.Format.date(Date.now()) + "\n")
+
+
+    /* settings */
+
+    component_dir.write_settings("""
+ISABELLE_JSOUP_HOME="$COMPONENT"
+
+classpath "$ISABELLE_JSOUP_HOME/lib/""" + download_name + """.jar"
+""")
+
+
+    /* jar */
+
+    val jar = component_dir.lib + Path.basic(download_name).jar
+    Isabelle_System.make_directory(jar.dir)
+    Isabelle_System.download_file(download_url, jar, progress = progress)
+  }
+
+
+  /* Isabelle tool wrapper */
+
+  val isabelle_tool =
+    Isabelle_Tool("component_jsoup", "build Isabelle jsoup component from official download",
+      Scala_Project.here,
+      { args =>
+        var target_dir = Path.current
+        var download_url = default_download_url
+
+        val getopts = Getopts("""
+Usage: isabelle component_jsoup [OPTIONS] DOWNLOAD
+
+  Options are:
+    -D DIR       target directory (default ".")
+    -U URL       download URL
+                 (default: """" + default_download_url + """")
+
+  Build jsoup component from the specified download URL (JAR).
+""",
+          "D:" -> (arg => target_dir = Path.explode(arg)),
+          "U:" -> (arg => download_url = arg))
+
+        val more_args = getopts(args)
+        if (more_args.nonEmpty) getopts.usage()
+
+        val progress = new Console_Progress()
+
+        build_jsoup(download_url = download_url, progress = progress, target_dir = target_dir)
+      })
+}
--- a/src/Pure/System/isabelle_tool.scala	Sat Mar 11 16:21:39 2023 +0100
+++ b/src/Pure/System/isabelle_tool.scala	Sat Mar 11 21:25:24 2023 +0100
@@ -169,6 +169,7 @@
   Component_Fonts.isabelle_tool,
   Component_JDK.isabelle_tool,
   Component_JEdit.isabelle_tool,
+  Component_Jsoup.isabelle_tool,
   Component_LIPIcs.isabelle_tool,
   Component_LLNCS.isabelle_tool,
   Component_Minisat.isabelle_tool,
--- a/src/Pure/Thy/html.scala	Sat Mar 11 16:21:39 2023 +0100
+++ b/src/Pure/Thy/html.scala	Sat Mar 11 21:25:24 2023 +0100
@@ -258,7 +258,7 @@
   /* input text */
 
   def input(text: String): String =
-    org.apache.commons.text.StringEscapeUtils.unescapeHtml4(text)
+    org.jsoup.nodes.Entities.unescape(text)
 
 
   /* messages */