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?
@mikerod Ended up using most of your initial suggestion, works fine now. Thanks!
Cool. I’m glad it was helpful then.
in project.clj:
:profiles {:uberjar {:prep-tasks [...]}}
there you can invoke arbitrary custom tasksyou 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
:source-paths ^:replace ["jar-layout"]
you’d do that in a profile as well
that might work
(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 ideabut there are open questions
@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
if you want this to build into the uberjar
or install
tasks, have to think about it a bit more
if you can just include/exclude things, that’d be ideal
Agree. But original resources are included anyway, no matter what changes I make. I’m suspecting I’m doing something very trivial wrong…
{:jar-exclusions [#"^src/scss/.*$"]
:jar-inclusions [#"^target/.*\.scss$"]
:resource {:resource-paths
[["src/scss"
{:includes [#".*\.sass"]
:target-path "target/sass"}]]}}
I haven’t used the lein-resource
, so don’t know about that part
you’re saying your :jar-exclusions
aren’t being used though?
That part works, it copies files to the specified target
yes
also tested this without the resource copying part, just ran jar task with files already in target folder
But sounds like you’re saying this is supposed to work, the way I’m expecting it here?
unless your regex are incorrect
yes 🙂
inclusions and exclusions should work on the jar
task specifically
I tested them elsewhere, semi-sure they work. But I guess they are the prime suspect
perhaps try making them more open to see if you get success
will do
thanks so far!
like :jar-exclusions [#"scss/.*"]
like narrowing down if you have a regex problem or not
I haven’t tried excluding things from src
or target
specifically like that before, so I’m curious
no problem, but no fast answers here from me hah
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
🙂