summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-04-27 23:10:53 +0000
committerRich Hickey <richhickey@gmail.com>2009-04-27 23:10:53 +0000
commit37ae4fb81152735afbc12a3334c59be5fecda81e (patch)
treef88dbdb1ca8db3c99922c3a9a7552988ecd6ee7a
parente9212ed36488b6fab3809082e8771c19be81da84 (diff)
added support for versioned builds, alignment with *clojure-version*, (clojure-version) function. Note this will create jars with names like: clojure-1.0.0-RC1-SNAPSHOT.jar [issue 110], patch from laurent.petit
-rw-r--r--build.xml68
-rw-r--r--pom-template.xml (renamed from pom.xml)4
-rw-r--r--src/clj/clojure/core.clj42
-rw-r--r--src/clj/clojure/main.clj4
-rw-r--r--src/clj/clojure/version.properties5
5 files changed, 106 insertions, 17 deletions
diff --git a/build.xml b/build.xml
index c385958f..ddfe5a79 100644
--- a/build.xml
+++ b/build.xml
@@ -12,9 +12,44 @@
<property name="jsrc" location="${src}/jvm"/>
<property name="cljsrc" location="${src}/clj"/>
<property name="build" location="classes"/>
- <property name="clojure_jar" location="clojure.jar"/>
- <property name="slim_jar" location="clojure-slim.jar"/>
- <property name="src_jar" location="clojure-sources.jar"/>
+
+ <!-- version related properties -->
+ <property file="${cljsrc}/clojure/version.properties"/>
+ <!-- ensures all version properties are present -->
+ <fail unless="clojure.version.major"/>
+ <fail unless="clojure.version.minor"/>
+ <fail unless="clojure.version.interim"/>
+
+ <condition property="clojure.version.incremental.label"
+ value=".${clojure.version.incremental}"
+ else="">
+ <length string="${clojure.version.incremental}" when="greater" length="0" />
+ </condition>
+ <condition property="clojure.version.qualifier.label"
+ value="-${clojure.version.qualifier}"
+ else="">
+ <length string="${clojure.version.qualifier}" when="greater" length="0" />
+ </condition>
+ <condition property="clojure.version.interim.label"
+ value="-SNAPSHOT"
+ else="">
+ <!-- We place -SNAPSHOT whenever interim is not set to false, not only
+ if interim is set to true (this is less typo prone in the worst case -->
+ <not><equals arg1="${clojure.version.interim}" arg2="false" trim="true"/></not>
+ </condition>
+
+ <property name="clojure.version.label"
+ value="${clojure.version.major}.${clojure.version.minor}${clojure.version.incremental.label}${clojure.version.qualifier.label}${clojure.version.interim.label}"/>
+
+ <!-- general filterset for use when clojure version must be copied -->
+ <filterset id="clojure-version-filterset">
+ <filter token="clojure-version" value="${clojure.version.label}"/>
+ </filterset>
+
+ <property name="clojure_jar" location="clojure-${clojure.version.label}.jar"/>
+ <property name="slim_jar" location="clojure-slim-${clojure.version.label}.jar"/>
+ <property name="src_jar" location="clojure-sources-${clojure.version.label}.jar"/>
+
<!-- These make sense for building on tapestry.formos.com -->
@@ -24,6 +59,17 @@
<target name="init" depends="clean">
<tstamp/>
<mkdir dir="${build}"/>
+ <antcall target="init-version"/>
+ </target>
+
+ <target name="init-version">
+ <copy file="pom-template.xml"
+ tofile="pom.xml">
+ <filterset refid="clojure-version-filterset"/>
+ </copy>
+ <!--prevents users from modifying accidentally the generated pom.xml
+ works only on linux.-->
+ <chmod file="pom.xml" perm="ugo-w"/>
</target>
<target name="compile-java" depends="init"
@@ -49,7 +95,10 @@
<target name="clojure" depends="compile-clojure"
description="Create clojure jar file.">
<jar jarfile="${clojure_jar}" basedir="${build}">
- <fileset dir="${cljsrc}" includes="**/*.clj"/>
+ <fileset dir="${cljsrc}">
+ <include name="**/*.clj"/>
+ <include name="clojure/version.properties"/>
+ </fileset>
<manifest>
<attribute name="Main-Class" value="clojure.main"/>
<attribute name="Class-Path" value="."/>
@@ -63,7 +112,10 @@
<fileset dir="${build}" includes="clojure/asm/**"/>
<fileset dir="${build}" includes="clojure/lang/**"/>
<fileset dir="${build}" includes="clojure/main.class"/>
- <fileset dir="${cljsrc}" includes="**/*.clj"/>
+ <fileset dir="${cljsrc}">
+ <include name="**/*.clj"/>
+ <include name="clojure/version.properties"/>
+ </fileset>
<manifest>
<attribute name="Main-Class" value="clojure.main"/>
<attribute name="Class-Path" value="."/>
@@ -73,7 +125,10 @@
<target name="clojure-sources" depends="init"
description="Create a JAR of Java sources.">
- <jar jarfile="${src_jar}" basedir="${jsrc}"/>
+ <jar jarfile="${src_jar}" basedir="${jsrc}" includes="**/*">
+ <fileset dir="${cljsrc}"
+ includes="clojure/version.properties"/>
+ </jar>
</target>
<target name="jar" depends="clojure"/>
@@ -83,6 +138,7 @@
<target name="clean"
description="Remove autogenerated files and directories.">
<delete dir="${build}"/>
+ <delete file="pom.xml"/>
</target>
<target name="-setup-maven">
diff --git a/pom.xml b/pom-template.xml
index 926316da..354c2345 100644
--- a/pom.xml
+++ b/pom-template.xml
@@ -6,7 +6,7 @@
<groupId>org.clojure</groupId>
<artifactId>clojure-lang</artifactId>
<name>clojure-lang</name>
- <version>1.0-SNAPSHOT</version>
+ <version>@clojure-version@</version>
<url>http://clojure.org/</url>
<description>Clojure core environment and runtime library.</description>
@@ -19,4 +19,4 @@
</license>
</licenses>
-</project> \ No newline at end of file
+</project>
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 2f126fb8..5e6c20f1 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -10,7 +10,6 @@
(def unquote)
(def unquote-splicing)
-(def *clojure-version* {:major 1 :minor 0 :incremental 0 :qualifier "RC1"})
(def
#^{:arglists '([& items])
@@ -3939,11 +3938,6 @@
(defmacro add-doc {:private true} [name docstring]
`(alter-meta! (var ~name) assoc :doc ~docstring))
-(add-doc *clojure-version*
- "The version info for Clojure core, as a map containing :major :minor :incremental and :qualifier keys.
- Feature releases may increment :minor and/or :major, bugfix releases will increment :incremental.
- Possible values of :qualifier include \"GA\", \"SNAPSHOT\", \"RC-x\" \"BETA-x\"")
-
(add-doc *file*
"The path of the file being evaluated, as a String.
@@ -4023,7 +4017,6 @@
(load "core_print")
(load "genclass")
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; futures (needs proxy);;;;;;;;;;;;;;;;;;
(defn future-call
"Takes a function of no args and yields a future object that will
@@ -4091,3 +4084,38 @@
`(letfn* ~(vec (interleave (map first fnspecs)
(map #(cons `fn %) fnspecs)))
~@body))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; clojure version number ;;;;;;;;;;;;;;;;;;;;;;
+
+(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 (prop "major")
+ :minor (prop "minor")
+ :incremental (prop "incremental")
+ :qualifier (prop "qualifier")}]
+ (def *clojure-version*
+ (if (not (= (prop "interim") "false"))
+ (clojure.lang.RT/assoc clojure-version :interim true)
+ clojure-version)))
+
+(add-doc *clojure-version*
+ "The version info for Clojure core, as a map containing :major :minor
+ :incremental and :qualifier keys. Feature releases may increment
+ :minor and/or :major, bugfix releases will increment :incremental.
+ Possible values of :qualifier include \"GA\", \"SNAPSHOT\", \"RC-x\" \"BETA-x\"")
+
+(defn
+ clojure-version
+ "Returns clojure version as a printable string."
+ []
+ (str (:major *clojure-version*)
+ "."
+ (:minor *clojure-version*)
+ (when-let [i (:incremental *clojure-version*)]
+ (str "." i))
+ (when-let [q (:qualifier *clojure-version*)]
+ (str "-" q))
+ (when (:interim *clojure-version*)
+ "-SNAPSHOT")))
diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj
index f549ece3..176fa13f 100644
--- a/src/clj/clojure/main.clj
+++ b/src/clj/clojure/main.clj
@@ -243,7 +243,7 @@
present"
[[_ & args] inits]
(when-not (some #(= eval-opt (init-dispatch (first %))) inits)
- (println "Clojure"))
+ (println "Clojure" (clojure-version)))
(repl :init #(initialize args inits))
(prn)
(System/exit 0))
@@ -320,7 +320,7 @@
The init options may be repeated and mixed freely, but must appear before
any main option. The appearance of any eval option before running a repl
- suppresses the usual repl greeting message: \"Clojure\".
+ suppresses the usual repl greeting message: \"Clojure ~(clojure-version)\".
Paths may be absolute or relative in the filesystem or relative to
classpath. Classpath-relative paths have prefix of @ or @/"
diff --git a/src/clj/clojure/version.properties b/src/clj/clojure/version.properties
new file mode 100644
index 00000000..e3a26c55
--- /dev/null
+++ b/src/clj/clojure/version.properties
@@ -0,0 +1,5 @@
+clojure.version.major=1
+clojure.version.minor=0
+clojure.version.incremental=0
+clojure.version.qualifier=RC1
+clojure.version.interim=true