smallseo.info

leiningen

Automate Clojure projects without setting your hair on fire.

leiningen: missing super-pom

if I enable eith the clojure-couchdb or swank-clojure then lein deps fails because org.apache.maven:super-pom:jar:2.0 is missing

:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
               [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
               [clojure-http-client "1.0.0-SNAPSHOT"]
               [org.apache.activemq/activemq-core "5.3.0"]
;              [org.clojars.the-kenny/clojure-couchdb "0.1.3"]
;              [org.clojure/swank-clojure "1.1.0"]
              ])

this error:

  Path to dependency: 
1) org.apache.maven:super-pom:jar:2.0
2) org.clojure:swank-clojure:jar:1.1.0

----------
1 required artifact is missing.

for artifact: 
 org.apache.maven:super-pom:jar:2.0

from the specified remote repositories:  
  clojars (http://clojars.org/repo/),
  clojure-snapshots (http://build.clojure.org/snapshots),
  central (http://repo1.maven.org/maven2)

what is super-pom. why do these packages need it and where can I get it.


Source: (StackOverflow)

Deploying Clojure apps with Leiningen

This is my project.clj file so far:

(defproject raj "0.0.1-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]]
  :keep-non-project-classes true
  :main raj.core)

And my core.clj file:

(ns raj.core
  (:use raj.core))

(defn -main [& args]
  (println "Hello World!!!"))

lein run -m raj.core displays the Hello World message just fine. So next I try lein uberjar and get

Compiling raj.core
Compilation succeeded.
Created C:\Users\bobjones\IdeaProjects\raj/raj-0.0.1-SNAPSHOT.jar
Including raj-0.0.1-SNAPSHOT.jar
Including clojure-1.3.0.jar
Created C:\Users\bobjones\IdeaProjects\raj/raj-0.0.1-SNAPSHOT-standalone.jar

Everything seems to be going well so far, so I try java -jar raj-0.0.1-SNAPSHOT-standalone.jar, and I receive

Error: Could not find or load main class raj.core

What would I be doing wrong here?


Source: (StackOverflow)

What's the difference between Cake and Leiningen?

What's the difference between Cake and Leiningen?


Source: (StackOverflow)

leiningen - how to add dependencies for local jars?

I want to use leiningen to build and develop my clojure project. Is there a way to modify project.clj to tell it to pick some jars from local directories?

I have some proprietary jars that cannot be uploaded to public repos.

Also, can leiningen be used to maintain a "lib" directory for clojure projects? If a bunch of my clojure projects share the same jars, I don't want to maintain a separate copy for each of them.

Thanks


Source: (StackOverflow)

How to reload a clojure file in REPL

What is the preferred way of reloading functions defined in a Clojure file without having to restart the REPL. Right now, in order to use the updated file I have to:

  • edit src/foo/bar.clj
  • close the REPL
  • open the REPL
  • (load-file "src/foo/bar.clj")
  • (use 'foo.bar)

In addition, (use 'foo.bar :reload-all) does not result in required effect, which is evaluating the modified bodies of functions and returning new values, instead of behaving as the source haven't changed at all.


Source: (StackOverflow)

Why is `lein run` not `lein trampoline`?

It seems to me that the only difference between lein run and lein trampoline is that the latter quits Leiningen's JVM to save memory.

This seems always a good idea, so why is this feature not included in lein run and then get rid of lein trampoline?


Source: (StackOverflow)

How to run .clj file as a script using leningen?

This is the second question after Is there a standalone Clojure package within Leiningen?

For example, I have a file hello_world.clj, and I can run it using

java -cp clojure.jar clojure.main hello_world.clj.

Since lein already contains Clojure (because I can run lein repl directly), is there a way to do the same thing like

lein script hello_world.clj by lein?


Source: (StackOverflow)

How do I find which of my dependencies is downloading a particular jar?

One of my project.clj's :dependencies is dependent on the monolithic clojure-contrib-1.1.0.jar, but I can't guess which one is downloading it. Short of incrementally commenting out each one, how can I discover which of them is responsible ?


Source: (StackOverflow)

How to Reload files upon save when using swank+leiningen+emacs

I'm looking to set up slime+lein-swank to reload source files referenced from the repl when i save the file. currently i do this:

  • edit file
  • save file
  • switch to repl
  • (use :reload-all 'com.package.namespace)
  • test stuff

I want to not have to remember to do step 4.


Source: (StackOverflow)

clojure and leiningen - using a git repository as dependency

Is it possible to have leiningen pull a project directly from a git repository (on github) as a dependency?

Using Bundler with Ruby, it is possible to map a gem to a git repo, allowing for rapid development and integration of dependent projects.

Update

Based on the accepted answer, there is now a leiningen plugin for managing git-deps: https://github.com/tobyhede/lein-git-deps


Source: (StackOverflow)

nrepl.el and leiningen 2 default namespace?

Getting an Emacs / Clojure environment up and running, I'm now running into behavior that I'm not sure is normal. In particular, when I start an nREPL and compile (C-c C-k) my buffer, I get dropped into something other than the namespace defined at the top of my core.clj file. I should add the disclaimer that I'm a bit new to Clojure and namespaces, and so my understanding of all this might be murky. I'm open to opinionated answers that show me a Better Way™.

First, about my setup:

My emacs environment is Cocoa Emacs 24, set up mostly with the emacs starter kit from the Melpa repository, with the clojure and nrepl packages added via the package manager.

My leiningen 2 project was set up using lein new test-clj.

My project.clj:

(defproject test-clj "0.1.0-SNAPSHOT"
  :description "A geospatial test app example mostly ripped off from http://datamangling.com/blog/2010/05/26/geotools-quickstart-in-clojure/"
  :repositories {"osgeo-geotools" "http://download.osgeo.org/webdav/geotools"}
  :url "FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.geotools/gt-main "8.2"]
                 [org.geotools/gt-shapefile "8.2"]
                 [org.geotools/gt-epsg-hsql "8.2"]
                 [org.geotools/gt-swing "8.2"]])

My core.clj:

(ns test-clj.core
  (:import [org.geotools.data CachingFeatureSource FeatureSource FileDataStore FileDataStoreFinder])
  (:import [org.geotools.map DefaultMapContext MapContext])
  (:import [org.geotools.swing JMapFrame])
  (:import [org.geotools.swing.data JFileDataStoreChooser]))


(defn show-shapefile
  "Prompts the user for a shapefile and displays its content"
  []
  (if-let [shapefile (JFileDataStoreChooser/showOpenFile "shp" nil)]
    (let [fs (.getFeatureSource (FileDataStoreFinder/getDataStore shapefile))]
      (doto (DefaultMapContext.)
        (.setTitle "Quickstart")
        (.addLayer fs nil)
        (JMapFrame/showMap)))))

I think I should be able to

  1. load up my core.clj file and jack-in (M-x nrepl-jack-in)
  2. C-c C-k to load the buffer into the REPL
  3. type (show-shapefile) and be impressed at my cleverness

In actuality, I get an error that looks like clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: show-shapefile in this context, compiling:(NO_SOURCE_PATH:1)

If, from the REPL I first type (in-ns `test-clj.core), I'm golden. Also, if I type (test-clj.core/show-shapefile) I'm set.

When I load a REPL in Counterclockwise, I automagically get dropped into the test-clj.core namespace, which seems mighty convenient.

My question then is two-fold:

  1. Is this the correct behavior that I'm seeing? (i.e. I'm just being lazy?)
  2. Is there a way to be dropped into this namespace (or conversely, tell me that this is a stupid idea)?

Source: (StackOverflow)

Installing Leiningen for use with Clojure

I'm trying to install Leiningen on my local machine to get Clojure running, but I can't seem to get the latest version.

I'm following the instructions on github here: https://github.com/technomancy/leiningen

I'm able to put the script in my path, and get Lein to download, but for some reason when I run lein version I keep getting

Leiningen 1.7.1 on Java 1.6.0_33 Java HotSpot(TM) 64-Bit Server VM

I've tried deleting and re-installing Leiningen several times, but nothing changes. Are there certain files I need to be deleting, or is there some way to switch versions? lein upgrade doesn't seem to do anything.

Thanks in advance.


Source: (StackOverflow)

Serving static files with ring/compojure - from a war

Using ring (and the lein-ring tools) - I am able to serve up static files from "resources" etc as per the docs when running in development - however - when I package things up via lien uberwar I have no idea how to make it serve those files when running in a container. I see conflicting docs on wrap-resource, or setting :resource-path but none seem to work.


Source: (StackOverflow)

How to install a leiningen plugin?

How do I install a leiningen plugin?

For example, leiningen-run?

I see this thing called "clojars.org", and how to "push" to it, but I don't see anything about "pulling" from it.


Source: (StackOverflow)

How to use library in maven repo for clojure project?

I use Leiningen to manage my CLJ project. When I want to wrap a Java library, I found that I have to introduce it to my project firstly.

How can I use a library in a Maven repo in my project?


Source: (StackOverflow)