leiningen uberjar doesn't add manifest attribute - clojure

I am unsuccessfully trying to run instant-pdf
lein uberjar
cd target
java -jar instant-pdf-0.2.0-standalone.jar
no main manifest attribute, in instant-pdf-0.2.0-standalone.jar
Do I have to manually edit the jar now?
I am using OpenJDK 7.u13-x86_64.

instant-pdf's project.clj lacks a :main setting, and I bet that's why it's not setting a main class in the jar's manifest. However, the project doesn't specify a main method anywhere in the sources either, so you'd have to add one yourself. See the section on Running Code from the Leningen Tutorial for details on using :main.
#Yogothos pointed out that using the Ring plugin for Leiningen will fix this (quoting his comment below):
The project should be built using lein ring uberjar instead of lein uberjar. The Ring plugin is responsible for creating the main.

Related

Check Leiningen Template Version Number

Trying out a new leiningen template. After running the template command,
the dependencies + project.clj built as expected.
lein new template-name project-name
However, lein run to start the web server threw a No such namespace error, even though the project.clj had the :main namespace.name correctly defined, so far as I can tell.
The template was not a project dependency, so it was not immediately obvious to me if the template was broken or some sort of path issue on my end.
I think I fixed my bug deleting the project and rebuilding with the lein -U update flag, but am still curious how to check the template version number.
How can I check the version number of the template that lein new is running?
I looked in lein help new and found how to specify a version but not how to check the one being used.
Leiningen templates are installed in your .m2 directory. So you could just cd ~/.m2/repository/template-name. There you should see directories named by the versions you have installed.

Can Leiningen recursively download the dependencies of its checkout dependencies?

Checkout dependencies can be used to add another work-in-progress project to your Leiningen project during development (for example: you're developing an app and underlying library in parallel).
However, when a checkout dependency itself has a "traditional" dependency (from Clojars), running lein run in the parent project will throw a java.io.FileNotFoundException since it apparently does not retrieve the "traditional" dependencies of its checkout dependencies.
Is there a way to let a Leiningen project recursively download the dependencies of its checkout dependencies?
My opinion of the "proper" way to do this is to have your project depend on the library in your checkouts directory as a traditional dependency in addition to having it in your checkouts directory.
Then every time you change dependencies, run lein install in your library project. This will cause lein to generate the appropriate jar file and install it into your local maven repo. It does not matter if this library project is finished, because you are not actually running it in this state, just using it to fetch dependencies.
Then when it does work you don't have to do anything to "switch to production" other than remove your checkouts directory. The dependency is already in place in the dependent project.
There is a side effect of using checkouts to work on libraries in that the code is loaded twice. Once from the "depended on" version, and then again from the "checkouts version". This is very occationally a problem for me when I'm using protocols and have to remember to re-load the protocol definition.

Where can I find leiningen's profiles.clj on Mac?

I am unable to locate the Leiningen profiles.clj file under .lein on my Mac. I am looking to use a previous version of Luminus by adding the following code to the profiles.clj:
:user {:plugins [[luminus/lein-template "1.16.7"]]}
So when i run:
lein new luminus myproject
I use the 1.16.7 template version of luminus.
Thanks
It should be located at ~/.lein/profiles.clj as you're suggesting.
However, if you've not had need for profiles.clj before, then you have to create it yourself, which is probably why you can't find it.
I set up a new machine recently, and I'm pretty sure that I created the file myself.

How to install a dependency in a Clojure project

This is a noob question, so I'm sorry if I offend somebody.
But how do I install seesaw on a *nix computer?
Yes, I've read the README.MD file, but how does the project.clj know where to find the library jars (for seesaw for example)?
Edit project.clj and add the dependency (the vector of project-identifying info and version) to the :dependencies vector in project.clj.
The dependency declaration looks like this: [seesaw "1.4.2"] Which you find by searching for seesaw on http://clojars.org.
Your project file should at minimum look something like:
(defproject my-awesome-gui-application "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.4.0"]
[seesaw "1.4.2"]])
If you are using a newer version of leiningen you can type lein deps :tree to see your dependency tree. In other words you can see what libraries are actually being used, ie. the ones you declared and their transitive dependencies.
$ lein deps :tree
[org.clojure/clojure "1.4.0"]
[seesaw "1.4.2"]
[com.jgoodies/forms "1.2.1"]
[com.miglayout/miglayout "3.7.4"]
[j18n "1.0.1"]
[org.fife.ui/rsyntaxtextarea "2.0.3"]
[org.swinglabs.swingx/swingx-core "1.6.3"]
[org.swinglabs.swingx/swingx-action "1.6.3"]
[org.swinglabs.swingx/swingx-autocomplete "1.6.3"]
[org.swinglabs.swingx/swingx-common "1.6.3"]
[org.swinglabs.swingx/swingx-painters "1.6.3"]
[org.swinglabs.swingx/swingx-plaf "1.6.3"]
If you are using an older version of leiningen, type lein deps and look in ./libs to see what jars got fetched (newer versions of lein are smarter and use the jars in ~/.m2 directly instead of copying them into your project. The directory ~/.m2 is the location of your local Maven repository. Leiningen deals with Maven and downloads all the dependencies you've specified so that you don't have to worry about Maven directly.)
I mentioned Maven and your local maven repository in ~/.m2. With any luck you may never have to think about Maven at all (except perhaps browsing through maven central to look up Java libs to stick in your project.clj), but there are times when you might suspect that a jar was corrupted or something to that effect, and it is good to know that you can just blow away that state by deleting your .m2 repository.
project.clj files specify the project configuration for leiningen.
Leiningen downloads and installs the dependencies specifies in the project.clj file and starts the project / runs the repl process / compiles the project to a java jar / whatever. See the link above. In short, leiningen is the most popular glue between your basic OS and the basic java-based clojure runtime/compiler.
Normally, you should not have to install any clojure libs (or even clojure). Except when you need additional libs to develop/debug the current project (and often you don't), you just install leiningen, and leiningen will install the dependencies for the project you want to run.
To be more specific: leiningen gets its download locations/install instructions by delegating to maven, which is a very interesting project. But possibly not worth looking into too closely if your time is precious.

How can I configure my project.clj so that Leiningen finds my sources under a non-standard directory structure?

It seems Leiningen's compile task looks for source packages to start immediately under the /src directory. I use both Java and Clojure in my project, so my /src directory looks like this:
/src/java/myapp
/src/clojure/myapp
Right now Leiningen is looking for /src/myapp and it's failing out during the compile.
Related, I'd like to know how to manually add directories to the classpath for Leiningen's compile and repl tasks. For example, Enlive's deftemplate function will search the classpath for a named template file. Adding /templates to the classpath would be required for my project to build and run properly.
This will be fixed in Leiningen 1.0 which is currently looking good for a release in the next week or so. Hopefully someone writes a javac plugin for Leiningen too; it should be easy to write as Lein bundles ant so you could just reuse ant's javac task.
Have you tried setting the :root value in your project file?
Looking at the source code for the compile command, it will process only Clojure files anyway and will look for these files under (file (:root project) "src") , so you could set :root to point to "src/clojure/" but would still need a symlink so that "src/clojure/src/" exists...