greglook / cljstyle

A tool for formatting Clojure code
Eclipse Public License 1.0
293 stars 39 forks source link

cljstyle-0.16.626.jar manifest does not specify Main-Class #105

Closed jayvdb closed 6 months ago

jayvdb commented 6 months ago

With prior releases I could use jgo like this

jgo --repository clojars.org=https://repo.clojars.org/ mvxcvi:cljstyle fix filename

Now that fails with

cljstyle-0.16.626.jar manifest does not specify Main-Class

There doesnt appear to be any other 0.16 releases uploaded, so I have switched to the more explicit

jgo --repository clojars.org=https://repo.clojars.org/ mvxcvi:cljstyle:0.15.1 fix filename

This works for me for now, but it would be good if cljstyle could specify its Main-Class in the jar metadata for future releases.

greglook commented 6 months ago

Definitely a bug; there were a lot of build tooling changes between 0.15 and 0.16.

greglook commented 6 months ago

Try 0.16.629, it should have the main attribute now.

jayvdb commented 6 months ago

Now it finds the Main-Class in the manifest as cljstyle.main but cant load it.

['jgo', '--repository', 'clojars.org=https://repo.clojars.org', 'mvxcvi:cljstyle:0.16.629', 'fix', '/home/jayvdb/python/py2many/tests/build/demorgan.smt'] (code: 1): b'INFO 2024-01-08 19:06:20,823: First time start-up may be slow. Downloaded dependencies will be cached for shorter start-up times in subsequent executions.\nINFO 2024-01-08 19:06:33,757: Inferring main class from jar manifest\nINFO 2024-01-08 19:06:33,758: Inferred main class: cljstyle.main\nError: Could not find or load main class cljstyle.main\nCaused by: java.lang.ClassNotFoundException: cljstyle.main\n'b''

greglook commented 6 months ago

Ah, probably because the namespaces aren't getting AOT compiled anymore. 🤔 I was hesitant to do this since it basically makes it into an uberjar, but I doubt people are going to pull cljstyle in as a library in most cases...

jayvdb commented 6 months ago

Perhaps also publish a cljstyle-cli , which is the uberjar ?

greglook commented 6 months ago

I'll consider turning AOT back on for the published jar. In the meantime, I pushed 0.16.630 which fixed a different issue, but also now enables this workaround leveraging clojure.main as the entry point:

% jgo \
    --repository clojars.org=https://repo.clojars.org/ \
    mvxcvi:cljstyle:0.16.630:clojure.main \
    -m cljstyle.main \
    check --report
# Checked 665 of 1095 files in 6.11 sec (108.9 fps)
# Checked 3947.2 KB of source files (646.5 KBps)
#   665 correct
#   362 unrelated
#    68 ignored

In practice you could use RELEASE instead of the specific version number. Is this good enough to solve the issue here?

jayvdb commented 6 months ago

That worked locally. Doing a PR https://github.com/py2many/py2many/pull/587 . thanks.