Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uberjar building issue with +handler #95

Closed
kongeor opened this issue Nov 24, 2019 · 6 comments
Closed

Uberjar building issue with +handler #95

kongeor opened this issue Nov 24, 2019 · 6 comments

Comments

@kongeor
Copy link

kongeor commented Nov 24, 2019

Hello,

when creating a project using +handler:

lein new re-frame foo +handler

and then building a uberjar:

lein uberjar

a part of the output looks like:

Compiling foo.server
2019-11-24 12:39:16.597:INFO::main: Logging initialized @3424ms to org.eclipse.jetty.util.log.StdErrLog
Compiling foo.server
[:app] Compiling ...
[:app] Build completed. (94 files, 0 compiled, 0 warnings, 7.91s)
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, or the namespace has not been AOT-compiled.

as expected trying to run the jar (java -jar target/foo.jar) will fail with:

Error: Could not find or load main class foo.server

Also, not sure why Compiling foo.server appears twice.

After some digging and comparing the project.clj with other projects that work as expected, it looks like the prod alias is the one causing this issue:

            "prod"         ["with-profile" "prod" "do"
                            ["clean"]
                            ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]

removing the ["clean"] task resolves this.

Not sure if this is a Leiningen issue or if it is a more complicated combination of different factors.

@gadfly361
Copy link
Contributor

@kongeor Please give this a try:

lein clean
lein with-profile prod uberjar

@kongeor
Copy link
Author

kongeor commented Nov 26, 2019

@gadfly361 no change. Behavior is exactly the same as before.

@superstructor
Copy link
Contributor

Sorry for the delay. Hopefully I'll have time to look at this for the next release.

@superstructor
Copy link
Contributor

I've looked into this but havn't worked it out.

  • The foo.server ns exists.
  • The foo.server ns has (:gen-class).
  • The uberjar profile appears to be configured as per lein documentation
  • The uberjar profile appears to be applied.
  • DEBUG true lein with-profile uberjar pprint is pretty much what I would expect except it does seem odd that it prints Compiling foo.server twice for something that doesn't even end up in the JAR.

I don't use uberjars a lot so would appreciate any help from someone who uses this more often.

Also note the compiled JS does not appear to be included in the uberjar, and it probably should be with another fix. Maybe :extra-paths ["resources"]. In any case will need to fix this issue first.

@dpassen
Copy link

dpassen commented Jan 3, 2020

I looked into this as part of https://stackoverflow.com/questions/59580237/lein-uberjar-not-setting-main-class-properly

The uberjar profile calls ["compile" ["prod"]] in :prep-tasks. The "prod" alias calls "clean" and "target" is listed in :clean-targets.

@superstructor
Copy link
Contributor

Thanks for investigating this and finding the cause @dpassen !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants