diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f7642d..51d2661 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,11 @@ version: 2.0 default: &default-steps steps: - checkout + - run: + # Note: this makes it hard to reproduce builds but easier to spot incompatibilities with + # newer PlantUML releases. Current trade off seems acceptable. + name: Download the latest PlantUML release + command: sh ./bin/download-plantuml.sh - run: name: Update APT packages command: apt-get update diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..1ccc932 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 90 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 10 +# Issues with these labels will never be considered stale +exemptLabels: + - help-wanted + - enhancement +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/README.md b/README.md index 40f92a5..bf2ae91 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ Also, to enable preview you need to tell `plantuml-mode` where to locate the Pla M-x customize-variable plantuml-jar-path +You can also download the latest version of PlantUML straight into `plantuml-jar-path`: + + M-x plantuml-download-jar + # Features - Syntax highlight diff --git a/bin/download-plantuml.sh b/bin/download-plantuml.sh new file mode 100644 index 0000000..3be3725 --- /dev/null +++ b/bin/download-plantuml.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Where the script is executed +CURRENT_PATH="$(dirname "$(readlink -f "$0")")" + +# Where to download the file +OUTPUT_PATH="${CURRENT_PATH}/plantuml.jar" + +# Retrieve the list of versions, in XML format, only one result (the latest) +VERSIONS_URL='https://search.maven.org/solrsearch/select?q=g:net.sourceforge.plantuml+AND+a:plantuml&core=gav&start=0&rows=1&wt=xml' + +# Only match the contents of the version (name="v") XML tag +LATEST_VERSION="$(curl -s "${VERSIONS_URL}" | grep -oP '(?<=).*(?=)')" + +# Compose the download link +DOWNLOAD_URL="https://search.maven.org/remotecontent?filepath=net/sourceforge/plantuml/plantuml/${LATEST_VERSION}/plantuml-${LATEST_VERSION}.jar" + +# finally, download the JAR file +echo "Downloading PlantUML v${LATEST_VERSION} into ${OUTPUT_PATH}" +curl -so "${OUTPUT_PATH}" "${DOWNLOAD_URL}" 2>/dev/null diff --git a/bin/plantuml.jar b/bin/plantuml.jar deleted file mode 100644 index bb909e1..0000000 Binary files a/bin/plantuml.jar and /dev/null differ diff --git a/plantuml-mode.el b/plantuml-mode.el index 4acf133..7de4062 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -37,6 +37,7 @@ ;;; Change log: ;; +;; version 1.2.11, 2019-04-09 Added `plantuml-download-jar' ;; version 1.2.10, 2019-04-03 Avoid messing with window layouts and buffers -- courtesy of https://github.com/wailo ;; version 1.2.9, Revamped indentation support, now working with a greater number of keywords ;; version 1.2.8, 2019-01-07 Support indentation for activate / deactivate blocks; allow customization of `plantuml-java-args' @@ -69,6 +70,7 @@ ;;; Code: (require 'thingatpt) (require 'dash) +(require 'xml) (defgroup plantuml-mode nil "Major mode for editing plantuml file." @@ -163,6 +165,31 @@ (insert msg) (insert "\n")))))) +(defun plantuml-download-jar () + "Download the latest PlantUML JAR file and install it into `plantuml-jar-path'." + (interactive) + (if (y-or-n-p (format "Download the latest PlantUML JAR file into %s? " plantuml-jar-path)) + (if (or (not (file-exists-p plantuml-jar-path)) + (y-or-n-p (format "The PlantUML jar file already exists at %s, overwrite? " plantuml-jar-path))) + (with-current-buffer (url-retrieve-synchronously "https://search.maven.org/solrsearch/select?q=g:net.sourceforge.plantuml+AND+a:plantuml&core=gav&start=0&rows=1&wt=xml") + (mkdir (file-name-directory plantuml-jar-path) t) + (let* ((parse-tree (xml-parse-region)) + (doc (->> parse-tree + (assq 'response) + (assq 'result) + (assq 'doc))) + (strs (xml-get-children doc 'str)) + (version (->> strs + (--filter (string-equal "v" (xml-get-attribute it 'name))) + (first) + (xml-node-children) + (first)))) + (message (concat "Downloading PlantUML v" version " into " plantuml-jar-path)) + (url-copy-file (format "https://search.maven.org/remotecontent?filepath=net/sourceforge/plantuml/plantuml/%s/plantuml-%s.jar" version version) plantuml-jar-path) + (kill-buffer)) + (message "Aborted."))) + (message "Aborted."))) + (defun plantuml-init () "Initialize the keywords or builtins from the cmdline language output." (unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path))