roomkey / lein-v

Drive leiningen project version from git instead of the other way around
48 stars 11 forks source link

Make sure the cache directory exists if necessary. #27

Closed brunchboy closed 4 years ago

brunchboy commented 5 years ago

My users were having trouble building Beat Link Trigger from source, it was mysteriously crashing complaining about version.edn not existing, and it took a while to figure out why. That file is in my .gitignore because it is a build product, and I had no other files in the resource/beat_link_trigger directory, so git simply did not create that directory when someone cloned the project. Then lein-v failed to write the file because the necessary parent directories did not exist when it ran.

This one-liner should solve this problem in the future by creating the parent directories of the configured cache directory when necessary.

cch1 commented 4 years ago

I'm inclined to consider the availability of the cache directory a repo setup problem. If you are not happy with the location, it can be overridden on the command line.

brunchboy commented 4 years ago

What harm is there in preventively ensuring things will work as you expect for people whose repositories are structured differently than yours, especially since Git makes this difficult without awkwardly creating useless files? I and my casual contributors will probably not be the last people to step on this particular rake.

cch1 commented 4 years ago

I'm disinclined to complect lein-v to create the directory you (implicitly) assign for the version file. By default, src/version.clj is created and by default leiningen creates the src directory in a new project.

If you change the format or the location from the default (presumably by setting a prep task naming a directory) then it's your responsibility to make sure that directory exists. The fact that git makes this less than trivial is a git problem.

brunchboy commented 4 years ago

Fair enough, I’d forgotten that I’d changed the default directory (it was nearly a year ago that this came up), and I can just use another prep task to create the directory for them for now. I’m moving away from liking the idea of having the version implicitly defined from git tags anyway, as I can’t practically do that in my pure Maven projects, so it complicates my release process.