Skip to content

Instantly share code, notes, and snippets.

@rkaneko
Last active August 29, 2015 14:08
Show Gist options
  • Save rkaneko/aaa50765fd636e18ec1c to your computer and use it in GitHub Desktop.
Save rkaneko/aaa50765fd636e18ec1c to your computer and use it in GitHub Desktop.
Create a jar file containing jruby and compass.

Create a jar containing jruby and compass

Credit

I created ShellScript in reference to above web site.

Prerequisites

  • JDK 1.7_x or later
  • jq
  • curl

Usage

# download ShellScript for creating a jar file containing jruby and compass
$ curl https://api.github.com/gists/aaa50765fd636e18ec1c | jq -r '.files["create-jcompass.sh"].content' >create-jcompass.sh

$ chmod +x ./create-jcompass.sh

$ ./create-jcompass.sh
$ ls
create-jcompass.sh jcompass.jar       lib

$ java -jar jcompass.jar -S compass create --help
# initialize
$ java -jar jcompass.jar -S compass create --sass-dir src/scss --css-dir public/stylesheets --image-dir public/imgs --environment development --output-style expanded

$ java -jar jcompass.jar -S compass compile --help
# ex)
$ java -jar jcompass.jar -S compass compile --sass-dir src/scss --css-dir public/stylesheets

$ java -jar jcompass.jar -S compass watch --help

TODO

#!/bin/bash
#
# @fileOverview Create fat jar file containing jruby and compass.
# @createdAt 2014/11/06
SCRIPT_DIR=`dirname $0`
LIB_DIR=${SCRIPT_DIR}/lib
COMPASS_GEMS_DIR=${SCRIPT_DIR}/compass-gems
TARGET=jcompass.jar
JAVA=`which java`
JAR=`which jar`
CURL=`which curl`
JRUBY_VERSION=1.7.16.1
JRUBY_JAR=jruby-complete-${JRUBY_VERSION}.jar
cat<< EOT
SCRIPT_DIR: ${SCRIPT_DIR}
LIB_DIR: ${LIB_DIR}
COMPASS_GEMS_DIR: ${COMPASS_GEMS_DIR}
TARGET: ${TARGET}
java: ${JAVA}
jar: ${JAR}
curl: ${CURL}
jruby version: ${JRUBY_VERSION}
jruby jar: ${JRUBY_JAR}
EOT
# ---
# make lib directory
if [ ! -d ${LIB_DIR} ]; then
mkdir -p ${LIB_DIR}
echo created lib directory
fi
# ---
# download a jruby jar
echo downloading ${JRUBY_JAR}
${CURL} -L http://central.maven.org/maven2/org/jruby/jruby-complete/${JRUBY_VERSION}/${JRUBY_JAR} -o ${LIB_DIR}/${JRUBY_JAR}
chmod +x ${LIB_DIR}/${JRUBY_JAR}
# ---
GEMS=( shared sass compass )
for GEM in ${GEMS[@]}
do
echo installing gem: ${GEM}
${JAVA} -jar ${LIB_DIR}/${JRUBY_JAR} -S gem install -i ${COMPASS_GEMS_DIR} ${GEM} --no-rdoc --no-ri
done
# ---
# copy jruby jar
cp ${LIB_DIR}/${JRUBY_JAR} ${SCRIPT_DIR}/${TARGET}
# compile all into one jar
${JAR} uf ${SCRIPT_DIR}/${TARGET} -C ${COMPASS_GEMS_DIR} ${SCRIPT_DIR}
chmod +x ${SCRIPT_DIR}/${TARGET}
# ---
# clean
if [ -d ${SCRIPT_DIR}/o-rdoc ]; then
rm -rf ${SCRIPT_DIR}/o-rdoc
fi
echo done!
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment