Wednesday 1 February 2012

Success With Leiningen, Kinda

Getting Leiningen working was a bit of a trial:
  1. Download lein.bat!
  2. Note that it can self-install, but only if wget or curl are to hand. I'm currently trying to get it working under windows, my primary gaming and dev environment, so I go with the manual download option. Progress seems good.
  3. Putting the .jar file in the place where lein is installed (and on the path) doesn't work. Harrumph a bit.
  4. Mess with batch file a bit, including directing Leiningen at Clojure.
  5. Give up, download a windows implementation of curl, add to path.
  6. >lein self-install now works! Hooray! And oooh, the .jar file goes in \self-install. Durr.
  7. Leiningen crashes on attempting to do anything, with a huge Java call stack. Pout.
  8. Notice that in my arrogance and delusion, I have pointed Leiningen at Clojure 1.3.0, the newly installed latest version, but the original wanted to use 1.2.1. Download the older version, alter batch file again.
  9. Yay, I can make a project!
  10. I'll want to use lwjgl at the very least with this at some point. Some research points me at swannodette's lovely native-deps addition to the tool, and the existence of lwjgl-clj at clojars.org. Cool.
  11. OK, I have a zip file for native-deps. How do I thrust this in lein's general direction?
  12. Welp, via adding it to :dev-dependencies in my project.clj file, it seems. I guess I'll keep the .zip file in case of emergencies. Or something.
  13. Argh, version 1.0.0 just blows up lein again.
  14. Phew, 1.0.5 works. I can now grab lwjgl-clj through the magic of... magic, I guess. And curl possibly.
  15. Look at it go, downloading all those lwjgl-clj files!
  16. I've got a little text-based thing that'd make a nicely self-contained test project for leiningen. Let's try turning it into a self-executable .jar
  17. >lein jar: and there was much grinding and gnashing of gears.
  18. Class "hexed" was not found.
  19. Oh, :gen-class! Silly me.
  20. Class "hexed" was not found.
  21. Err... oh, -main.
  22. Class "hexed" was not found.
  23. wat.


And there were some more steps, mostly consisting of my own stupidity fighting with my own stubbornness, before finally:
>lein uberjar
>java -jar hexrl-1.0.0-SNAPSHOT-standalone.jar
SUCCESS!




Woohoo!

Now, I list my failures mostly because I am quite stupid, and I hope other people feel better about themselves as a result. But also because there's a fair amount of assumed knowledge concerning most JVM languages and their associated tools. Before I started working with Scala, I had only the most vague inklings regarding the black magic of .class and .jar files. Ant, maven and all related stuff is... well, initially I was curious and tried to learn more. Now I'm just hoping most of it dies and gets replaced by something. Anything. As long as it doesn't involve XML.

I still find it vaguely offensive that I'm expected to this.like.project.my.structure, preferably including URLs (hah), but in moderation it works well enough. Knowing that you need to generate an appropriate class exposing the correct form of a main method is reasonable. It would be nice if some of these things failed more gracefully in case of version mismatch

Long story short, now I have achieved a critical point: using a cuddly-ish tool to build a working application, however trivial. Chances are therefore good that I will learn to use Leiningen correctly (somewhat) and frequently.

Edit: I promised pretty screenshots, and have not yet delivered. The next step is apply the power of the ant-agonistic build tool to the OpenGL-using framework, check everything works with the version of lwjgl available at clojars.org, and then see what happens. Hopefully there will be relatively few explosions and couple of simple meshes to screenshot.

No comments: