From 20f5544a6090bfaac63fc084f99f8958e350cbac Mon Sep 17 00:00:00 2001 From: Stuart Sierra Date: Fri, 17 Dec 2010 17:04:15 -0500 Subject: [PATCH] Build and deploy with Maven 2; CLJ-681 * Real pom.xml * Simpler build.xml for local development with Ant * No Clojure plugin; uses AntRun to build Clojure * POM inheritance from Sonatype OSS deployment * Build instructions in README * Automatically builds "slim" and "sources" JARs as before * 'distribution' profile generates a ZIP * version.properties generated by the version in pom.xml * slightly different format * minor changes to clojure.core to handle version.properties * Fix tests that assumed Ant as the test driver * tweaked by Stu to apply cleanly to master --- .gitignore | 8 +- build.xml | 203 +++++------------------------- pom-template.xml | 23 ---- pom.xml | 23 ++++ readme.txt | 20 +++- release.sh | 37 ------ src/assembly/distribution.xml | 49 +++++++ src/assembly/slim.xml | 32 +++++ src/clj/clojure/core.clj | 29 +++-- src/clj/clojure/version.properties | 5 - src/resources/clojure/version.properties | 1 + src/script/run_tests.clj | 57 +++++++++ test/clojure/test_clojure.clj | 103 --------------- test/clojure/test_clojure/protocols.clj | 2 +- test/clojure/test_clojure/reader.clj | 2 +- test/clojure/test_clojure/rt.clj | 11 +- 16 files changed, 237 insertions(+), 368 deletions(-) delete mode 100644 pom-template.xml create mode 100644 pom.xml delete mode 100755 release.sh create mode 100644 src/assembly/distribution.xml create mode 100644 src/assembly/slim.xml delete mode 100644 src/clj/clojure/version.properties create mode 100644 src/resources/clojure/version.properties create mode 100644 src/script/run_tests.clj delete mode 100644 test/clojure/test_clojure.clj diff --git a/.gitignore b/.gitignore index 899c8fc..2f67a91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,5 @@ -test-classes/* -classes/* -*jar -pom.xml +*.jar +target clojure.iws clojure.ipr nbproject/private/ -*.zip -dist diff --git a/build.xml b/build.xml index e7261e5..872c03c 100644 --- a/build.xml +++ b/build.xml @@ -1,87 +1,35 @@ - + - Build with "ant jar" and then start the + Build with "ant" and then start the REPL with: "java -cp clojure.jar clojure.main". - You will need to install the Maven Ant - Tasks to ${ant.home}/lib in order to execute - the nightly-build or stable-build targets. - - + + + + + + - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + + version=${clojure.version.label} - - - + failonerror="true" + fork="true"> @@ -144,132 +89,44 @@ - + - + - - + - + + - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom-template.xml b/pom-template.xml deleted file mode 100644 index b76b4d1..0000000 --- a/pom-template.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - 4.0.0 - org.clojure - clojure - clojure - @clojure-version@ - http://clojure.org/ - - Clojure core environment and runtime library. - - - - Eclipse Public License 1.0 - http://opensource.org/licenses/eclipse-1.0.php - repo - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0eeebd8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + org.clojure + clojure + clojure + 1.3.0-master-SNAPSHOT + http://clojure.org/ + + Clojure core environment and runtime library. + + + + Eclipse Public License 1.0 + http://opensource.org/licenses/eclipse-1.0.php + repo + + + + diff --git a/readme.txt b/readme.txt index b12890b..c0006f1 100644 --- a/readme.txt +++ b/readme.txt @@ -10,8 +10,24 @@ Docs: http://clojure.org Feedback: http://groups.google.com/group/clojure -To Run: java -cp clojure.jar clojure.main -To Build: ant + +To run: java -cp clojure-${VERSION}.jar clojure.main + +To build locally with Ant: ant + + +Maven 2 build instructions: + + To build: mvn package + The built JARs will be in target/ + + To build without testing: mvn package -Dmaven.test.skip=true + + To build and install in local Maven repository: mvn install + + To build a ZIP distribution: mvn package -Pdistribution + The built .zip will be in target/ + -------------------------------------------------------------------------- This program uses the ASM bytecode engineering library which is distributed diff --git a/release.sh b/release.sh deleted file mode 100755 index 1ff8b9c..0000000 --- a/release.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -if [ -z $3 ]; then - echo 'Usage: - (checkout onto correct branch) - (edit changes.txt) - (optional: set CLOJURE_DEPLOY_URL for nonstandard location) - release.sh (qualifier)' - exit 0 -fi - -MAJOR_VERSION=$1 -MINOR_VERSION=$2 -INCREMENTAL_VERSION=$3 -QUALIFIER=$4 - -echo "clojure.version.major=$MAJOR_VERSION -clojure.version.minor=$MINOR_VERSION -clojure.version.incremental=$INCREMENTAL_VERSION -clojure.version.qualifier=$QUALIFIER -clojure.version.interim=false" >src/clj/clojure/version.properties - -if [ -z $QUALIFIER ]; then - VERSION="$MAJOR_VERSION.$MINOR_VERSION.$INCREMENTAL_VERSION" -else - VERSION="$MAJOR_VERSION.$MINOR_VERSION.$INCREMENTAL_VERSION-$QUALIFIER" -fi - -git commit -a -m "[Automated release] Clojure $VERSION" -git tag -a -m "$VERSION" $VERSION - -if [ -z $CLOJURE_DEPLOY_URL ]; then - CLOJURE_DEPLOY_URL=scp://build.clojure.org/srv/www/releases -fi -ant release -Ddeployment.url=$CLOJURE_DEPLOY_URL - -echo "Build is complete. git push if you are satisfied with the result." diff --git a/src/assembly/distribution.xml b/src/assembly/distribution.xml new file mode 100644 index 0000000..410fb0f --- /dev/null +++ b/src/assembly/distribution.xml @@ -0,0 +1,49 @@ + + distribution + + zip + + + + src + src + + + doc + doc + + + test + test + + + target + / + false + + *.jar + + + + + + pom.xml + + + build.xml + + + readme.txt + true + + + changes.txt + + + clojure.iml + + + epl-v10.html + + + diff --git a/src/assembly/slim.xml b/src/assembly/slim.xml new file mode 100644 index 0000000..5958439 --- /dev/null +++ b/src/assembly/slim.xml @@ -0,0 +1,32 @@ + + slim + + jar + + false + + + src/clj + / + + + src/resources + / + true + + + target/classes/clojure/asm + clojure/asm + + + target/classes/clojure/lang + clojure/lang + + + + + target/classes/clojure/main.class + clojure + + + diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index bd4c05d..6fa139d 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -5908,18 +5908,23 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clojure version number ;;;;;;;;;;;;;;;;;;;;;; -(let [version-stream (.getResourceAsStream (clojure.lang.RT/baseLoader) - "clojure/version.properties") +(let [version-stream (.getResourceAsStream + (clojure.lang.RT/baseLoader) + "clojure/version.properties") properties (doto (new java.util.Properties) (.load version-stream)) - prop (fn [k] (.getProperty properties (str "clojure.version." k))) - clojure-version {:major (Integer/valueOf ^String (prop "major")) - :minor (Integer/valueOf ^String (prop "minor")) - :incremental (Integer/valueOf ^String (prop "incremental")) - :qualifier (prop "qualifier")}] - (def ^:dynamic *clojure-version* - (if (not (= (prop "interim") "false")) - (clojure.lang.RT/assoc clojure-version :interim true) - clojure-version))) + version-string (.getProperty properties "version") + [_ major minor incremental qualifier snapshot] + (re-matches + #"(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9_]+))?(?:-(SNAPSHOT))?" + version-string) + clojure-version {:major (Integer/valueOf ^String major) + :minor (Integer/valueOf ^String minor) + :incremental (Integer/valueOf ^String incremental) + :qualifier (if (= qualifier "SNAPSHOT") nil qualifier)}] + (def ^:dynamic *clojure-version* + (if (.contains version-string "SNAPSHOT") + (clojure.lang.RT/assoc clojure-version :interim true) + clojure-version))) (add-doc-and-meta *clojure-version* "The version info for Clojure core, as a map containing :major :minor @@ -5941,7 +5946,7 @@ (when-let [q (:qualifier *clojure-version*)] (when (pos? (count q)) (str "-" q))) (when (:interim *clojure-version*) - "-SNAPSHOT"))) + "-SNAPSHOT"))) (defn promise "Alpha - subject to change. diff --git a/src/clj/clojure/version.properties b/src/clj/clojure/version.properties deleted file mode 100644 index 908346f..0000000 --- a/src/clj/clojure/version.properties +++ /dev/null @@ -1,5 +0,0 @@ -clojure.version.major=1 -clojure.version.minor=3 -clojure.version.incremental=0 -clojure.version.qualifier=master -clojure.version.interim=interim diff --git a/src/resources/clojure/version.properties b/src/resources/clojure/version.properties new file mode 100644 index 0000000..75ac2d2 --- /dev/null +++ b/src/resources/clojure/version.properties @@ -0,0 +1 @@ +version=${version} \ No newline at end of file diff --git a/src/script/run_tests.clj b/src/script/run_tests.clj new file mode 100644 index 0000000..7c606e2 --- /dev/null +++ b/src/script/run_tests.clj @@ -0,0 +1,57 @@ +(ns clojure.test-clojure (:require clojure.test)) + +(def test-namespaces '[ +clojure.test-clojure.agents +clojure.test-clojure.annotations +clojure.test-clojure.atoms +clojure.test-clojure.clojure-set +clojure.test-clojure.clojure-xml +clojure.test-clojure.clojure-zip +clojure.test-clojure.compilation +clojure.test-clojure.control +clojure.test-clojure.data +clojure.test-clojure.data-structures +clojure.test-clojure.def +clojure.test-clojure.errors +clojure.test-clojure.evaluation +clojure.test-clojure.for +clojure.test-clojure.genclass.examples +clojure.test-clojure.genclass +clojure.test-clojure.java.io +clojure.test-clojure.java.javadoc +clojure.test-clojure.java.shell +clojure.test-clojure.java-interop +clojure.test-clojure.keywords +clojure.test-clojure.logic +clojure.test-clojure.macros +clojure.test-clojure.main +clojure.test-clojure.metadata +clojure.test-clojure.multimethods +clojure.test-clojure.ns-libs +clojure.test-clojure.numbers +clojure.test-clojure.other-functions +clojure.test-clojure.parallel +clojure.test-clojure.pprint +clojure.test-clojure.predicates +clojure.test-clojure.printer +clojure.test-clojure.protocols +clojure.test-clojure.reader +clojure.test-clojure.reflect +clojure.test-clojure.refs +clojure.test-clojure.repl +clojure.test-clojure.rt +clojure.test-clojure.sequences +clojure.test-clojure.serialization +clojure.test-clojure.special +clojure.test-clojure.string +clojure.test-clojure.test +clojure.test-clojure.test-fixtures +clojure.test-clojure.transients +clojure.test-clojure.vars +clojure.test-clojure.vectors +]) + +(apply require test-namespaces) + +(let [results (apply clojure.test/run-tests test-namespaces)] + (System/exit (+ (:error results) (:fail results)))) diff --git a/test/clojure/test_clojure.clj b/test/clojure/test_clojure.clj deleted file mode 100644 index d66ecf2..0000000 --- a/test/clojure/test_clojure.clj +++ /dev/null @@ -1,103 +0,0 @@ -; Copyright (c) Rich Hickey. All rights reserved. -; The use and distribution terms for this software are covered by the -; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) -; which can be found in the file epl-v10.html at the root of this distribution. -; By using this software in any fashion, you are agreeing to be bound by -; the terms of this license. -; You must not remove this notice, or any other, from this software. -; - -;; clojure.test-clojure -;; -;; Tests for the facilities provided by Clojure -;; -;; scgilardi (gmail) -;; Created 22 October 2008 - -(ns clojure.test-clojure - (:require [clojure.test :as t]) - (:gen-class)) - -(def test-names - [:reader - :printer - :compilation - :evaluation - :special - :macros - :metadata - :ns-libs - :logic - :predicates - :control - :data-structures - :numbers - :sequences - :for - :multimethods - :other-functions - :vars - :refs - :agents - :atoms - :parallel - :java-interop - :test - :test-fixtures - ;; libraries - :clojure-set - :clojure-xml - :clojure-zip - :protocols - :genclass - :main - :vectors - :annotations - :pprint - :serialization - :rt - :repl - :java.io - :string - :java.javadoc - :java.shell - :transients - :def - :keywords - :data - :reflect - :errors - ]) - -(def test-namespaces - (map #(symbol (str "clojure.test-clojure." (name %))) - test-names)) - -(defn run - "Runs all defined tests" - [] - (println "Loading tests...") - (apply require :reload-all test-namespaces) - (apply t/run-tests test-namespaces)) - -(defn run-ant - "Runs all defined tests, prints report to *err*, throw if failures. This works well for running in an ant java task." - [] - (let [rpt t/report] - (binding [;; binding to *err* because, in ant, when the test target - ;; runs after compile-clojure, *out* doesn't print anything - *out* *err* - t/*test-out* *err* - t/report (fn report [m] - (if (= :summary (:type m)) - (do (rpt m) - (if (or (pos? (:fail m)) (pos? (:error m))) - (throw (new Exception (str (:fail m) " failures, " (:error m) " errors."))))) - (rpt m)))] - (run)))) - -(defn -main - "Run all defined tests from the command line" - [& args] - (run) - (System/exit 0)) diff --git a/test/clojure/test_clojure/protocols.clj b/test/clojure/test_clojure/protocols.clj index b28f84e..b46fbdf 100644 --- a/test/clojure/test_clojure/protocols.clj +++ b/test/clojure/test_clojure/protocols.clj @@ -75,7 +75,7 @@ (eval '(defprotocol Elusive (old-method [x]))) (eval '(defprotocol Elusive (new-method [x]))) (is (= :new-method (eval '(new-method (reify Elusive (new-method [x] :new-method)))))) - (is (fails-with-cause? IllegalArgumentException #"No method of interface: user\.Elusive found for function: old-method of protocol: Elusive \(The protocol method may have been defined before and removed\.\)" + (is (fails-with-cause? IllegalArgumentException #"No method of interface: .*\.Elusive found for function: old-method of protocol: Elusive \(The protocol method may have been defined before and removed\.\)" (eval '(old-method (reify Elusive (new-method [x] :new-method)))))))) (deftype ExtendTestWidget [name]) diff --git a/test/clojure/test_clojure/reader.clj b/test/clojure/test_clojure/reader.clj index e1ef925..7a06034 100644 --- a/test/clojure/test_clojure/reader.clj +++ b/test/clojure/test_clojure/reader.clj @@ -237,7 +237,7 @@ ) (deftest reading-keywords - (are [x y] (= x (read-string y)) + (are [x y] (= x (binding [*ns* (the-ns 'user)] (read-string y))) :foo ":foo" :foo/bar ":foo/bar" :user/foo "::foo") diff --git a/test/clojure/test_clojure/rt.clj b/test/clojure/test_clojure/rt.clj index 478cacb..0a47f0b 100644 --- a/test/clojure/test_clojure/rt.clj +++ b/test/clojure/test_clojure/rt.clj @@ -9,7 +9,8 @@ ; Author: Stuart Halloway (ns clojure.test-clojure.rt - (:use clojure.test clojure.test-helper)) + (:use clojure.test clojure.test-helper) + (:require clojure.set)) (defmacro with-err-print-writer "Evaluate with err pointing to a temporary PrintWriter, and @@ -59,19 +60,19 @@ (defn prefers [] (throw (RuntimeException. "rebound!"))))) (testing "reflection cannot resolve field" (should-print-err-message - #"Reflection warning, NO_SOURCE_PATH:\d+ - reference to field blah can't be resolved\.\r?\n" + #"Reflection warning, .*:\d+ - reference to field blah can't be resolved\.\r?\n" (defn foo [x] (.blah x)))) (testing "reflection cannot resolve instance method" (should-print-err-message - #"Reflection warning, NO_SOURCE_PATH:\d+ - call to zap can't be resolved\.\r?\n" + #"Reflection warning, .*:\d+ - call to zap can't be resolved\.\r?\n" (defn foo [x] (.zap x 1)))) (testing "reflection cannot resolve static method" (should-print-err-message - #"Reflection warning, NO_SOURCE_PATH:\d+ - call to valueOf can't be resolved\.\r?\n" + #"Reflection warning, .*:\d+ - call to valueOf can't be resolved\.\r?\n" (defn foo [] (Integer/valueOf #"boom")))) (testing "reflection cannot resolve constructor" (should-print-err-message - #"Reflection warning, NO_SOURCE_PATH:\d+ - call to java.lang.String ctor can't be resolved\.\r?\n" + #"Reflection warning, .*:\d+ - call to java.lang.String ctor can't be resolved\.\r?\n" (defn foo [] (String. 1 2 3))))) (def example-var) -- 1.7.1