Reputation: 7886
I am working through the book Programming Clojure (Second Edition) by Stuart Halloway and Aaron Bedra. As instructed in the book, I edit and add code in the file project.clj (which was created by lein new pinger) so that it reads:
(defproject pinger "0.0.1-SNAPSHOT"
:description "A website availability tester"
:dependencies [[org.clojure/clojure "1.3.0"]])
(ns pinger.core
(:import (java.net URL HttpURLConnection)))
(defn response-code [address]
(let [conn ^HttpURLConnection (.openConnection (URL. address))
code (.getResponseCode conn)]
(when (< code 400)
(-> conn .getInputStream .close))
code))
I then try to load the file and get the following error:
user=> (load-file "src/pinger/project.clj")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: defproject
in this context, compiling:(C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\pinger\project.clj:1)
What am I doing wrong here?
Upvotes: 2
Views: 1722
Reputation: 17773
You're not supposed to add any code to the project.clj outside of the defproject definition.
The real project code is supposed to go into the classpath (for instance, in the files generated by "lein new ..." in src)
Upvotes: 8