Fork me on GitHub
#leiningen
<
2016-07-21
>
timgilbert16:07:56

@roberto: late response, but I've had good luck using https://github.com/trptcolin/versioneer to introspect the project version

roberto16:07:48

this is awesome

timgilbert16:07:53

Yeah, trying to figure out all that profile-injection stuff and plugins really makes my head hurt. Versioneer makes it easy and it works from both lein run and a compiled uberjar

timgilbert16:07:12

I also had some luck using humble old lein pprint before I stumbled on versioneer (in the context of deployment scripts) - you can lein pprint :version to get your version number (as a quoted string)

timgilbert17:07:21

Actually I have a somewhat-related question I was hoping to get help with. When I override :release-tasks for my project, I can substitute in some variables from the project map, so like using the lein-shell plugin, I can have a release task like this:

:release-tasks [["shell" "echo" "Hello, world from ${:name} version ${:version}"]]

timgilbert17:07:28

Can anyone tell me what the mechanism is that does that string substitution, and especially if there is a way to hook into it with a command I'm specifying via :aliases? What I'd like is to have the -main function I'm calling from my alias be passed the project name and version as arguments

timgilbert17:07:42

Is this the kind of thing I need to write a plugin for?

danielcompton22:07:30

@timgilbert: this comes from a lein-shell feature, rather than coming from Leiningen unfortunately

danielcompton22:07:50

I’d love to have something in Leiningen where I can reference parts of project.clj in other parts

danielcompton22:07:07

Would be tricky to break the cycle though

danielcompton22:07:38

I did see something about putting functions in project.clj that take a project map and return a value, but I couldn’t make them work, or find any docs on them