Skip to content

Instantly share code, notes, and snippets.

@ebouchut
Created December 22, 2011 14:18
Show Gist options
  • Select an option

  • Save ebouchut/1510447 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
Author

@ebouchut
Copy link
Copy Markdown
Author

The rake command is missing from the JRuby 1.6.5 jar!
jruby/jruby-maven-plugins#23
Fixed in jRuby version 1.6.6: http://jira.codehaus.org/browse/JRUBY-6233

@ebouchut
Copy link
Copy Markdown
Author

java -jar ~/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar -S gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 1.8.9
  • RUBY VERSION: 1.8.7 (2011-10-25 patchlevel 330) [java]
  • INSTALLATION DIRECTORY: file:/users/grunt/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/gems/1.8
  • RUBY EXECUTABLE: java -jar /users/grunt/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar
  • EXECUTABLE DIRECTORY: file:/users/grunt/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar!/META-INF/jruby.home/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • universal-java-1.6
  • GEM PATHS:
    • file:/users/grunt/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar!/META-INF/jruby.home/lib/ruby/gems/1.8
    • /users/grunt/.gem/jruby/1.8
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :benchmark => false
    • :backtrace => false
    • :bulk_threshold => 1000
    • "install" => "--no-rdoc --no-ri --env-shebang"
    • "update" => "--no-rdoc --no-ri --env-shebang"
  • REMOTE SOURCES:

@ebouchut
Copy link
Copy Markdown
Author

How to configure the GEM path: http://forums.site5.com/showthread.php?t=11954

@ebouchut
Copy link
Copy Markdown
Author

The workaround is to use the second to last version (1.5.6) instead of the latest (1.6.5).
Version 1.5.6 contains rake.
Version 1.6.5 ... does not!

@ebouchut
Copy link
Copy Markdown
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
Copy Markdown
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