leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
ingesol 2019-10-03T10:18:17.047200Z

Hi! I’m making a JAR from my client project, and before the actual zipping happens I want to move some files around, such that the dir layout in the JAR will be subtly different from that in the project structure. I tried using https://github.com/m0smith/lein-resource, but can’t seem to figure out how to make it operate on files in target folder before JAR task. Also, I think it only does copy, not move. Any ideas?

ingesol 2019-10-07T21:33:18.058600Z

@mikerod Ended up using most of your initial suggestion, works fine now. Thanks!

2019-10-07T23:01:38.059200Z

Cool. I’m glad it was helpful then.

vemv 2019-10-03T10:20:35.047400Z

in project.clj:

:profiles {:uberjar {:prep-tasks [...]}}
there you can invoke arbitrary custom tasks

2019-10-03T13:33:07.047600Z

you may find lein-shell helpful if you just want to do a few shell things to move stuff around pre-jar’ing. You can change the :source-paths or whatever to be a new tmp dir you make specifically for this changed layout too and that might help

2019-10-03T13:33:36.047800Z

:source-paths ^:replace ["jar-layout"]

2019-10-03T13:33:43.048Z

you’d do that in a profile as well

ingesol 2019-10-03T13:36:47.048200Z

that might work

2019-10-03T13:38:20.048400Z

(defproject org.example/my-tester "1.0.0"
  :plugins [[lein-shell "0.5.0"]]

  :aliases {"jar-build" ["do"
                         ["shell" "cp" "-r" "src" "jar-build/src"]
                         ["shell" "cp" "-r" "resources" "jar-build/src"]
                         ;; Do other changes you want to these new directory
                         ;; Add in any profiles you want active for `jar`.
                         ["with-profile" "jar-build" "jar"]]}
  
  :profiles {:jar-build {:source-paths ^:replace ["jar-build/src"]
                         :resource-paths ^:replace ["jar-build/resources"]}})
rough idea

2019-10-03T13:38:25.048600Z

but there are open questions

ingesol 2019-10-03T13:38:37.048800Z

@mikerod Currently I’m trying to use :jar-exclusions and :jar-inclusions because there are only a few changes I need in the file structure. So I try to copy them to the target folder and then exclude the original folder. But my settings don’t work

2019-10-03T13:38:39.049Z

if you want this to build into the uberjar or install tasks, have to think about it a bit more

2019-10-03T13:38:55.049200Z

if you can just include/exclude things, that’d be ideal

vemv 2019-10-03T13:39:03.049400Z

Forgot to say: sounds reasonable, thanks! 🍻

ingesol 2019-10-03T13:39:32.049600Z

Agree. But original resources are included anyway, no matter what changes I make. I’m suspecting I’m doing something very trivial wrong…

ingesol 2019-10-03T13:42:07.049800Z

{:jar-exclusions [#"^src/scss/.*$"]
                     :jar-inclusions [#"^target/.*\.scss$"]
                     :resource       {:resource-paths
                                      [["src/scss"
                                        {:includes    [#".*\.sass"]
                                         :target-path "target/sass"}]]}}

2019-10-03T13:43:37.050100Z

I haven’t used the lein-resource, so don’t know about that part

2019-10-03T13:43:48.050300Z

you’re saying your :jar-exclusions aren’t being used though?

ingesol 2019-10-03T13:43:52.050500Z

That part works, it copies files to the specified target

ingesol 2019-10-03T13:43:57.050700Z

yes

ingesol 2019-10-03T13:46:06.050900Z

also tested this without the resource copying part, just ran jar task with files already in target folder

ingesol 2019-10-03T13:46:48.051100Z

But sounds like you’re saying this is supposed to work, the way I’m expecting it here?

2019-10-03T13:48:39.051300Z

unless your regex are incorrect

ingesol 2019-10-03T13:48:46.051500Z

yes 🙂

2019-10-03T13:48:58.051700Z

inclusions and exclusions should work on the jar task specifically

ingesol 2019-10-03T13:49:01.051900Z

I tested them elsewhere, semi-sure they work. But I guess they are the prime suspect

2019-10-03T13:49:14.052100Z

perhaps try making them more open to see if you get success

ingesol 2019-10-03T13:49:29.052300Z

will do

ingesol 2019-10-03T13:49:33.052500Z

thanks so far!

2019-10-03T13:50:05.052700Z

like :jar-exclusions [#"scss/.*"]

2019-10-03T13:50:18.052900Z

like narrowing down if you have a regex problem or not

2019-10-03T13:50:37.053100Z

I haven’t tried excluding things from src or target specifically like that before, so I’m curious

2019-10-03T13:50:47.053300Z

no problem, but no fast answers here from me hah

ingesol 2019-10-03T13:50:56.053500Z

yes, that’s pretty much what I’ve been doing so far. I’ll discuss it with some of my colleagues, maybe they’ll see it more clearly than I can

ingesol 2019-10-03T13:51:01.053700Z

🙂

1🎉