in the sample project,
https://github.com/technomancy/leiningen/blob/master/sample.project.clj
on line 217, there is a directive for including non-code files :
:resource-paths ["src/main/resource"] ; non-code files included in classpath/jar
I have a resources folder in my project and this line in my project.clj
:resource-paths ["resources"] ; non-code files included in classpath/jar
however, when I run lein jar to generate the .jar file, it does not package up the resources folder.
Is there something that I am missing?
Actually, it did get packaged. I just was not looking in the right spot:
from:
Resources in Clojure applications
'Leiningen borrows the convention for resources from maven, with slightly different folder layouts. The rule states that the resources folder must be used as a compile time classpath root, meaning that leiningen is right in putting all the files inside resources folder in the root location inside the jar.'
I thought that a resources directory would get created with the jar itself but lein jar copied all the files in the resources directory to the root of the jar.
Related
I have 2 project: my backend on Clojure and frontend on ClojureScript.
I decided to merge them. So i copied files from both projects, runed lein deps and try to start my backend. So i got this error
Couldn't locate web.clj on classpath
In my project source-paths:
["src/clj" "src/cljs"]
And main ^:skip-aot clj.web
My frontend is working properly.
My folder structure:
src
clj
web.clj
cljs
*some cljs files*
So how can i setup my source-paths setting to run my backend?
The namespace you want to start is not clj.web but web so your project.clj file should have:
main ^:skip-aot web
And your web.clj file should being with:
(ns web)
If you use subfolders in the future, the namespaces will be mapped with the following rules:
(ns com.my-company.clojure.examples.my-utils)
The ns form names the lib’s namespace and declares its dependencies. Based on its name, this lib is typically defined in a source file at the classpath-relative path: com/my_company/clojure/examples/my_utils.clj (note the translations from period to slash and hyphen to underscore).
Apparently the LD_LIBRARY_PATH includes /var/task/lib.
But how do I make sure my libs end up in /var/task/lib.
All my code ends up in /var/task/hello-world.
Your Lambda deployment package (zip file with your code) is extracted to /var/task with its directory structure intact. If you want something in /var/task/lib/, put it inside lib/ and not the root of the zip file.
All my code ends up in /var/task/hello-world
This implies that you have a folder named hello-world in the root of your zip file. Your code needs to go in the root of the zip, not in a folder, unless you specifically want it to be extracted to a folder under /var/task, as noted above.
https://aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-nodejs/
Similar to: Resources not copied to output path in IntelliJ 12.1.4, I am finding that any resource with an extension of "*.lib" is ignored by Intellij (community 2017.2) when copying resource files into the /out directory managed by Intellij for Gradle projects.
I try adding liberal includes to my /build.gradle:
sourceSets.test.resources {
srcDirs = ["src/test/resources"]
includes = ["**/*"]
}
but everything but the *.lib files are copied into the /out/test/resources/**/*.* location upon refreshing the gradle project. In troubleshooting, I confirmed that if I change the extension of a file from *.lib to something else (such as *.txt), Intellij correctly copies the file into /out/resources/**/*.txt. I can also manually copy the *.lib files into out/resources/**/*.lib and it won't remove them (a work around).
How can *.lib files be automatically copied from the test/resources/**/*.lib to /out/test/resources/**/*.lib in Intellij for running gradle unit tests?
I'm totally new to clojure and leiningen, all I want to do is write some java code that will use this library https://github.com/nathanmarz/dfs-datastores
Here is what I did :
Created a new leiningen project.
Added [com.backtype/dfs-datastores "1.3.6"] to my :dependencies ( I checked my .m2/repository/com/backtype/dfs-datastores/1.3.6 and there are some jar files there)
Created a new .java file in the main project directory with some code.
Now how can I use the dfs-datastores code inside my .java file ?
Is there a way to programmatically insert the name of my home directory into file paths in Leiningen's project.clj?
I run a Leiningen project on different machines, where I have different home directories. The project uses jar files that are not managed by Maven; I download 'em and put them in a directory that's relative to my home directory, or copy them into the Leiningen project. The second option works but is undesirable.
An easy way to use the first option--keeping the jar files somewhere else--is to add a soft link to the "somewhere else" directory in my Leiningen directory. That works, but the link has to be different on each machine, so I can't include the link file in the git repository, and I'd rather include everything in the git repo.
Isn't there a way to use environmental variables, or otherwise refer to my home directory, in my project.clj file? I've gone through the sample project file and have not found a solution, so far.
I thought I could just construct path strings at run time--what's in project.clj is just Clojure code, after all. Since hard-coding my home directory into project.clj works without any trouble:
:resource-paths [/Users/myhomedir/dist/mason/jar/mason.19.jar")]
I figured I could do this:
:resource-paths [(str (System/getenv "HOME") "/dist/mason/jar/mason.19.jar")]
However, Leiningen doesn't like this at all:
java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.PersistentList
Changing [...] to (vector ...) gives the same error but with 'clojure.lang.Symbol` at the end.
In the name of repeatability you'd better have the jar installed in the local maven repository and have it added to the project.clj :dependencies so it's fetched from there. But you said those jars won't be managed by maven, so here we go:
defproject is a macro and it allows to use unquoting to do arbitrary evaluation. It does it by calling the internal fn unquote-project. So you can do the following:
:resource-paths [~(str (System/getenv "HOME") "/dist/mason/jar/mason.19.jar")]