From 7df81f1273312de3a7ca0f4dc092c1d4c4897f2b Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 23 Sep 2021 12:15:01 -0400 Subject: [PATCH] make core.async and rewrite-clj integral (#1014) * make core.async integral (not a feature) tasks (in particular, parallel tasks) require core.async * make rewrite_clj integral (not a feature) * cleanup mistakes --- Dockerfile | 2 -- deps.edn | 11 +++---- doc/build.md | 1 - project.clj | 10 ++---- resources/META-INF/babashka/deps.edn | 11 +++---- script/compile | 2 -- script/uberjar | 14 --------- script/uberjar.bat | 12 ------- .../babashka/impl/clojure/core}/async.clj | 2 +- src/babashka/impl/features.clj | 8 ----- .../babashka/impl/rewrite_clj.clj | 0 src/babashka/main.clj | 31 +++++++------------ test/babashka/main_test.clj | 2 +- 13 files changed, 27 insertions(+), 79 deletions(-) rename {feature-core-async/babashka/impl => src/babashka/impl/clojure/core}/async.clj (99%) rename {feature-rewrite-clj => src}/babashka/impl/rewrite_clj.clj (100%) diff --git a/Dockerfile b/Dockerfile index 6b4aef4f..1cef8366 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,6 @@ ENV BABASHKA_XMX=$BABASHKA_XMX # by setting them at build time via `docker build --build-arg ARG_NAME=true ...` ARG BABASHKA_LEAN= ARG BABASHKA_MUSL= -ARG BABASHKA_FEATURE_CORE_ASYNC= ARG BABASHKA_FEATURE_CSV= ARG BABASHKA_FEATURE_JAVA_NET_HTTP= ARG BABASHKA_FEATURE_JAVA_NIO= @@ -38,7 +37,6 @@ ARG BABASHKA_FEATURE_DATASCRIPT= ARG BABASHKA_FEATURE_LANTERNA= ARG BABASHKA_STATIC= ENV BABASHKA_LEAN=$BABASHKA_LEAN -ENV BABASHKA_FEATURE_CORE_ASYNC=$BABASHKA_FEATURE_CORE_ASYNC ENV BABASHKA_FEATURE_CSV=$BABASHKA_FEATURE_CSV ENV BABASHKA_FEATURE_JAVA_NET_HTTP=$BABASHKA_FEATURE_JAVA_NET_HTTP ENV BABASHKA_FEATURE_JAVA_NIO=$BABASHKA_FEATURE_JAVA_NIO diff --git a/deps.edn b/deps.edn index 363c0459..d296fa11 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,4 @@ -{:paths ["src" "feature-xml" "feature-core-async" +{:paths ["src" "feature-xml" "feature-yaml" "feature-csv" "feature-transit" "feature-java-time" "feature-java-nio" "feature-httpkit-client" "feature-httpkit-server" @@ -7,7 +7,6 @@ "feature-hiccup" "feature-test-check" "feature-spec-alpha" - "feature-rewrite-clj" "feature-selmer" "feature-logging" "pods/src" @@ -56,7 +55,7 @@ {:git/url "https://github.com/babashka/clj-http-lite" :sha "f44ebe45446f0f44f2b73761d102af3da6d0a13e"} borkdude/spartan.spec {:git/url "https://github.com/borkdude/spartan.spec" - :sha "16f7eec4b6589c77c96c9fcf989f78fffcee7c4c"} + :sha "16f7eec4b6589c77c96c9fcf989f78fffcee7c4c"} lambdaisland/regal {:git/url "https://github.com/lambdaisland/regal" :sha "f902d2c43121f9e1c48603d6eb99f5900eb6a9f6"} weavejester/medley {:git/url "https://github.com/weavejester/medley" @@ -91,9 +90,9 @@ clj-commons/multigrep {:mvn/version "0.5.0"} amperity/vault-clj {:mvn/version "1.0.4"} java-http-clj/java-http-clj {:mvn/version "0.4.3"}} - :classpath-overrides {org.clojure/clojure nil - org.clojure/spec.alpha nil - org.clojure/core.specs.alpha nil}} + :classpath-overrides {org.clojure/clojure nil + org.clojure/spec.alpha nil + org.clojure/core.specs.alpha nil}} :clj-nvd {:extra-deps {clj-nvd/clj-nvd {:git/url "https://github.com/miikka/clj-nvd.git" :sha "f2ec98699e057a379baf170cb49cf7ad76874a70"}} diff --git a/doc/build.md b/doc/build.md index 18945435..8442378a 100644 --- a/doc/build.md +++ b/doc/build.md @@ -93,7 +93,6 @@ Babashka supports the following feature flags: | Name | Description | Default | |--------|----------------------------------------------|----------| -| `BABASHKA_FEATURE_CORE_ASYNC` | Includes the [clojure.core.async](https://github.com/clojure/core.async) library | `true` | | `BABASHKA_FEATURE_CSV` | Includes the [clojure.data.csv](https://github.com/clojure/data.csv) library | `true` | | `BABASHKA_FEATURE_JAVA_NET_HTTP` | Includes commonly used classes from the `java.net.http` package | `true` | | `BABASHKA_FEATURE_JAVA_NIO` | Includes commonly used classes from the `java.nio` package | `true` | diff --git a/project.clj b/project.clj index 58561a9a..8fa29cdf 100644 --- a/project.clj +++ b/project.clj @@ -23,8 +23,10 @@ [cheshire "5.10.1"] [nrepl/bencode "1.1.0"] [borkdude/sci.impl.reflector "0.0.1"] + [org.clojure/core.async "1.3.618"] [org.clojure/test.check "1.1.0"] - [com.github.clj-easy/graal-build-time "0.1.0"]] + [com.github.clj-easy/graal-build-time "0.1.0"] + [rewrite-clj/rewrite-clj "1.0.644-alpha"]] :profiles {:feature/xml {:source-paths ["feature-xml"] :dependencies [[org.clojure/data.xml "0.2.0-alpha6"]]} :feature/yaml {:source-paths ["feature-yaml"] @@ -35,8 +37,6 @@ ;:feature/oracledb [:feature/jdbc {:dependencies [[com.oracle.database.jdbc/ojdbc8 "19.8.0.0"]]}] :feature/oracledb [:feature/jdbc {:dependencies [[io.helidon.integrations.db/ojdbc "2.1.0"]]}] ; ojdbc10 + GraalVM config, by Oracle :feature/hsqldb [:feature/jdbc {:dependencies [[org.hsqldb/hsqldb "2.5.1"]]}] - :feature/core-async {:source-paths ["feature-core-async"] - :dependencies [[org.clojure/core.async "1.3.618"]]} :feature/csv {:source-paths ["feature-csv"] :dependencies [[org.clojure/data.csv "1.0.0"]]} :feature/transit {:source-paths ["feature-transit"] @@ -55,8 +55,6 @@ :dependencies [[hiccup/hiccup "2.0.0-alpha2"]]} :feature/test-check {:source-paths ["feature-test-check"]} :feature/spec-alpha {:source-paths ["feature-spec-alpha"]} - :feature/rewrite-clj {:source-paths ["feature-rewrite-clj"] - :dependencies [[rewrite-clj/rewrite-clj "1.0.644-alpha"]]} :feature/selmer {:source-paths ["feature-selmer"] :dependencies [[selmer/selmer "1.12.44"]]} :feature/logging {:source-paths ["feature-logging"] @@ -67,7 +65,6 @@ :feature/yaml :feature/postgresql :feature/hsqldb - :feature/core-async :feature/csv :feature/transit :feature/datascript @@ -77,7 +74,6 @@ :feature/hiccup :feature/test-check :feature/spec-alpha - :feature/rewrite-clj :feature/selmer :feature/logging {:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.5.0"] diff --git a/resources/META-INF/babashka/deps.edn b/resources/META-INF/babashka/deps.edn index 363c0459..d296fa11 100644 --- a/resources/META-INF/babashka/deps.edn +++ b/resources/META-INF/babashka/deps.edn @@ -1,4 +1,4 @@ -{:paths ["src" "feature-xml" "feature-core-async" +{:paths ["src" "feature-xml" "feature-yaml" "feature-csv" "feature-transit" "feature-java-time" "feature-java-nio" "feature-httpkit-client" "feature-httpkit-server" @@ -7,7 +7,6 @@ "feature-hiccup" "feature-test-check" "feature-spec-alpha" - "feature-rewrite-clj" "feature-selmer" "feature-logging" "pods/src" @@ -56,7 +55,7 @@ {:git/url "https://github.com/babashka/clj-http-lite" :sha "f44ebe45446f0f44f2b73761d102af3da6d0a13e"} borkdude/spartan.spec {:git/url "https://github.com/borkdude/spartan.spec" - :sha "16f7eec4b6589c77c96c9fcf989f78fffcee7c4c"} + :sha "16f7eec4b6589c77c96c9fcf989f78fffcee7c4c"} lambdaisland/regal {:git/url "https://github.com/lambdaisland/regal" :sha "f902d2c43121f9e1c48603d6eb99f5900eb6a9f6"} weavejester/medley {:git/url "https://github.com/weavejester/medley" @@ -91,9 +90,9 @@ clj-commons/multigrep {:mvn/version "0.5.0"} amperity/vault-clj {:mvn/version "1.0.4"} java-http-clj/java-http-clj {:mvn/version "0.4.3"}} - :classpath-overrides {org.clojure/clojure nil - org.clojure/spec.alpha nil - org.clojure/core.specs.alpha nil}} + :classpath-overrides {org.clojure/clojure nil + org.clojure/spec.alpha nil + org.clojure/core.specs.alpha nil}} :clj-nvd {:extra-deps {clj-nvd/clj-nvd {:git/url "https://github.com/miikka/clj-nvd.git" :sha "f2ec98699e057a379baf170cb49cf7ad76874a70"}} diff --git a/script/compile b/script/compile index 8a497e2f..9bed92dc 100755 --- a/script/compile +++ b/script/compile @@ -85,7 +85,6 @@ then # Remove all the default features, unless explicitly set to true: export BABASHKA_FEATURE_XML="${BABASHKA_FEATURE_XML:-false}" export BABASHKA_FEATURE_YAML="${BABASHKA_FEATURE_YAML:-false}" - export BABASHKA_FEATURE_CORE_ASYNC="${BABASHKA_FEATURE_CORE_ASYNC:-false}" export BABASHKA_FEATURE_CSV="${BABASHKA_FEATURE_CSV:-false}" export BABAHSKA_FEATURE_TRANSIT="${BABAHSKA_FEATURE_TRANSIT:-false}" export BABASHKA_FEATURE_JAVA_TIME="${BABASHKA_FEATURE_JAVA_TIME:-false}" @@ -97,7 +96,6 @@ then export BABASHKA_FEATURE_HICCUP="${BABASHKA_FEATURE_HICCUP:-false}" export BABASHKA_FEATURE_TEST_CHECK="${BABASHKA_FEATURE_TEST_CHECK:-false}" export BABASHKA_FEATURE_SPEC_ALPHA="${BABASHKA_FEATURE_SPEC_ALPHA:-false}" - export BABASHKA_FEATURE_REWRITE_CLJ="${BABASHKA_FEATURE_REWRITE_CLJ:-false}" export BABASHKA_FEATURE_SELMER="${BABASHKA_FEATURE_SELMER:-false}" export BABASHKA_FEATURE_LOGGING="${BABASHKA_FEATURE_LOGGING:-false}" fi diff --git a/script/uberjar b/script/uberjar index 8baa7681..6a318385 100755 --- a/script/uberjar +++ b/script/uberjar @@ -70,13 +70,6 @@ else BABASHKA_LEIN_PROFILES+=",-feature/yaml" fi -if [ "$BABASHKA_FEATURE_CORE_ASYNC" != "false" ] -then - BABASHKA_LEIN_PROFILES+=",+feature/core-async" -else - BABASHKA_LEIN_PROFILES+=",-feature/core-async" -fi - if [ "$BABASHKA_FEATURE_CSV" != "false" ] then BABASHKA_LEIN_PROFILES+=",+feature/csv" @@ -147,13 +140,6 @@ else BABASHKA_LEIN_PROFILES+=",-feature/spec-alpha" fi -if [ "$BABASHKA_FEATURE_REWRITE_CLJ" != "false" ] -then - BABASHKA_LEIN_PROFILES+=",+feature/rewrite-clj" -else - BABASHKA_LEIN_PROFILES+=",-feature/rewrite-clj" -fi - if [ "$BABASHKA_FEATURE_SELMER" != "false" ] then BABASHKA_LEIN_PROFILES+=",+feature/selmer" diff --git a/script/uberjar.bat b/script/uberjar.bat index 7a7a8e80..38ab72ff 100755 --- a/script/uberjar.bat +++ b/script/uberjar.bat @@ -46,12 +46,6 @@ if not "%BABASHKA_FEATURE_YAML%"=="false" ( set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/yaml ) -if not "%BABASHKA_FEATURE_CORE_ASYNC%"=="false" ( - set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/core-async -) else ( - set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/core-async -) - if not "%BABASHKA_FEATURE_CSV%"=="false" ( set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/csv ) else ( @@ -112,12 +106,6 @@ set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/spec-alpha set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/spec-alpha ) -if not "%BABASHKA_FEATURE_REWRITE_CLJ%"=="false" ( -set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/rewrite-clj -) else ( -set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/rewrite-clj -) - if not "%BABASHKA_FEATURE_SELMER%"=="false" ( set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/selmer ) else ( diff --git a/feature-core-async/babashka/impl/async.clj b/src/babashka/impl/clojure/core/async.clj similarity index 99% rename from feature-core-async/babashka/impl/async.clj rename to src/babashka/impl/clojure/core/async.clj index 46c75499..f6d87959 100644 --- a/feature-core-async/babashka/impl/async.clj +++ b/src/babashka/impl/clojure/core/async.clj @@ -1,4 +1,4 @@ -(ns babashka.impl.async +(ns babashka.impl.clojure.core.async {:no-doc true} (:require [clojure.core.async :as async] [clojure.core.async.impl.protocols :as protocols] diff --git a/src/babashka/impl/features.clj b/src/babashka/impl/features.clj index 6bd3dfe6..96b59978 100644 --- a/src/babashka/impl/features.clj +++ b/src/babashka/impl/features.clj @@ -4,7 +4,6 @@ ;; included by default (def yaml? (not= "false" (System/getenv "BABASHKA_FEATURE_YAML"))) (def xml? (not= "false" (System/getenv "BABASHKA_FEATURE_XML"))) -(def core-async? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_ASYNC"))) (def csv? (not= "false" (System/getenv "BABASHKA_FEATURE_CSV"))) (def transit? (not= "false" (System/getenv "BABASHKA_FEATURE_TRANSIT"))) (def java-time? (not= "false" (System/getenv "BABASHKA_FEATURE_JAVA_TIME"))) @@ -15,7 +14,6 @@ (def core-match? (not= "false" (System/getenv "BABASHKA_FEATURE_CORE_MATCH"))) (def hiccup? (not= "false" (System/getenv "BABASHKA_FEATURE_HICCUP"))) (def test-check? (not= "false" (System/getenv "BABASHKA_FEATURE_TEST_CHECK"))) -(def rewrite-clj? (not= "false" (System/getenv "BABASHKA_FEATURE_REWRITE_CLJ"))) (def selmer? (not= "false" (System/getenv "BABASHKA_FEATURE_SELMER"))) (def logging? (not= "false" (System/getenv "BABASHKA_FEATURE_LOGGING"))) @@ -38,9 +36,6 @@ (when jdbc? (require '[babashka.impl.jdbc])) -(when core-async? - (require '[babashka.impl.async])) - (when csv? (require '[babashka.impl.csv])) @@ -71,9 +66,6 @@ (when spec-alpha? (require '[babashka.impl.spec])) -(when rewrite-clj? - (require '[babashka.impl.rewrite-clj])) - (when selmer? (require '[babashka.impl.selmer])) diff --git a/feature-rewrite-clj/babashka/impl/rewrite_clj.clj b/src/babashka/impl/rewrite_clj.clj similarity index 100% rename from feature-rewrite-clj/babashka/impl/rewrite_clj.clj rename to src/babashka/impl/rewrite_clj.clj diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 0ecffe22..f05eae92 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -9,6 +9,7 @@ [babashka.impl.classes :as classes] [babashka.impl.classpath :as cp :refer [classpath-namespace]] [babashka.impl.clojure.core :as core :refer [core-extras]] + [babashka.impl.clojure.core.async :refer [async-namespace async-protocols-namespace]] [babashka.impl.clojure.java.browse :refer [browse-namespace]] [babashka.impl.clojure.java.io :refer [io-namespace]] [babashka.impl.clojure.java.shell :refer [shell-namespace]] @@ -31,6 +32,7 @@ [babashka.impl.proxy :refer [proxy-fn]] [babashka.impl.reify :refer [reify-fn]] [babashka.impl.repl :as repl] + [babashka.impl.rewrite-clj :as rewrite] [babashka.impl.server :refer [clojure-core-server-namespace]] [babashka.impl.socket-repl :as socket-repl] [babashka.impl.tasks :as tasks :refer [tasks-namespace]] @@ -225,7 +227,6 @@ Use bb run --help to show this help output. (format (str/trim " {:babashka/version \"%s\" - :feature/core-async %s :feature/csv %s :feature/java-nio %s :feature/java-time %s @@ -241,11 +242,9 @@ Use bb run --help to show this help output. :feature/hiccup %s :feature/test-check %s :feature/spec-alpha %s - :feature/rewrite-clj %s :feature/selmer %s :feature/logging %s}") version - features/core-async? features/csv? features/java-nio? features/java-time? @@ -261,7 +260,6 @@ Use bb run --help to show this help output. features/hiccup? features/test-check? features/spec-alpha? - features/rewrite-clj? features/selmer? features/logging?))) @@ -308,11 +306,11 @@ Use bb run --help to show this help output. curl babashka.curl fs babashka.fs bencode bencode.core - deps babashka.deps} + deps babashka.deps + async clojure.core.async} features/xml? (assoc 'xml 'clojure.data.xml) features/yaml? (assoc 'yaml 'clj-yaml.core) features/jdbc? (assoc 'jdbc 'next.jdbc) - features/core-async? (assoc 'async 'clojure.core.async) features/csv? (assoc 'csv 'clojure.data.csv) features/transit? (assoc 'transit 'cognitect.transit))) @@ -357,14 +355,19 @@ Use bb run --help to show this help output. 'babashka.process process-namespace 'clojure.core.server clojure-core-server-namespace 'babashka.deps deps-namespace - 'babashka.tasks tasks-namespace} + 'babashka.tasks tasks-namespace + 'clojure.core.async async-namespace + 'clojure.core.async.impl.protocols async-protocols-namespace + 'rewrite-clj.node rewrite/node-namespace + 'rewrite-clj.paredit rewrite/paredit-namespace + 'rewrite-clj.parser rewrite/parser-namespace + 'rewrite-clj.zip rewrite/zip-namespace + 'rewrite-clj.zip.subedit rewrite/subedit-namespace} features/xml? (assoc 'clojure.data.xml @(resolve 'babashka.impl.xml/xml-namespace)) features/yaml? (assoc 'clj-yaml.core @(resolve 'babashka.impl.yaml/yaml-namespace) 'flatland.ordered.map @(resolve 'babashka.impl.ordered/ordered-map-ns)) features/jdbc? (assoc 'next.jdbc @(resolve 'babashka.impl.jdbc/njdbc-namespace) 'next.jdbc.sql @(resolve 'babashka.impl.jdbc/next-sql-namespace)) - features/core-async? (assoc 'clojure.core.async @(resolve 'babashka.impl.async/async-namespace) - 'clojure.core.async.impl.protocols @(resolve 'babashka.impl.async/async-protocols-namespace)) features/csv? (assoc 'clojure.data.csv @(resolve 'babashka.impl.csv/csv-namespace)) features/transit? (assoc 'cognitect.transit @(resolve 'babashka.impl.transit/transit-namespace)) features/datascript? (assoc 'datascript.core @(resolve 'babashka.impl.datascript/datascript-namespace)) @@ -394,16 +397,6 @@ Use bb run --help to show this help output. 'clojure.spec.alpha @(resolve 'babashka.impl.spec/spec-namespace) 'clojure.spec.gen.alpha @(resolve 'babashka.impl.spec/gen-namespace) 'clojure.spec.test.alpha @(resolve 'babashka.impl.spec/test-namespace))) - features/rewrite-clj? (assoc 'rewrite-clj.node - @(resolve 'babashka.impl.rewrite-clj/node-namespace) - 'rewrite-clj.paredit - @(resolve 'babashka.impl.rewrite-clj/paredit-namespace) - 'rewrite-clj.parser - @(resolve 'babashka.impl.rewrite-clj/parser-namespace) - 'rewrite-clj.zip - @(resolve 'babashka.impl.rewrite-clj/zip-namespace) - 'rewrite-clj.zip.subedit - @(resolve 'babashka.impl.rewrite-clj/subedit-namespace)) features/selmer? (assoc 'selmer.parser @(resolve 'babashka.impl.selmer/selmer-parser-namespace) 'selmer.tags diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 5e1059f6..1be76b81 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -240,7 +240,7 @@ (deftest process-builder-test (let [cmd-line (if main/windows? - "[\"cmd\" \"/c\" \"dir\" ]" + "[\"cmd\" \"/c\" \"dir\"]" "[\"ls\"]")] (is (str/includes? (bb nil (str " (def pb (ProcessBuilder. " cmd-line "))