Fork me on GitHub

If I fork a project and publish a jar under a different clojars groupid, can I somehow alias it back to the original groupid/name? Otherwise, my understanding is even if I use :override-deps the original project will be pulled in from any transitive deps, correct? Does that mean I need to track down all potential transitive deps that use this groupid/project-name and add an :exclusion?


Normally, I'd just use the original groupid and point to a :git/url, but this particular project has some compiled java bits.


@pithyless :classpath-overrides + nil might work too


although that might still pull in the transitive deps


but if your fork pulls in the same transitive deps you will probably get the newest of those transitive deps


OK, great; thanks @borkdude


Confirming that :classpath-overrides + nil works like a charm; cheers!


There's a jira for this fwiw


hi, can I run a java class as a Clojure alias? I'm trying to generate bindings for an antlr grammar using the java tool: The gradle code I want to replicate is:

apply plugin: 'java'
repositories {
dependencies {
    runtime 'org.antlr:antlr4:4.5.2'
task generateParser(type:JavaExec) {
   main = 'org.antlr.v4.Tool'
   classpath = sourceSets.main.runtimeClasspath
   args = ['-Dlanguage=JavaScript', 'todo.g4', '-o', 'static/generated-parser']


how can I specify the main class: org.antlr.v4.Tool ?

Alex Miller (Clojure team)20:12:52

you can specify clj -M -m org.antlr.v4.Tool if you just want to invoke that main class with the deps classpath

Alex Miller (Clojure team)20:12:33

you can pack this into an alias too using :main-opts and :replace-deps or :extra-deps to specify the deps

Alex Miller (Clojure team)20:12:19

and not sure if that -D is a jvm property or a class arg. If the former, use :jvm-opts for that one

Alex Miller (Clojure team)20:12:29

(note that you can't remove Clojure itself from the classpath - it assumes you are running Clojure programs)


thanks @alexmiller. How I can specify org.antlr.v4.Tool in deps.edn ? Now I have:

:antlr-js-target {:main-fn ["org.antlr.v4.Tool"]
                   :main-opts ["grammars/timeclock.g4" "-o" "static/generated/js-parser"]
                   :jvm-opts ["-Dlanguage=JavaScript"]}

Alex Miller (Clojure team)20:12:05

:antlr-js-target {:main-opts ["-m" "org.antlr.v4.Tool" "grammars/timeclock.g4" "-o" "static/generated/js-parser"]
                   :jvm-opts ["-Dlanguage=JavaScript"]}


thank you 🙂


unfortunatelly it does not work 😞

hledger-grammars$ clj -M:antlr-js-target
Execution error (FileNotFoundException) at clojure.main/main (
Could not locate org/antlr/v4/Tool__init.class, org/antlr/v4/Tool.clj or org/antlr/v4/Tool.cljc on classpath.

Full report at:
I have checked the dependencies and they should be on the classpath
 "Execution error (FileNotFoundException) at clojure.main/main (\nCould not locate org/antlr/v4/Tool__init.class, org/antlr/v4/Tool.clj or org/antlr/v4/Tool.cljc on classpath.\n",
  :clojure.error/line 40,
  "Could not locate org/antlr/v4/Tool__init.class, org/antlr/v4/Tool.clj or org/antlr/v4/Tool.cljc on classpath.",
  :clojure.error/symbol clojure.main/main,
  :clojure.error/source "",
  :clojure.error/phase :execution},
    "Could not locate org/antlr/v4/Tool__init.class, org/antlr/v4/Tool.clj or org/antlr/v4/Tool.cljc on classpath.",
    :at [clojure.lang.RT load "" 462]}],
  [[clojure.lang.RT load "" 462]
   [clojure.lang.RT load "" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "" 137]
   [clojure.lang.Var applyTo "" 705]
   [clojure.main main "" 40]],
  "Could not locate org/antlr/v4/Tool__init.class, org/antlr/v4/Tool.clj or org/antlr/v4/Tool.cljc on classpath."}}

Alex Miller (Clojure team)21:12:33

can you double-check with clj -Spath -M:antlr-js-target ?

Alex Miller (Clojure team)21:12:31

oh, it's looking to load a clojure class here

Alex Miller (Clojure team)21:12:38

maybe you can't actually do this :)


clj -Spath -M:antlr-js-target

Alex Miller (Clojure team)21:12:18

could just invoke with a Clojure expression, like?

:antlr-js-target {:main-opts ["-e" "(org.antlr.v4.Tool/main,\"grammars/timeclock.g4\",\"-o\",\"static/generated/js-parser\")"]
                   :jvm-opts ["-Dlanguage=JavaScript"]}

Alex Miller (Clojure team)21:12:24

as you can tell, you're kind of out of the main usage of this tool (running clojure programs)


yes, seems like it is. I am tryng to use this tool to do some project building. Seems to be related to what it is used for in clojure


almost there, now it needs to pass a single array instead of 3 args


Syntax error (IllegalArgumentException) compiling . at (REPL:1:1).
No matching method main found taking 3 args for class org.antlr.v4.Tool


I'll try to use object-array


failed with ["-e" "(org.antlr.v4.Tool/main,(object-array,[,\"grammars/timeclock.g4\",\"-o\",\"static/generated/js-parser\",],),)"]

class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lang.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap') 

Alex Miller (Clojure team)21:12:48

oh right. it's probably actually a String[]

Alex Miller (Clojure team)21:12:22

["-e" "(org.antlr.v4.Tool/main,(into-array,[\"grammars/timeclock.g4\",\"-o\",\"static/generated/js-parser\",],),)"]

Alex Miller (Clojure team)21:12:34

^^ will derive the array type from the first arg


yes, this works but it does not take into account the jvm option: :jvm-opts ["-Dlanguage=JavaScript"] . It generates java classes instead of js. I could set the property in the expression


I managed to get it working by checking the java code. It seems they accept -Dlanguage as an argument also so this worked: :antlr-js-target {:main-opts ["-e" "(org.antlr.v4.Tool/main,(into-array,[\"-Dlanguage=JavaScript\",\"grammars/timeclock.g4\",\"-o\",\"static/generated/js-parser\"]))"]}


thank you @alexmiller for your help. Could calling Java from deps.edn be made easier? Would JavaExec or an Exec be a feature?

Alex Miller (Clojure team)22:12:17

it could be made easier, but I don't really see it as the purpose of this tool so I'm not really interested in adding stuff for it

👍 3