Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make lein uberjar without source files

I'm using 'lein uberjar' to make a executable jar file of my project. the jar is created correctly and runs as expected.

I just want to know if it is possible to NOT include my source .clj files in the generated .jar, since I'm planning to distribute it, and I don't want my source files available to the public.

I'm using lein 1.7.1

if not possible with lein, would it work if I just manually removed the .clj files from the jar? I did a test and it worked, by I want to be sure that this is safe to do.

thanks in advance.

like image 581
weeanon Avatar asked May 25 '12 18:05

weeanon


2 Answers

Use :omit-source true in lein's project.clj.

like image 57
praimon Avatar answered Nov 26 '22 00:11

praimon


Have you tried using the aot compilation step that is provided? See here for an example.

Also, someone blogged something not too long ago about aot compiling their entire project: http://blog.japila.pl/2012/02/aot-compile-all-namespaces-in-a-clojure-project-aot-all-in-project-clj-leiningen/

In that case, too, you might still have to dig in and remove the .clj files, I'm not sure. Maybe this is somewhere to start, though.

Edit 1

I should note that even if you were to use compilation to just distribute the .class files, there are really good tools to decompile those classes in a way that users can read (I've used this in the past when the documentation was so poor I had to look elsewhere to see how it worked).

In those cases, you'd be better off finding a way to implement your own code obfuscator, although I know little/nothing about that topic, here's a start.

like image 35
Nick Klauer Avatar answered Nov 25 '22 22:11

Nick Klauer