how to pass port number to clojureRepl task at cli?

31 views
Skip to first unread message

Phil Groce

unread,
Feb 14, 2014, 10:54:53 PM2/14/14
to cloju...@googlegroups.com
I'm fairly new to Gradle, so this may be frightfully easy, but so far it's been beyond me. I want to start a Clojure repl listening on an arbitrary port but I don't want to modify the build script; rather, I want to pass the port number in when I execute the clojureRepl task. AFAICT, I can pass in environment variables or properties which the clojureRepl could conceivably do something with, but as yet I haven't stumbled on the incantation to override the task's port property directly.

Thanks for any help you can provide.

Meikel Brandmeyer

unread,
Feb 15, 2014, 3:54:36 AM2/15/14
to cloju...@googlegroups.com
Hi,
Command line arguments are currently only inofficially supported in
gradle. They are only test wise for some gradle internal tasks available
and not document anywhere. It might take another release or two until
they are available.

However you may use a property on the command line to set the port until
then.

clojureRepl {
if (project.hasProperty("clojureReplPort")) {
port = project.clojureReplPort
}
}

And invoke gradle via 'gradle -PclojureReplPort="4711"'. Or you put
it in the gradle.properties file.

Maybe I could expose these knobs in general via properties.

Hope that helps.

Meikel

signature.asc

Phil Groce

unread,
Feb 16, 2014, 1:37:46 PM2/16/14
to cloju...@googlegroups.com
On Saturday, February 15, 2014 3:54:36 AM UTC-5, Meikel Brandmeyer wrote:
Maybe I could expose these knobs in general via properties.

That would be helpful, I think. I could see wanting to change the port number to accommodate multiple nRepls running simultaneously (in multiple projects, say, or on a multi-user machine). In that case, you wouldn't want to encode the port number statically. The solution you posted definitely helps with that, but there are many situations where it would be much nicer to do it with zero changes to the build script.

I really don't care much whether it's done via properties, environment variables, command-line parameters, etc., but properties are probably the best option available now.
 
Hope that helps.

You've been very helpful and responsive. I definitely appreciate it, thanks.
 
Meikel

phil 
Reply all
Reply to author
Forward
0 new messages