Wednesday, June 12, 2013

Java Sass Compass (SCSS) - [SOLVED!]

After hours of research, trial, frustration, and disappointment, I am very happy to say I have the matter solved.

I need to publish this solution to Java Compass Sass (SCSS). From my source links at the bottom it appears people have done this exact thing before, but I haven't seen it blogged about, hence this post. (I don't like re-posting existing knowledge, I don't need to be the source if it's easily available elsewhere.) There appears to already be a jazz.jar on github which is this exact thing, but I couldn't get it to work. I'll post this on my github account later as well.

UPDATED: I have posted here on Github: JCompass


In the end it was simple and elegant without the mess.

  1. Download the latest copy of JRuby  (At the time of this posting it's version 1.7.4)
    (http://www.jruby.org/download Find the "Complete Jar", second link from the bottom in the top group of links for the latest version)

    (The rest is command line)

  2. # Make a copy of jruby-complete-1.7.4.jar for the new singleton combined jar file
    cp jruby-complete-1.7.4.jar jruby-complete.jar

  3. # Now install these 3 gems locally:

    # Without this I got errors.
    java -jar jruby-complete.jar -S gem install -i ./compass-gems shared --no-rdoc --no-ri

    # I flagged "--pre" to get the latest pre-release version, skip that if you want.
    java -jar jruby-complete.jar -S gem install -i ./compass-gems sass --pre --no-rdoc --no-ri

    # Again, I flagged "--pre" here. Also, I had heard this includes the sass gem as a dependency, but I installed it separately to be safe.
    java -jar jruby-complete.jar -S gem install -i ./compass-gems compass --pre --no-rdoc --no-ri

  4. # Now rename the jruby complete jar to the name for the new jar app, or we lose the original and have to go download it again
    mv jruby-complete.jar jcompass.jar

  5. # Now compile together
    jar uf jcompass.jar -C compass-gems .    # including the space and period at the end

  6. # test it out:
    java -jar jcompass.jar -S compass compile --help
    java -jar jcompass.jar -S compass compile --sass-dir [relative or abs path to your .scss files] --css-dir [relative or asb path to destination .css files] --force


That's it.  

You can download my version of jcompass.jar here.



Sources that helped me compile this, and many thanks to them:

http://blog.nicksieger.com/articles/2009/01/10/jruby-1-1-6-gems-in-a-jar/
http://stackoverflow.com/questions/16188626/how-to-use-compass-through-jruby-for-embedding-in-my-soft
http://stackoverflow.com/questions/15549617/cleanest-way-to-run-susy-compass-and-sass-within-jruby-complete