Skip to content

Instantly share code, notes, and snippets.

@ebouchut
Created December 22, 2011 14:18
Show Gist options
  • Save ebouchut/1510447 to your computer and use it in GitHub Desktop.
Save ebouchut/1510447 to your computer and use it in GitHub Desktop.
(Sass/maven) Unable to launch rake using jruby-rake-plugin
java -jar ~/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar -S gem env
@ebouchut
Copy link
Author

<!-- Excerpt of working pom.xml (at least) -->

<properties>
    <jruby.version>1.5.6</jruby.version>
    <gem.home>${user.home}/.gem/jruby/1.8</gem.home>
    <gem.options>--no-rdoc --no-ri --no-test</gem.options>
  </properties>

<plugins>
            <plugin>
                <groupId>org.jruby.plugins</groupId>
                <artifactId>jruby-rake-plugin</artifactId>
                <version>${jruby.version}</version>
                <executions>
                    <execution>
                        <id>install-sass</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>jruby</goal>
                        </goals>
                        <configuration>
                            <args>-S gem install -i ${gem.home} ${gem.options} sass</args>
                        </configuration>
                    </execution>

                    <execution>
                        <id>sass</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>jruby</goal>
                        </goals>
                        <configuration>
                            <args>-I${gem.home} -S sassify.rb ${basedir}/src/main/webapp/sass ${basedir}/src/main/webapp/css</args>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
</plugins>

@ebouchut
Copy link
Author

Here is the ruby file (sassify.rb) maven is calling to transform SASS into CSS:

require 'rubygems'
require 'sass'
require 'sass/exec'

abort "2 arguments required: source_dir destination_dir" if ARGV.size != 2

source_dir = ARGV[0]
dest_dir   = ARGV[1]

options = [ 
  "--update", 
  "--no-cache",
  "--style", "expanded",
  "#{source_dir}:#{dest_dir}"
]     

sass = Sass::Exec::Sass.new(options)
begin           
  puts "SASS: Converting SASS files (in #{source_dir}) into CSS files (in #{dest_dir})"
  sass.parse!   
rescue SystemExit => se
  puts "SASS: Done."
end  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment