I wanted to refresh my knowledge of functional programming, A-Star search, and I figured learning Clojure at the same time couldn’t hurt. I figured I’d do all three at once, and throw in a health dose of Maven and Java at the same time.
This project was intended to:
Once downloaded, unzip the zip file and open a terminal.
You now have three options:
Review the Source Code
The meat of the code is all in Clojure, here:
src/main/resources/com/example/clap/astar.clj
There is a bit of boot-strap Java code in the following file, but I can’t say its all that interesting:
src/main/java/com/example/clap/App.java
Running from Source
If you are on a Mac, or you already have Maven and Java installed, just run the following:
cd astar && mvn test
Maven will download all the needed packages and then compiled and execute the demo.
Running from Binary
If you are on Linux, or have cygwin installed on Windows, you can run the following:
cd astar/bin/ && ./run-astar
At work, we need to start using JOGL as a dependency of our project, which we build with Maven. JOGL, the Java OpenGL interface, uses platform specific binaries, which introduces some complexity to the build process.
After a brief websearch, I found the appropriately titled using-jogl-as-dependency-in-maven, unfortunately, it appears to be a private blog, so I can’t see if the information is useful or not.
I did find on mvnbrowser.com that jogl-1.1.1-rc6 (as of this writing) is on the dev.java.net Maven2 repository, but I couldn’t find a usage guide.
Oh well, I’ll keep looking. For now its not a hugely pressing issue, so the one developer who is using has just hacked his Eclipse setup.
I came across this post and this Maven plugin today. Call me cynical, but I was shocked when it worked out of the box, building our application as a Mac friendly .app which can be run with a double click.
To test it out, all I did was change into our application’s trunk directory and ran:
mvn package osxappbundle:bundle -DmainClass=com.mypkg.MyMain
And it worked!
So I extended integrated it into our pom.xml with the following. Now whenever our app is packaged on a Mac, in addition to the other artifacts, an .app, .dmg, and .zip of the My App tool will be created.
<profiles>
....
<profile>
<id>package-osx-bundle</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>osxappbundle-maven-plugin</artifactId>
<configuration>
<mainClass>com.mypkg.MyMain</mainClass>
<bundleName>My App</bundleName>
<jvmVersion>1.5+</jvmVersion>
</configuration>
<executions>
<execution>
<phase>package</phase>
<!-- append to the packaging phase. -->
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I uninstalled M2Eclipse and installed q4e and gave it a shot. All the core functionality seems to be there (dependancy management is the big one for me) and importing from a project pom seems to work (although It didn’t seem to import a multilayer project, I had to import each module separately, but thats ok for me).
Its nice to add dependancies manually, although I’d like to see a dependancy search page like m2eclipse has and a place to cut and paste dependancy XML chunks (I use mvnrepository.com a lot). The dependancy graph is a nice feature although the controls on the side seem a bit buggy.
A pom view somewhat like the built in Ant view would be nice, where I can double click a phase or a plugin:goal and run it, although I understand it might make sense to be able to manually which goals / phases appear in the workspace.
So far so good, I hope the m2eclipse and q4eclipse projects can work together in the future.