Java doesn’t allow – in names. That’s why Clojure and Clojure tooling maps – in 
names to _ in files (and classes).

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

From: Mars0i
Sent: Friday, March 3, 2017 9:17 PM
To: Clojure
Subject: lein jar, uberjar don't allow hyphens in paths?

It looks like 'lein uberjar' and 'lein jar' don't like namespace path elements 
that contain hyphens.

Example:

lein new app foo-bar
cd foo-bar

Now edit src/foo_bar/core.clj, changing

(ns foo-bar.core
  (:gen-class))

to

(ns foo-bar.core
  (:gen-class
    :name foo-bar.core))

Then 'lein uberjar' reports:

Compiling foo-bar.core
Warning: The Main-Class specified does not exist within the jar. It may not be 
executable as expected. A gen-class directive may be missing in the namespace 
which contains the main method.

Also, 'java -jar target/uberjar/foo-bar-0.1.0-SNAPSHOT-standalone.jar' prints:

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

A similar problem seems to occur with 'lein jar'.

However, no problem occurs with 'lein run', or with 'lein uberjar' if :name is 
left out of the ns form, or if :name is used but the project namespace 
qualifier does not contain a hyphen.

I think this has to do with the fact that when I use :name with foo-bar, 
core.class ends up in target/uberjar/classes/foo-bar, while its related inner 
class files end up in target/uberjar/classes/foo_bar.  If I don't use :name or 
if the path doesn't contain a dash, all of the classes end up in the same 
directory, e.g. foo_bar.  (I don't know much about jar files or subtleties of 
how the jvm interprets them.)

I have a standalone project that runs fine with 'lein run' but I'm unable to 
make an uberjar because of this problem.  (I apparently to need the :name 
element in order to create an instance of the same class in my -main function.) 
 The project is small enough that it won't be much trouble to rename filenames 
and namespace paths in order to get rid of dashes, but I'm wondering if there's 
a different solution.  

I'm also wondering whether this is a bug/flaw in Leiningen.  I can submit an 
issue if so.
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to