diff --git a/.gitignore b/.gitignore index 2d372135..8e4ba164 100644 --- a/.gitignore +++ b/.gitignore @@ -12,11 +12,11 @@ .installed .tested -### MAVEN (include pom.xml in /base) ########################################### +### MAVEN ########################################### *.jar *.war -#pom.xml +pom.xml pom.xml.asc ### NREPL ###################################################################### diff --git a/.travis.yml b/.travis.yml index 1a1856b9..02c38b6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,11 @@ jdk: - openjdk12 - openjdk13 -services: - - docker +install: make --file=.travis/Makefile deps +script: make --file=.travis/Makefile install -install: curl https://raw.githubusercontent.com/boot-clj/docker-boot/master/boot/3/Dockerfile | docker build -t bootclj/boot:latest -f - . -script: docker run -t bootclj/boot:latest cd ~/.boot/cache/bin/3.0.0-SNAPSHOT/ && ls -a +cache: + directories: + - $HOME/.m2 + - $HOME/.boot/cache + - $HOME/bin diff --git a/Makefile b/.travis/Makefile similarity index 88% rename from Makefile rename to .travis/Makefile index bc7567a1..f04b793f 100644 --- a/Makefile +++ b/.travis/Makefile @@ -14,7 +14,7 @@ aetheruber = aether.uber.jar workerjar = boot/worker/target/worker-$(version).jar corejar = boot/core/target/core-$(version).jar basejar = boot/base/target/base-$(version).jar -baseuber = boot/base/target/base-$(version)-jar-with-dependencies.jar +baseuber = boot/base/target/base-$(version)-standalone.jar alljars = $(podjar) $(aetherjar) $(workerjar) $(corejar) $(baseuber) $(bootjar) java_version = $(shell java -version 2>&1 | awk -F '"' '/version/ {print $$2}' |awk -F. '{print $$1 "." $$2}') @@ -44,11 +44,8 @@ bin/boot: mkdirs deps: bin/lein bin/boot -boot/base/pom.xml: $(verfile) boot/base/pom.in.xml - (cd boot/base && cat pom.in.xml |sed 's/__VERSION__/$(version)/' > pom.xml) - -$(basejar): boot/base/pom.xml $(shell find boot/base/src/main/java) - (cd boot/base && mvn -q install) +$(basejar): boot/base/project.clj $(shell find boot/base/src/main/java) + (cd boot/base && lein install) $(podjar): $(verfile) boot/pod/project.clj $(shell find boot/pod/src) (cd boot/pod && lein install) @@ -64,8 +61,8 @@ $(workerjar): $(verfile) boot/worker/project.clj $(shell find boot/worker/src) $(corejar): $(verfile) boot/core/project.clj $(shell find boot/core/src) (cd boot/core && lein install) -$(baseuber): boot/base/pom.xml $(shell find boot/base/src/main) - (cd boot/base && mvn -q assembly:assembly -DdescriptorId=jar-with-dependencies) +$(baseuber): boot/base/project.clj $(shell find boot/base/src/main) + (cd boot/base && lein uberjar) $(bootjar): $(verfile) boot/boot/project.clj (cd boot/boot && lein install) diff --git a/boot.properties b/boot.properties index f7026cba..6852f6f1 100644 --- a/boot.properties +++ b/boot.properties @@ -1 +1,2 @@ +BOOT_VERSION=3.0.0-SNAPSHOT BOOT_AS_ROOT=yes diff --git a/boot/aether/project.clj b/boot/aether/project.clj index 2c41d7a3..4a6e39e3 100644 --- a/boot/aether/project.clj +++ b/boot/aether/project.clj @@ -16,6 +16,7 @@ :dependencies [[org.clojure/clojure "1.9.0" :scope "compile"] [boot/base ~version :scope "provided"] [boot/pod ~version :scope "compile"] + [boot/bootstrap "3.0.0-SNAPSHOT" :scope "compile"] [com.cemerick/pomegranate "1.0.0" :scope "compile"] [org.apache.maven.wagon/wagon-http "2.12" :scope "compile" :exclusions [org.apache.maven.wagon/wagon-provider-api]]]) diff --git a/boot/aether/src/boot/aether.clj b/boot/aether/src/boot/aether.clj index c1afee41..929a3b2b 100644 --- a/boot/aether/src/boot/aether.clj +++ b/boot/aether/src/boot/aether.clj @@ -8,7 +8,8 @@ [boot.pod :as pod] [boot.gpg :as gpg] [boot.from.io.aviso.ansi :as ansi] - [boot.kahnsort :as ksort]) + [boot.kahnsort :as ksort] + [bootstrap.config :as conf]) (:import [boot App] [java.io File] @@ -20,12 +21,10 @@ (def offline? (atom false)) (def update? (atom :daily)) (def local-repo (atom nil)) -(def default-repositories (delay (let [c (boot.App/config "BOOT_CLOJARS_REPO") - m (boot.App/config "BOOT_MAVEN_CENTRAL_REPO")] +(def default-repositories (delay (let [{c :boot-clojars-repo m :boot-maven-central-repo} (conf/config)] [["clojars" {:url (or c "https://repo.clojars.org/")}] ["maven-central" {:url (or m "https://repo1.maven.org/maven2/")}]]))) -(def default-mirrors (delay (let [c (boot.App/config "BOOT_CLOJARS_MIRROR") - m (boot.App/config "BOOT_MAVEN_CENTRAL_MIRROR") +(def default-mirrors (delay (let [{c :boot-clojars-mirror m :boot-maven-central-mirror} (conf/config) f #(when %1 {%2 {:name (str %2 " mirror") :url %1}})] (merge {} (f c "clojars") (f m "maven-central"))))) @@ -391,7 +390,7 @@ context (make-context (into (default-certs) certs))] (override-wagon-registry! (https-registry context))))) -(when-let [certs (boot.App/config "BOOT_CERTIFICATES")] +(when-let [certs (:boot-certificates (conf/config))] (let [certs (string/split certs #":")] (util/dbug "Using SSL certificates: %s\n" certs) (load-certificates! certs))) diff --git a/boot/base/project.clj b/boot/base/project.clj index 2cc8a49d..9f76db49 100644 --- a/boot/base/project.clj +++ b/boot/base/project.clj @@ -8,6 +8,7 @@ :aot [#"^(?!boot\.repl-server).*$"] :jar-exclusions [#"^clojure/core/"] :java-source-paths ["src/main/java"] + :resource-paths ["src/main/resources"] :description "Boot base module–this is the classloader shim." :url "https://github.com/boot-clj/boot" :scm {:url "https://github.com/boot-clj/boot.git" :dir "../../"} @@ -16,5 +17,7 @@ ["sonatype-snaps" {:url "https://oss.sonatype.org/content/repositories/snapshots"}]] :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.projectodd.shimdandy/shimdandy-api "1.2.1" :scope "compile"] + :dependencies [[org.clojure/clojure "1.9.0" :scope "provided"] + [boot/bootstrap "3.0.0-SNAPSHOT" :scope "compile"] + [org.projectodd.shimdandy/shimdandy-api "1.2.1" :scope "compile"] [junit/junit "3.8.1" :scope "test"]]) diff --git a/boot/base/src/main/java/boot/App.java b/boot/base/src/main/java/boot/App.java index 3cd51e3d..1ea86736 100644 --- a/boot/base/src/main/java/boot/App.java +++ b/boot/base/src/main/java/boot/App.java @@ -416,13 +416,6 @@ public class App { try { core.get().close(); } catch (InterruptedException ie) {}}} - public static String - readVersion() throws Exception { - Properties p = new Properties(); - try (InputStream in = resource("boot/base/version.properties")) { - p.load(in); } - return p.getProperty("version"); } - public static void printVersion() throws Exception { Properties p = new Properties(); @@ -446,14 +439,6 @@ public class App { && ! (asroot.equals("yes") || asroot.equals("1") || asroot.equals("true"))) throw new Exception("refusing to run as root (set BOOT_AS_ROOT=yes to force)"); - // BOOT_VERSION is decided by the loader; it will respect the - // boot.properties files, env vars, system properties, etc. - // or it will use the latest installed version. - // - // Since 2.4.0 we can assume that bootversion and appversion - // are the same (or boot.main will throw an exception). - bootversion = appversion = readVersion(); - File cachehome = mkFile(bootdir(), "cache"); File bootprops = mkFile(bootdir(), "boot.properties"); File jardir = mkFile(cachehome, "lib", appversion); @@ -466,24 +451,6 @@ public class App { readProps(bootprops, true); - if (args.length > 0 - && ((args[0]).equals("-u") - || (args[0]).equals("--update"))) { - updateBoot(bootprops, (args.length > 1) ? args[1] : null, "RELEASE"); - System.exit(0); } - - if (args.length > 0 - && ((args[0]).equals("-U") - || (args[0]).equals("--update-snapshot"))) { - updateBoot(bootprops, null, "(0,)"); - System.exit(0); } - - if (args.length > 0 - && ((args[0]).equals("-V") - || (args[0]).equals("--version"))) { - printVersion(); - System.exit(0); } - String repo = (localrepo == null) ? "default" : md5hash((new File(localrepo)).getCanonicalFile().getPath()); @@ -498,3 +465,10 @@ public class App { Thread shutdown = new Thread() { public void run() { ex.shutdown(); }}; Runtime.getRuntime().addShutdownHook(shutdown); System.exit(runBoot(newCore(null), newWorker(), args)); }} + +// public static void +// main(String[] args) throws Exception { + +// Thread shutdown = new Thread() { public void run() { ex.shutdown(); }}; +// Runtime.getRuntime().addShutdownHook(shutdown); +// System.exit(runBoot(newCore(null), newWorker(), args)); }} diff --git a/boot/base/src/main/resources/boot/base/version.properties b/boot/base/src/main/resources/boot/base/version.properties index 5feebe97..cd92d6b0 100644 --- a/boot/base/src/main/resources/boot/base/version.properties +++ b/boot/base/src/main/resources/boot/base/version.properties @@ -1 +1 @@ -version=${pom.version} \ No newline at end of file +version=3.0.0-SNAPSHOT diff --git a/boot/core/build.boot b/boot/core/build.boot index 491a7ca9..23a95041 100644 --- a/boot/core/build.boot +++ b/boot/core/build.boot @@ -1,28 +1,28 @@ (set-env! :source-paths #{"src" "test"} - :dependencies '[[org.clojure/tools.reader "1.0.0-alpha2"] - [metosin/boot-alt-test "0.3.2" :scope "test"]]) + :dependencies '[[org.clojure/tools.reader "1.0.0-alpha2"]]) + ;[metosin/boot-alt-test "0.3.2" :scope "test"]]) -(ns-unmap 'boot.user 'test) +;(ns-unmap 'boot.user 'test) -(require '[boot.test :refer [runtests test-report test-exit]] - '[metosin.boot-alt-test :refer [alt-test]] - 'boot.test-test) +;(require '[boot.test :refer [runtests test-report test-exit]] +; '[metosin.boot-alt-test :refer [alt-test]] +; 'boot.test-test) -(import boot.App) +;(import boot.App) -(deftask integration-test [] - (comp - (runtests) - (test-report) - (test-exit))) +;(deftask integration-test [] +; (comp +; (runtests) +; (test-report) +; (test-exit)) -(deftask unit-test [] - (alt-test :test-matcher #"boot\.cli-test")) +;(deftask unit-test [] +; (alt-test :test-matcher #"boot\.cli-test")) -(deftask test [] - (comp - (with-pass-thru [fs] - (boot.util/info "Testing against version %s\n" (App/config "BOOT_VERSION"))) - (unit-test) - (integration-test))) +;(deftask test [] +; (comp +; (with-pass-thru [fs] +; (boot.util/info "Testing against version %s\n" (App/config "BOOT_VERSION")) +; (unit-test) +; (integration-test)) diff --git a/boot/core/project.clj b/boot/core/project.clj index 371fd692..000e7872 100644 --- a/boot/core/project.clj +++ b/boot/core/project.clj @@ -15,4 +15,5 @@ :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.9.0" :scope "provided"] [boot/base ~version :scope "provided"] - [boot/pod ~version :scope "compile"]]) + [boot/pod ~version :scope "compile"] + [boot/bootstrap "3.0.0-SNAPSHOT" :scope "provided"]]) diff --git a/boot/core/src/boot/app.clj_ b/boot/core/src/boot/app.clj_ new file mode 100644 index 00000000..9d9f5f03 --- /dev/null +++ b/boot/core/src/boot/app.clj_ @@ -0,0 +1,78 @@ +(ns boot.app + (:require [clojure.java.io :as io] + [bootstrap.config :as conf]) + (:import [java.net URLClassLoader] + [java.util.concurrent Executors] + [org.projectodd.shimdandy ClojureRuntimeShim]) + (:gen-class)) + +(defn- invoke-hooks [runtime hooks] + (reduce #(when (.exists %2) (.invoke %1 "clojure.core/load-file" (.getPath %2)) %1) runtime hooks)) + +(def ^:private pods (atom [])) + +(defn- mkshim [name exec data jars] + (let [urls (map #(.toURL (.toURI %)) jars) + classldr (URLClassLoader. urls (ClassLoader/getPlatformClassLoader)) + runtime (ClojureRuntimeShim/newRuntime classldr) + hooks [(io/file (conf/boot-dir) "boot-shim.clj") (io/file "boot-shim.clj")]] + (doto runtime + (.setName (or name "anonymous")) + (invoke-hooks hooks) + (.require "boot.pod") + (.invoke "boot.pod/seal-app-classloader") + (.invoke "boot.pod/extend-addable-classloader") + (.invoke "boot.pod/set-data!" data) + (.invoke "boot.pod/set-pods!" pods) + (.invoke "boot.pod/set-this-pod!" runtime) + #(swap! pods conj %)))) + +(defn- set-pod-repo! [pod repo] + (if-not repo pod + (doto (.get pod) + (.require "boot.aether") + (.invoke "boot.aether/set-local-repo!" repo)))) + +(defn- resolve-dep-jars [shim sym] ;bootver cljname cljver] + (let [repo (:boot-local-repo (conf/config) "default")] + (doto shim + (.require "boot.aether") + (.invoke "boot.aether/set-local-repo!" repo) + (.invoke "boot.aether/update-always!") + (.invoke "boot.aether/resolve-dependency-jars" sym "3.0.0-SNAPSHOT" "org.clojure/clojure" "1.10.0")))) + +(def ^:private pid (atom 0)) + +(defn Exit [code msg] + (ex-info msg {:error-code code})) + +(defn- run-boot [corepod workerpod args] + (let [hooks (atom []) + core (.get @corepod)] + (try + (let [repo (:boot-local-repo (conf/config) "default") + worker (set-pod-repo! @workerpod repo) + pid (and (swap! pid inc) @pid)] + (.require core "boot.main") + (.invoke core "boot.main/-main" pid worker hooks args) + -1) + (catch Throwable t + (println "Boot failed to start:") + (if-let [exdata (ex-data t)] + (:error-code exdata) + (and (.printStackTrace t) -2))) + (finally + (doseq [hook hooks] @hook) + (try (.close core) + (catch InterruptedException ie -3)))))) + +(defn -main [& args] + (let [exec (Executors/newCachedThreadPool) + shutdown (future (.shutdown exec)) + aetherpod (future (mkshim "aether" exec nil "aether.uber.jar")) + corejars (resolve-dep-jars aetherpod "boot/core") + corepod (future (mkshim "core" exec nil corejars)) + workerjars (resolve-dep-jars aetherpod "boot/worker") + workerpod (future (mkshim "worker" exec nil workerjars))] + (.addShutdownHook (Runtime/getRuntime) (fn [] @shutdown)) + (System/exit (run-boot corepod workerpod args)))) diff --git a/boot/core/src/boot/core.clj b/boot/core/src/boot/core.clj index c810a638..74a88e65 100644 --- a/boot/core/src/boot/core.clj +++ b/boot/core/src/boot/core.clj @@ -17,9 +17,10 @@ [boot.util :as util] [boot.from.io.aviso.exception :as ex] [boot.from.clojure.tools.cli :as cli] - [boot.from.backtick :as bt]) + [boot.from.backtick :as bt] + [bootstrap.config :as conf]) (:import - [boot App] + ;[boot App] [java.io File] [java.nio.file Path Paths] [java.net URLClassLoader URL] @@ -45,7 +46,7 @@ .getCanonicalFile file/split-path rest - (apply io/file (App/getBootDir) "cache" "tmp") + (apply io/file (conf/boot-dir) "cache" "tmp") tmp/registry tmp/init! delay)) @@ -60,8 +61,7 @@ (def ^:private checkout-dirs (atom #{})) (def ^:private default-repos [["clojars" {:url "https://repo.clojars.org/"}] ["maven-central" {:url "https://repo1.maven.org/maven2"}]]) -(def ^:private default-mirrors (delay (let [c (boot.App/config "BOOT_CLOJARS_MIRROR") - m (boot.App/config "BOOT_MAVEN_CENTRAL_MIRROR") +(def ^:private default-mirrors (delay (let [{c :boot-clojars-mirror m :boot-maven-central-mirror} (conf/config) f #(when %1 {%2 {:name (str %2 " mirror") :url %1}})] (merge {} (f c "clojars") (f m "maven-central"))))) @@ -230,7 +230,7 @@ "compute a seq of [name new-coord old-coord] elements describing version conflicts when resolving the 'old' dependency vector and the 'new' dependency vector" [old new env] - (let [clj-name (symbol (boot.App/getClojureName)) + (let [clj-name (symbol (:boot-clojure-name (conf/config))) old-deps (-> (map-of-deps env old) (assoc clj-name (clojure-version)))] (->> (map-of-deps env new) (keep (fn [[name coord]] @@ -241,7 +241,7 @@ "Warn, when the version of a dependency changes. Call this with the result of find-version-conflicts as arguments" [coll] - (let [clj-name (symbol (boot.App/getClojureName))] + (let [clj-name (symbol (:boot-clojure-name (conf/config)))] (doseq [[name new-coord old-coord] coll] (let [op (if (= name clj-name) "NOT" "ALSO")] (-> "Classpath conflict: %s version %s already loaded, %s loading version %s\n" @@ -368,7 +368,7 @@ .getCanonicalFile file/split-path (when-not global) - (into [(App/getBootDir) "cache" "cache" (if global "global" "project")]) + (into [(conf/boot-dir) "cache" "cache" (if global "global" "project")]) (#(into % ((juxt namespace name) key))) (apply io/file) (#(doto % .mkdirs)))) diff --git a/boot/core/src/boot/main.clj b/boot/core/src/boot/main.clj index 70efdaf3..392b72c7 100644 --- a/boot/core/src/boot/main.clj +++ b/boot/core/src/boot/main.clj @@ -1,6 +1,6 @@ (ns boot.main - (:import - [boot App]) + ;(:import + ; [boot App] (:require [clojure.java.io :as io] [clojure.string :as string] @@ -9,7 +9,8 @@ [boot.core :as core] [boot.file :as file] [boot.util :as util] - [boot.from.clojure.tools.cli :as cli])) + [boot.from.clojure.tools.cli :as cli] + [bootstrap.config :as conf])) (def cli-opts [["-a" "--asset-paths PATH" "Add PATH to set of asset directories." @@ -110,7 +111,7 @@ (defn shebang? [arg] (when (and (<= 0 (.indexOf arg (int \/))) (.exists (io/file arg))) (let [bang-line (str (first (string/split (slurp arg) #"\n"))) - full-path (System/getProperty "boot.app.path") + full-path (:boot-app-path (conf/config)) base-path (.getName (io/file full-path)) full-pat (re-pattern (format "^#!\\s*\\Q%s\\E(?:\\s+.*)?$" full-path)) base-pat (re-pattern (format "^#!\\s*/usr/bin/env\\s+\\Q%s\\E(?:\\s+.*)?$" base-path))] @@ -121,10 +122,6 @@ (->> (string/split (slurp f) #"\n") (remove string/blank?) (map re-pattern) set))) (defn -main [pod-id worker-pod shutdown-hooks [arg0 & args :as args*]] - (when (not= (boot.App/getVersion) (boot.App/getBootVersion)) - (let [url "https://github.com/boot-clj/boot#install"] - (util/exit-error - (println (format "Please download latest Boot binary: %s" url))))) (pod/set-pod-id! pod-id) (pod/set-worker-pod! worker-pod) @@ -133,7 +130,7 @@ (let [[arg0 args args*] (if (seq args*) [arg0 args args*] ["--help" nil ["--help"]]) - bootscript (App/config "BOOT_FILE" "build.boot") + bootscript (:boot-file (conf/config) "build.boot") exists? #(when (.isFile (io/file %)) %) have-bootscript? (exists? bootscript) [arg0 args] (cond @@ -175,8 +172,8 @@ *err* (util/auto-flush *err*) core/*boot-opts* opts core/*boot-script* arg0 - core/*boot-version* (boot.App/getBootVersion) - core/*app-version* (boot.App/getVersion)] + core/*boot-version* (:boot-version (conf/config)) + core/*app-version* (:boot-version (conf/config))] (util/exit-ok (let [userscript (util/with-let [x (-> (System/getProperty "user.home") @@ -186,7 +183,7 @@ (util/warn "** WARNING: ~/.profile.boot is deprecated.\n") (util/warn "** Please use $BOOT_HOME/profile.boot instead.\n") (util/warn "** See: https://github.com/boot-clj/boot/issues/157\n"))) - userscript (or userscript (exists? (io/file (App/getBootDir) "profile.boot"))) + userscript (or userscript (exists? (io/file (conf/boot-dir) "profile.boot"))) localscript (exists? (io/file "profile.boot")) profile? (not (:no-profile opts)) bootstr (some->> arg0 slurp) @@ -204,8 +201,6 @@ (when (:boot-script opts) (util/exit-ok (print scriptstr))) - (when (:version opts) (util/exit-ok (boot.App/printVersion))) - (reset! core/bootignore (parse-bootignore (io/file ".bootignore"))) (#'core/init!) diff --git a/boot/core/src/boot/parallel.clj b/boot/core/src/boot/parallel.clj index 55a122b3..2cb1e1e8 100644 --- a/boot/core/src/boot/parallel.clj +++ b/boot/core/src/boot/parallel.clj @@ -6,8 +6,9 @@ [boot.util :as util] [boot.from.io.aviso.exception :as ex]) (:import - [java.util HashMap Collections] - [java.util.concurrent CountDownLatch TimeUnit])) + [boot App] + [java.util HashMap Collections] + [java.util.concurrent CountDownLatch TimeUnit])) ;; AR we might need also to modify the map when a task/batch/computation ;; finishes. However, I might overengineer a bit and therefore I am leaving @@ -61,14 +62,14 @@ The first item of the vector is timeout, the second unit"} Clojure objects won't work)." [a args ARG [str] "The boot cli arguments." d data OBJECT ^:! code "The data to pass the (new) boot environment"] - (let [core (boot.App/newCore data) + (let [core (App/newCore data) worker (future pod/worker-pod) args (-> (vec (remove empty? args)) (->> (into-array String)))] (util/dbug "Runboot will run %s \n" (str "\"boot " (string/join " " args) "\"")) (core/with-pass-thru [fs] (future (try (.await (get pod/data "start-latch")) - (boot.App/runBoot core worker (into-array String (into ["-x"] args))) + (App/runBoot core worker (into-array String (into ["-x"] args))) (catch InterruptedException e (util/print-ex e)) (catch Throwable e diff --git a/boot/core/src/boot/test.clj b/boot/core/src/boot/test.clj_ similarity index 100% rename from boot/core/src/boot/test.clj rename to boot/core/src/boot/test.clj_ diff --git a/boot/pod/project.clj b/boot/pod/project.clj index 3000848b..c8873267 100644 --- a/boot/pod/project.clj +++ b/boot/pod/project.clj @@ -16,6 +16,7 @@ :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[boot/base ~version :scope "provided"] - [org.clojure/clojure "1.9.0" :scope "provided"] + [boot/bootstrap "3.0.0-SNAPSHOT" :scope "compile"] + [org.clojure/clojure "1.10.0" :scope "provided"] [org.tcrawley/dynapath "1.0.0" :scope "compile"] - [org.projectodd.shimdandy/shimdandy-impl "1.2.0" :scope "compile"]]) + [org.projectodd.shimdandy/shimdandy-impl "1.2.1" :scope "compile"]]) diff --git a/boot/pod/src/boot/file.clj b/boot/pod/src/boot/file.clj index e4202d38..cd75ec2c 100644 --- a/boot/pod/src/boot/file.clj +++ b/boot/pod/src/boot/file.clj @@ -1,16 +1,17 @@ (ns boot.file (:require - [clojure.java.io :as io] - [clojure.set :as set] - [clojure.data :as data] - [boot.from.digest :as digest] - [clojure.string :as str]) + [clojure.java.io :as io] + [clojure.set :as set] + [clojure.data :as data] + [boot.from.digest :as digest] + [boot.host :as host] + [clojure.string :as str]) (:import - [java.net URI] - [java.io File] - [java.lang.management ManagementFactory] - [java.nio.file Files StandardCopyOption FileVisitOption] - [java.nio.file.attribute FileAttribute PosixFilePermissions]) + [java.net URI] + [java.io File] + [java.lang.management ManagementFactory] + [java.nio.file Files StandardCopyOption FileVisitOption] + [java.nio.file.attribute FileAttribute PosixFilePermissions]) (:refer-clojure :exclude [sync name file-seq])) (set! *warn-on-reflection* true) @@ -21,11 +22,9 @@ (def ^:dynamic *sync-delete* true) (def ^:dynamic *hard-link* true) -(def windows? (boot.App/isWindows)) - (def tmpfile-permissions (into-array FileAttribute - (if windows? + (if host/windows? [] [(PosixFilePermissions/asFileAttribute (PosixFilePermissions/fromString "rw-------"))]))) @@ -251,7 +250,7 @@ (defn match-filter? [filters f] - (let [normalize #(if-not windows? % (str/replace % #"\\" "/"))] + (let [normalize #(if-not host/windows? % (str/replace % #"\\" "/"))] ((apply some-fn (map (partial partial re-find) filters)) (normalize (.getPath ^File f))))) (defn keep-filters? diff --git a/boot/pod/src/boot/filesystem.clj b/boot/pod/src/boot/filesystem.clj index 5f9d989c..5fa54bb6 100644 --- a/boot/pod/src/boot/filesystem.clj +++ b/boot/pod/src/boot/filesystem.clj @@ -7,7 +7,8 @@ [boot.filesystem.patch :as fsp] [boot.file :as file] [boot.from.digest :as digest :refer [md5]] - [boot.util :as util :refer [with-let]]) + [boot.util :as util :refer [with-let]] + [boot.host :as host]) (:import [java.net URI] [java.io File] @@ -38,8 +39,6 @@ (def read-only (PosixFilePermissions/fromString "r--r--r--")) -(def windows? (boot.App/isWindows)) - (defprotocol IToPath (->path [x] "Returns a java.nio.file.Path for x.")) @@ -162,7 +161,7 @@ (util/dbug* "Filesystem: copying %s...\n" (string/join "/" path)) (try (Files/copy ^Path src ^Path dst copy-opts) (Files/setLastModifiedTime dst (FileTime/fromMillis time)) - (when (and mode (not windows?)) (Files/setPosixFilePermissions dst mode)) + (when (and mode (not host/windows?)) (Files/setPosixFilePermissions dst mode)) (catch java.nio.file.NoSuchFileException ex (util/dbug* "Filesystem: %s\n", (str ex)))))) @@ -172,7 +171,7 @@ (util/dbug* "Filesystem: linking %s...\n" (string/join "/" path)) (try (Files/deleteIfExists dst) (Files/createLink (doto dst mkparents!) src) - (when (and mode (not windows?)) (Files/setPosixFilePermissions dst mode)) + (when (and mode (not host/windows?)) (Files/setPosixFilePermissions dst mode)) (catch java.nio.file.NoSuchFileException ex (util/dbug* "Filesystem: %s\n" (str ex)))))) diff --git a/boot/pod/src/boot/gpg.clj b/boot/pod/src/boot/gpg.clj index 7cddcf2d..573fbc10 100644 --- a/boot/pod/src/boot/gpg.clj +++ b/boot/pod/src/boot/gpg.clj @@ -3,13 +3,14 @@ [clojure.java.io :as io] [clojure.java.shell :as shell] [boot.pod :as pod] - [boot.util :as util]) + [boot.util :as util] + [bootstrap.config :as conf]) (:import [java.io StringReader File])) (defn ^{:boot/from :technomancy/leiningen} gpg-program "Lookup the gpg program to use, defaulting to 'gpg'" [] - (or (boot.App/config "BOOT_GPG_COMMAND") "gpg")) + (or (:boot-gpg-command (conf/config)) "gpg")) (defn- ^{:boot/from :technomancy/leiningen} get-english-env [] "Returns environment variables as a map with clojure keywords and LANGUAGE set to 'en'" @@ -75,7 +76,7 @@ pomfile (doto (File/createTempFile "pom" ".xml") (.deleteOnExit) (spit (pod/pom-xml jarfile pompath))) - pomout (io/file outdir (.replaceAll jarname "\\.jar$" ".pom.asc")) ] + pomout (io/file outdir (.replaceAll jarname "\\.jar$" ".pom.asc"))] (spit pomout (sign-it pomfile gpg-options)) [[:extension "pom.asc"] (.getPath pomout)]))) diff --git a/boot/pod/src/boot/host.clj b/boot/pod/src/boot/host.clj new file mode 100644 index 00000000..ed11760f --- /dev/null +++ b/boot/pod/src/boot/host.clj @@ -0,0 +1,8 @@ +(ns boot.host + (:require [clojure.string :as str] + [bootstrap.config :as conf])) + +(defn windows? [] + (-> (:os-name (conf/config)) + (str/lower-case) + (str/starts-with? "win"))) diff --git a/boot/pod/src/boot/pod.clj b/boot/pod/src/boot/pod.clj index b4f58f67..3c674737 100644 --- a/boot/pod/src/boot/pod.clj +++ b/boot/pod/src/boot/pod.clj @@ -9,7 +9,8 @@ [boot.from.io.aviso.exception :as ex] [clojure.java.io :as io] [dynapath.util :as dp] - [dynapath.dynamic-classpath :as cp]) + [dynapath.dynamic-classpath :as cp] + [bootstrap.config :as conf]) (:import [java.util.jar JarFile] [java.lang.ref WeakReference] @@ -70,7 +71,7 @@ dynapath.dynamic-classpath/DynamicClasspath boot.pod/sealed-classloader-fns)) (catch Exception _)) - + (try ;; this import will fail if the user is using Java 9 (import sun.misc.Launcher$AppClassLoader) @@ -336,7 +337,7 @@ that boot may be running inside another instance of boot, so shutdown hooks must be handled carefully as the JVM will not necessarily exit when this boot instance is finished. - + Functions added via add-shutdown-hook! will be processed at the correct time (i.e. when boot is finished in the case of nested instances of boot, or when the JVM exits otherwise)." @@ -400,7 +401,7 @@ The expr is expected to be of the form (f & args). It is evaluated in the pod by resolving f and applying it to args. - + Note: Since forms must be serialized to pass from one pod to another it is not always appropriate to include metadata, as metadata may contain eg. File objects which are not printable/readable by Clojure." @@ -590,7 +591,7 @@ will be excluded from the result (the clojure dependency is identified by the BOOT_CLOJURE_NAME environment setting, which defaults to org.clojure.clojure)." [env & [ignore-clj?]] - (let [clj-dep (symbol (boot.App/config "BOOT_CLOJURE_NAME")) + (let [clj-dep (symbol (:boot-clojure-name (conf/config))) rm-clj (if-not ignore-clj? identity (partial remove #(and (= clj-dep (first (:dep %))) @@ -762,7 +763,7 @@ (defn jars-in-dep-order "Returns a seq of all jar file dependencies specified in the boot environment map env, including transitive dependencies, and in dependency order. - + Dependency order means, eg. if jar B depends on jar A then jar A will appear before jar B in the returned list." [env] @@ -887,8 +888,8 @@ ([] (init-pod! env (boot.App/newPod nil data))) ([{:keys [directories dependencies] :as env} & {:keys [name data]}] (let [dirs (map io/file directories) - cljname (or (boot.App/getClojureName) "org.clojure/clojure") - dfl [['boot/pod (boot.App/getBootVersion)] + {cljname :boot-clojure-name ver :boot-version} (conf/config) + dfl [['boot/pod ver] [(symbol cljname) (clojure-version)]] env (default-dependencies dfl env) jars (resolve-dependency-jars env) @@ -909,7 +910,7 @@ are needed to bootstrap the pod, have no transitive dependencies, and are added automatically." [classpath & {:keys [name data]}] - (doto (->> (assoc env :dependencies [['boot/pod (boot.App/getBootVersion)]]) + (doto (->> (assoc env :dependencies [['boot/pod (:boot-version (conf/config))]]) (resolve-dependency-jars) (into (map io/file classpath)) (into-array java.io.File) @@ -938,7 +939,7 @@ Calling the function with no arguments produces a reference to the current pod. Expressions can be evaluated in this pod via with-eval-in, etc. - + Calling the function with the :refresh argument swaps out the current pod, destroys it, and promotes a pod from the reserve pool. A new pod is created asynchronously to replenish the reserve pool. diff --git a/boot/pod/src/boot/tmpdir.clj b/boot/pod/src/boot/tmpdir.clj index 6bb6f37e..6ce385ae 100644 --- a/boot/pod/src/boot/tmpdir.clj +++ b/boot/pod/src/boot/tmpdir.clj @@ -9,7 +9,8 @@ [boot.pod :as pod] [boot.file :as file] [boot.from.digest :as digest] - [boot.util :as util :refer [with-let]]) + [boot.util :as util :refer [with-let]] + [bootstrap.config :as conf]) (:import [java.io File] [java.util Properties] @@ -113,7 +114,7 @@ (defn- ^File cache-dir [cache-key] - (-> (boot.App/bootdir) + (-> (conf/boot-dir) (io/file "cache" "cache" "fileset") (io/file CACHE_VERSION cache-key))) diff --git a/boot/pod/src/boot/util.clj b/boot/pod/src/boot/util.clj index 73dbe89a..019da479 100644 --- a/boot/pod/src/boot/util.clj +++ b/boot/pod/src/boot/util.clj @@ -7,7 +7,9 @@ [boot.file :as file] [boot.from.io.aviso.ansi :as ansi] [boot.from.io.aviso.exception :as pretty] - [boot.from.me.raynes.conch :as conch]) + [boot.from.me.raynes.conch :as conch] + [bootstrap.config :as conf] + [boot.host :as host]) (:import [java.io File] [java.nio ByteBuffer] @@ -25,7 +27,7 @@ configuration option BOOT_WATCHERS_DISABLE to either '1' or 'yes' or 'true' to disable inotify; any other value keeps normal behavior." [] - (let [value (boot.App/config "BOOT_WATCHERS_DISABLE")] + (let [value (:boot-watchers-disable (conf/config))] (if (string/blank? value) true (not (#{"1" "yes" "true"} @@ -40,15 +42,13 @@ either '1' or 'yes' or 'true' to enable it; any other value disables colorization." [] - (let [value (boot.App/config "BOOT_COLOR")] - (if-not (string/blank? value) - (#{"1" "yes" "true"} (string/lower-case value)) - (not (boot.App/isWindows))))) + (if (#{"1" "yes" "true" true} (:boot-color (conf/config))) true + (not (host/windows?)))) (def ^:dynamic *verbosity* "Atom containing the verbosity level, 1 is lowest, 3 highest. Level 2 corresponds to the -v boot option, level 3 to -vv, etc. - + Levels: 1. Print INFO level messages or higher, colorize and prune stack traces @@ -167,13 +167,13 @@ Note that boot.util/*verbosity* in a pod needs to be altered AFTER pod creation or log level won't be affected." [& args] - (when-not (= "no" (boot.App/config "BOOT_WARN_DEPRECATED")) + (when-not (= "no" (:boot-warn-deprecated (conf/config))) (apply warn args))) (defmacro extends-protocol "Like extend-protocol but allows specifying multiple classes for each of the implementations: - + (extends-protocol IFoo clojure.lang.MapEntry ; <-- this is the difference, multiple clojure.lang.PersistentVector ; <-- classes per implementation @@ -232,7 +232,7 @@ (defmacro dotoseq "A cross between doto and doseq. For example: - + (-> (System/-err) (dotoseq [i (range 0 100)] (.printf \"i = %d\\n\" i)) @@ -252,7 +252,7 @@ is missing." [binding & body] (let [[ks m] [(butlast binding) (last binding)] - req-ks (set (map keyword ks)) ] + req-ks (set (map keyword ks))] `(if-let [dif-ks# (not-empty (set/difference ~req-ks (set (keys ~m))))] (throw (new AssertionError (apply format "missing key(s): %s" dif-ks#))) (let [{:keys ~ks} ~m] ~@body)))) @@ -277,12 +277,11 @@ * This is the preferred method for returning an exit code != 0, this method returns 1. * This macro does not call System.exit(), because this instance of boot - may be nested in another boot instance. Instead a special method on boot.App - is called which handles the exit behavior (calling shutdown hooks etc.)." + may be nested in another boot instance." [& body] `(binding [*out* *err*] ~@body - (throw (boot.App$Exit. (str 1))))) + (throw (Exception. "Boot Error." (str 1))))) (defmacro exit-ok "Evaluates the body, and exits with non-zero status. @@ -291,16 +290,11 @@ * Boot's main explicitly wraps user tasks in exit-ok so that in general it is not necessary to call it for exiting with 0. * This macro does not call System.exit(), because this instance of boot - may be nested in another boot instance. Instead a special method on boot.App - is called which handles the exit behavior (calling shutdown hooks etc.)." + may be nested in another boot instance." [& body] `(try ~@body - (throw (boot.App$Exit. (str 0))) - (catch Throwable e# - (if (instance? boot.App$Exit e#) - (throw e#) - (exit-error (print-ex e#)))))) + (throw (Exception. "Boot OK." (str 0))))) (defmacro with-err-str "Evaluates exprs in a context in which *err* is bound to a fresh StringWriter. @@ -339,9 +333,9 @@ A tree consists of a graph of nodes of the format [ ], where is a string and is a set of nodes (the children of this node). - + Example: - + (util/print-tree [[\"foo\" #{[\"bar\" #{[\"baz\"]}]}]] [\"--\" \"XX\"]) prints: diff --git a/boot/tasks/src/boot/task/built_in.clj b/boot/tasks/src/boot/task/built_in.clj index 26ce6e1f..17be148a 100644 --- a/boot/tasks/src/boot/task/built_in.clj +++ b/boot/tasks/src/boot/task/built_in.clj @@ -19,7 +19,9 @@ [boot.from.digest :as digest] [boot.task-helpers :as helpers] [boot.task-helpers.notify :as notify] - [boot.pedantic :as pedantic]) + [boot.pedantic :as pedantic] + [bootstrap.config :as conf] + [boot.host :as host]) (:import [java.io File] [java.nio.file.attribute PosixFilePermissions] @@ -241,7 +243,7 @@ (pod/with-eval-in p boot.pod/env))] (when pods (util/info "\nPod: %s\n\n" pod-name)) (cond (or deps verify-deps) (print (pod/with-call-worker (boot.aether/dep-tree ~pod-env ~verify-deps))) - env (println (pretty-str (assoc pod-env :config (boot.App/config)))) + env (println (pretty-str (assoc pod-env :config (conf/config)))) updates (mapv prn (pod/outdated pod-env :snapshots update-snapshots)) pedantic (pedantic/prn-conflicts pod-env) :else @usage)))))))) @@ -331,7 +333,7 @@ (defn- mk-posix-file-permissions [posix-string] (try (when posix-string - (if (boot.App/isWindows) + (if (host/windows?) (util/warn "Filemode not supported on Windows\n") (PosixFilePermissions/fromString posix-string))) (catch IllegalArgumentException _ diff --git a/boot/worker/build.boot b/boot/worker/build.boot index 7d6d84c9..e8c0c56d 100644 --- a/boot/worker/build.boot +++ b/boot/worker/build.boot @@ -19,10 +19,9 @@ (require '[metosin.boot-alt-test :refer [alt-test]]) -(import boot.App) -(deftask test [] - (comp - (with-pass-thru [fs] - (boot.util/info "Testing against version %s\n" (App/config "BOOT_VERSION"))) - (alt-test))) +;(deftask test [] +; (comp +; (with-pass-thru [fs] +; (boot.util/info "Testing against version %s\n" (App/config "BOOT_VERSION")) +; (alt-test))