2009/4/22 Rich Hickey <richhic...@gmail.com>:
> [...]
> {:major 1, :minor 0, :incremental 0, :qualifier :rc1 :interim true}
>
> for interim versions and
>
> {:major 1, :minor 0, :incremental 0}
>
> for releases. :interim tracks the SNAPSHOT segment of the version
> string.
> [...]
> I don't mind the build producing clojure-1.0.0.jar etc, but it doesn't
> now. The master build is Ant. Where is the best place to put the
> version info so it can be leveraged by Ant, Maven and the clojure core
> runtime in order to produce *clojure-version* ?

Here a patch that allows to initialize from ant and from a file
version.properties the values in *clojure-version*.

The patch only addresses the problematic of having a single place for
version attributes.
Having the ant build also use these properties for creating correctly
numbered jars is not part of the patch.

Note that I had to create a new file, src/clj/clojure/core_version.clj
, which is created by ant as a combination of template file
core_version-template.clj and the properties from version.properties.

You'll see that if you don't like the names of the keys in
version.properties, build.xml is the single place where to change them
(apart from version.properties, of course).
Also, if you don't like the name version.properties (e.g. if it should
be named project.properties or whatever for easing maven users), then
you just have to change its occurence in build.xml too.

If you like it, it can file an issue to google code and attach the patch,

Regards,

-- 
Laurent

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Index: version.properties
===================================================================
--- version.properties	(révision 0)
+++ version.properties	(révision 0)
@@ -0,0 +1,5 @@
+clojure.version.major=1
+clojure.version.minor=0
+clojure.version.incremental=0
+clojure.version.qualifier="RC1"
+clojure.version.interim=false
Index: src/clj/clojure/core.clj
===================================================================
--- src/clj/clojure/core.clj	(révision 1354)
+++ src/clj/clojure/core.clj	(copie de travail)
@@ -10,7 +10,6 @@
 
 (def unquote)
 (def unquote-splicing)
-(def *clojure-version* {:major 1 :minor 0 :incremental 0 :qualifier "RC1"})
 
 (def
  #^{:arglists '([& items])
@@ -3954,11 +3953,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.
 
@@ -4037,8 +4031,8 @@
 (load "core_proxy")
 (load "core_print")
 (load "genclass")
+(load "core_version")
 
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; futures (needs proxy);;;;;;;;;;;;;;;;;;
 (defn future-call 
   "Takes a function of no args and yields a future object that will
@@ -4106,3 +4100,4 @@
   `(letfn* ~(vec (interleave (map first fnspecs) 
                              (map #(cons `fn %) fnspecs)))
            ~...@body))
+
Index: core_version-template.clj
===================================================================
--- core_version-template.clj	(révision 0)
+++ core_version-template.clj	(révision 0)
@@ -0,0 +1,18 @@
+;   Copyright (c) Laurent Petit. 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.
+
+(in-ns 'clojure.core)
+
+(let [clojure-version {:major       'CLOJURE_VERSION_MAJOR
+                       :minor       'CLOJURE_VERSION_MINOR
+                       :incremental 'CLOJURE_VERSION_INCREMENTAL
+                       :qualifier   'CLOJURE_VERSION_QUALIFIER}]
+  (def *clojure-version* 
+    (if* 'CLOJURE_VERSION_INTERIM
+      (. clojure.lang.RT (assoc clojure-version :interim true))
+      clojure-version)))
Index: build.xml
===================================================================
--- build.xml	(révision 1354)
+++ build.xml	(copie de travail)
@@ -16,13 +16,17 @@
   <property name="slim_jar" location="clojure-slim.jar"/>
   <property name="src_jar" location="clojure-sources.jar"/>
   <property name="clojure.assert-if-lazy-seq" value=""/>
+  <property name="clojure.version.template" 
+            location="core_version-template.clj"/>
+  <property name="clojure.version" 
+            location="${cljsrc}/clojure/core_version.clj"/>
 
   <!-- These make sense for building on tapestry.formos.com -->
 
   <property name="snapshot.repo.dir" location="/var/www/maven-snapshot-repository"/>
   <property name="stable.repo.dir" location="/var/www/maven-repository"/>
 
-  <target name="init" depends="clean">
+  <target name="init" depends="clean,set-version">
     <tstamp/>
     <mkdir dir="${build}"/>
   </target>
@@ -80,11 +84,37 @@
 
   <target name="jar" depends="clojure"/>
 
+  <target name="set-version">
+    <!-- ensure we will overwrite a fresh template with correct placeholders-->
+    <copy file="${clojure.version.template}" 
+          tofile="${clojure.version}"/>
+
+    <replace file="${clojure.version}" 
+             propertyFile="version.properties">
+      <replacefilter
+        token="'CLOJURE_VERSION_MAJOR"
+        property="clojure.version.major"/>
+      <replacefilter
+        token="'CLOJURE_VERSION_MINOR"
+        property="clojure.version.minor"/>
+      <replacefilter
+        token="'CLOJURE_VERSION_INCREMENTAL"
+        property="clojure.version.incremental"/>
+      <replacefilter
+        token="'CLOJURE_VERSION_QUALIFIER"
+        property="clojure.version.qualifier"/>
+      <replacefilter
+        token="'CLOJURE_VERSION_INTERIM"
+        property="clojure.version.interim"/>
+    </replace>
+  </target>
+
   <target name="all" depends="clojure,clojure-slim,clojure-sources"/>
 
   <target name="clean"
           description="Remove autogenerated files and directories.">
     <delete dir="${build}"/>
+    <delete file="${cljsrc}/clojure/core_version.clj"/>
   </target>
 
   <target name="-setup-maven">

Reply via email to