Fork me on GitHub
#clojars
<
2022-06-16
>
victorb22:06:53

Did a little exploration/prototype to see how hard it would be to get lein to add arbitrary files (specifically FUNDING.yml) into the deployed JAR, read out those files in the upload process from the JAR in Clojars and persist the data to the db. Turns out, wasn't that complicated. Here is a preliminary screenshot. Unpolished code as I just wanted to see how hard it would be in reality.

tcrawley11:06:44

This is great! I like this idea. I think the proper place to put FUNDING.yml files is under META-INF. lein already puts the project.clj, etc there:

$ jar tvf ring-1.9.2.jar 
   217 Sat Mar 20 17:31:08 EDT 2021 META-INF/MANIFEST.MF
  2619 Sat Mar 20 17:31:08 EDT 2021 META-INF/maven/ring/ring/pom.xml
   998 Sat Mar 20 17:31:08 EDT 2021 META-INF/leiningen/ring/ring/project.clj
  2119 Sat Mar 20 17:31:08 EDT 2021 META-INF/leiningen/ring/ring/README.md
  1105 Sat Mar 20 17:31:08 EDT 2021 META-INF/leiningen/ring/ring/LICENSE
     0 Sat Mar 20 17:31:04 EDT 2021 META-INF/
     0 Sat Mar 20 17:31:04 EDT 2021 META-INF/maven/
     0 Sat Mar 20 17:31:04 EDT 2021 META-INF/maven/ring/
     0 Sat Mar 20 17:31:04 EDT 2021 META-INF/maven/ring/ring/
    93 Sat Mar 20 17:31:04 EDT 2021 META-INF/maven/ring/ring/pom.properties
I think it would be straightforward to expand lein here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/jar.clj#L194

tcrawley11:06:08

I haven't looked at other tooling.

victorb13:06:58

> I think the proper place to put FUNDING.yml files is under META-INF. lein already puts the project.clj, etc there: Yeah, probably. My thinking was firsthand that it would be great to capture everyone who is already using FUNDING.yml without them having to change anything. Current script actually just scans the entire JAR file for a FUNDING.yml, so doesn't really matter where it ends up. The way I hacked it into lein was with the filespecs key in project.clj, which allows you to put arbitrary files into the final artifact. Unfortunately, it doesn't seem to expose any control on where the file ends up in the JAR file, just puts it at the root level. But the following snippet does the trick:

:filespecs [{:type :path :path "FUNDING.yml"}
            {:type :path :path ".github/FUNDING.yml"}]
The better way is obviously the way you're describing, to have it work without changing project.clj at all, but we can suggest a patch to lein at a later point, after deploying the Clojars changes

victorb13:06:47

Unfortunate side-effect of requiring the FUNDING.yml to be in the JAR file is that people are gonna have to release a new version in order for it to show up at Clojars 😕

victorb13:06:49

but I think in the end the pros outweigh the cons with this approach. Gonna open a issue/try to submit a patch to cljdocs with the same approach once/if we get it live on Clojars

victorb22:06:22

Today I learned that JAR files are just ZIP files, so the code for reading one specific file from a archive is just ~12 lines, without having to extract the entire file