You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -184,7 +183,7 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
184
183
:main-args ["-e" "(clojure-version)"]})]
185
184
(b/process cmd)))
186
185
</code></pre><p>We can run this with:</p><pre><code>clojure -T:build run
187
-
</code></pre><p>and we'll see the version of Clojure we're running: <code>"1.11.1"</code>.</p><p><strong>Error Handling</strong></p><p>Since we will generally want the build to fail if the command exits with
186
+
</code></pre><p>and we'll see the version of Clojure we're running: <code>"1.11.3"</code>.</p><p><strong>Error Handling</strong></p><p>Since we will generally want the build to fail if the command exits with
188
187
a non-zero status, we'll check the return value of <code>b/process</code> and throw
189
188
an exception if the exit status is non-zero:</p><pre><codeclass="clojure"> (when-not (zero? (:exit (b/process cmd)))
190
189
(throw (ex-info (str "run failed for " aliases) opts)))
@@ -243,7 +242,7 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
243
242
that specify versions of Clojure to test against, and then use those in a
244
243
new <code>test-multi</code> function in <code>build.clj</code>.</p><p>Add these aliases to <code>deps.edn</code>:</p><pre><codeclass="clojure"> :1.9 {:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}}
</code></pre><p>When these aliases are used in combination with other aliases, the default
248
247
version of Clojure will be overridden with the specified version. We can see
249
248
this by running <code>clojure -T:build run :aliases '[:1.9]'</code> and seeing <code>"1.9.0"</code>
@@ -284,7 +283,7 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
284
283
Running tests in #{"test"}
285
284
286
285
Testing example-test
287
-
1.11.1
286
+
1.11.3
288
287
289
288
Ran 1 tests containing 1 assertions.
290
289
0 failures, 0 errors.
@@ -318,13 +317,14 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
318
317
build a SNAPSHOT or a release version of the library).</p><p>The global variables defining <code>lib</code>, <code>version</code>, etc could be moved to the
319
318
<code>jar-opts</code> function but some people will find it easier to read your <code>build.clj</code>
320
319
file if they are defined at the top of the file.</p><p>You might end up with something like:</p><pre><codeclass="clojure">(defn- jar-opts [opts]
321
-
(let [lib 'my/lib
320
+
(let [lib 'my/lib ; group/artifact
322
321
version "1.2.3"
323
322
target "target"
324
323
classes (str target "/classes")]
325
324
(assoc opts
326
325
:lib lib
327
326
:version version
327
+
;; group/artifact-version.jar is the expected naming convention:
328
328
:jar-file (format "target/%s-%s.jar" lib version)
329
329
:scm {:tag (str "v" version)}
330
330
:basis (b/create-basis {})
@@ -360,7 +360,7 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
360
360
<dependency>
361
361
<groupId>org.clojure</groupId>
362
362
<artifactId>clojure</artifactId>
363
-
<version>1.11.1</version>
363
+
<version>1.11.3</version>
364
364
</dependency>
365
365
</dependencies>
366
366
<repositories>
@@ -430,7 +430,7 @@ <h2 id="toolsbuild-and-the-clojure-cli"><code>tools.build</code> and the Clojure
</code></pre><p><strong>Clojars credentials</strong></p><p>Per the <code>deps-deploy</code> README, you'll need to set up environment variables
433
+
</code></pre><blockquote><p>Note: the expected naming convention for JAR files on Clojars is <code>group/artifact-version.jar</code> so you should ensure that your <code>:lib</code> and <code>:version</code> values are set up correctly in your <code>jar-opts</code> function (see above).</p></blockquote><p><strong>Clojars credentials</strong></p><p>Per the <code>deps-deploy</code> README, you'll need to set up environment variables
434
434
for your Clojars username and token: <code>CLOJARS_USERNAME</code> and <code>CLOJARS_PASSWORD</code>
435
435
(even tho' it is <strong>not</strong> your password, it's a deployment token you need to
436
436
setup in your Clojars account).</p><p>You can now deploy your JAR file to Clojars with:</p><pre><code>clojure -T:build deploy
<metaproperty="og:title" content="Date and Time" />
@@ -65,7 +65,7 @@ <h2>Date and Time</h2>
65
65
</div>
66
66
67
67
<p>This cookbook covers working with Java's <code>java.time</code> package in two styles, the
68
-
first with interop and the second using libraries.</p><p>This guide covers Clojure 1.11.1 and Java 8 or later.</p><p>This work is licensed under a <arel="license" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution
68
+
first with interop and the second using libraries.</p><p>This guide covers Clojure 1.11.3 and Java 8 or later.</p><p>This work is licensed under a <arel="license" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution
69
69
3.0 Unported License</a> (including images & stylesheets). The source is
70
70
available <ahref="https://github.com/clojure-doc/clojure-doc.github.io">on Github</a>.</p><h1id="introduction">Introduction</h1><p>This cookbook does not assume a background in Java, if you have such a
71
71
background the interop section might be of interest.</p><p>This cookbook will be useful if you got your Clojure environment setup, know
@@ -75,7 +75,7 @@ <h2>Date and Time</h2>
75
75
literal</a> is used
76
76
to represent a <code>java.util.Date</code> object.</li></ul><p>While in JavaScript:
77
77
TBD</p><h2id="libraries">Libraries</h2><ul><li><ahref="https://github.com/dm3/clojure.java-time">clojure.java-time</a><blockquote><p>A Clojure wrapper for Java 8 Date-Time API.</p></blockquote></li><li><ahref="https://github.com/henryw374/cljc.java-time">cljc.java-time</a><blockquote><p>A Clojure(Script) library which mirrors the java.time api through kebab-case-named vars.</p></blockquote></li><li><ahref="https://github.com/juxt/tick">tick</a><blockquote><p>A Clojure(Script) & babashka library for dealing with time. Intended as a replacement for clj-time.</p></blockquote></li></ul><h1id="preliminaries">Preliminaries</h1><p>The examples below assume the following <code>deps.edn</code></p><pre><codeclass="clojure">{:paths ["src"]
</code></pre><h1id="recipes">Recipes</h1><h2id="clojurejava-time"><code>clojure.java-time</code></h2><h3id="basics">Basics</h3><p>For the people coming from a non-Java background, we are creating an <em>instance</em>
Copy file name to clipboardExpand all lines: articles/ecosystem/libraries_authoring/index.html
+2-1
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,8 @@ <h2>Ecosystem: Library Development and Distribution</h2>
79
79
as the name of the new project we create and publish here, but you
80
80
can use whatever name you want -- just remember to substitute that
81
81
wherever you see <code>my-cool-lib</code> in this guide.</p><p>This guide uses Clojure 1.11 and a recent version of the Clojure CLI
82
-
(at least 1.11.1.1139), and requires you have <code>git</code>
82
+
(at least 1.11.1.1139; current version is 1.11.3.1463 as of May 2024),
83
+
and requires you have <code>git</code>
83
84
installed (though very little familiarity with <code>git</code> is required).</p><blockquote><p>Note: you should always ensure you have an up-to-date version of the Clojure CLI installed! See <ahref="https://clojure.org/releases/tools">Tools Releases</a>. Several of the examples here require 1.11.1.1139 or later: <code>clojure -version</code> should tell you the version you have installed.</p></blockquote><p>It's assumed that you're already somewhat familiar with Clojure. If
84
85
not, see the <ahref="/articles/tutorials/getting_started/">Getting Started</a> and
85
86
<ahref="/articles/tutorials/introduction/">Introduction</a> guides.</p><p>This work is licensed under a <arel="license" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons
Copy file name to clipboardExpand all lines: articles/tutorials/basic_web_development/index.html
+2-2
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ <h2>Basic Web Development</h2>
80
80
<ahref="/articles/tutorials/introduction/">Introduction</a> guides.</p><p>This work is licensed under a <arel="license" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons
81
81
Attribution 3.0 Unported License</a> (including images &
82
82
stylesheets). The source is available <ahref="https://github.com/clojure-doc/clojure-doc.github.io">on
83
-
Github</a>.</p><p>This guide uses Clojure 1.11.1, as well as current versions of the
83
+
Github</a>.</p><p>This guide uses Clojure 1.11.3, as well as current versions of the
84
84
component libraries noted below.</p><h2id="conceptual-overview-of-components">Conceptual Overview of Components</h2><p>We'll use four major components (briefly described below) for our
85
85
little webapp:</p><ul><li>Ring</li><li>Compojure</li><li>Hiccup</li><li>H2</li></ul><h3id="ring">Ring</h3><p><ahref="https://github.com/ring-clojure/ring">Ring</a> (<ahref="https://clojars.org/ring">at
86
86
clojars</a>) is a foundational Clojure web
@@ -236,7 +236,7 @@ <h2>Basic Web Development</h2>
236
236
the value for that column.</p><p>You can try the code out in the <code>comment</code> form by evaluating each expression
237
237
in it, and you should see the same results as the inline comments show.</p><p>You can also try those calls yourself in a standalone REPL,
238
238
if you like:</p><pre><codeclass="clojure">clj
239
-
Clojure 1.11.1
239
+
Clojure 1.11.3
240
240
user=> (require 'my-webapp.db)
241
241
nil
242
242
;; you must require a namespace before you go into it:
Copy file name to clipboardExpand all lines: articles/tutorials/getting_started_cli/index.html
+3-3
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ <h2>Getting Started with the Clojure CLI</h2>
80
80
see the list of all the options available.</p><h2id="trying-out-the-repl">Trying out the REPL</h2><p>Once you have the Clojure CLI installed, you can run it from anywhere you like
81
81
to get a REPL:</p><pre><code>$ clj
82
82
</code></pre><p>You should be greeted with the Clojure version and a "<code>user=></code>" prompt. Try it out:</p><pre><codeclass="clojure">$ clj
83
-
Clojure 1.11.1
83
+
Clojure 1.11.3
84
84
user=> (+ 1 1)
85
85
;; ⇒ 2
86
86
user=> (distinct [:a :b :a :c :a :d])
@@ -109,10 +109,10 @@ <h2>Getting Started with the Clojure CLI</h2>
109
109
<code>clojure.main</code> can also evaluate expressions:</p><pre><code>$ clojure -M -e '(println "Hello, Command!")'
</code></pre><p>The <code>-e</code> option prints the value returned by the expression (if it is not <code>nil</code>).</p><h3id="working-in-the-repl">Working in the REPL</h3><p>In your project directory, start up a repl (<code>clj</code>) and
114
114
run your <code>-main</code> function to see its output in the repl:</p><pre><code>$ clj
0 commit comments