文章

Compass as a standalone jar with jruby

By using jruby, you can package the compass as a standalone jar file and run compass directly. Making it portable and easier to bring in compass feature in your project (esp. java) or have it on your windows machine. Here are the steps:

curl -O http://repo1.maven.org/maven2/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar
java -jar jruby-complete-1.7.4.jar -S gem install -i ./compass compass --no-rdoc --no-ri
jar cf compass.jar -C compass .
rm -rf compass

Now you have both compass.jar and jruby-complete-1.7.4.jar, you can have a compass.cmd (windows) like

@echo off
java -cp jruby-complete-1.7.4.jar;compass.jar org.jruby.Main -S compass %*

Now you can do something like compass compile --sass-dir=scss --css-dir=css

I’ve put the script on github

*