获取文件未找到错误在Sa中运行Sass和Compass为jar

时间:2011-11-23 01:40:07

标签: ant jar jruby sass compass-sass

我使用以下教程在罗盘中添加指南针作为目标:http://caueguerra.com/tutorial-using-sass-in-a-java-project

以下是我罐子里的宝石:

java -jar jruby-compass-gems.jar -S gem list

*** LOCAL GEMS ***

chunky_png (1.2.5)
compass (0.11.5)
fssm (0.2.7)
rake (0.8.7)
sass (3.1.1)
sources (0.0.1)

这是我调用compass compile的目标:

<project name="run-compass" basedir=".">
    <property name="apps.root" value="${basedir}/src/main/webapp/apps" />
    <property name="sass.dir" value="${apps.root}/resources/sass" />

    <!-- Include jruby-compass jar -->
    <path id="jruby.classpath">  
         <fileset dir="${basedir}">  
            <include name="jruby*.jar"/>  
         </fileset>  
    </path>

<target name="compile.sass">  
     <java classname="org.jruby.Main" fork="true" failonerror="true" classpathref="jruby.classpath">  
         <arg line="${basedir}/compile.rb ${basedir} compile ${sass.dir}"/>  
     </java>  
</target>  
</project>

对compile.rb进行以下修改:

# Instead of loading lib dirs, just add the first arg
# Dir.entries(ARGV[0]).each do |lib|  
#    $LOAD_PATH.unshift "#{ARGV[0]}/#{lib}/lib"  
#end  
$LOAD_PATH.unshift "#{ARGV[0]}"

require 'rubygems'   
require 'compass'  
require 'compass/exec'  

# select_appropriate_command_line_ui is no longer a valid method, so don't use
#command_line_class = Compass::Exec::Helpers.select_appropriate_command_line_ui [ARGV[1], ARGV[2], "-q"]  
exit Compass::Exec::SubCommandUI.new([ARGV[1], ARGV[2], "-q"]).run!

运行ant:

后,我在生成的.css文件中看到此错误
Syntax error: File to import not found or unreadable: shared.
              Load paths:
                C:\Users\aliu\workspace\ui/src/main/webapp/apps/resources/sass
                file:C:/Users/aliu/workspace/ui/jruby-compass-gems.jar!/gems/compass-0.11.5/frameworks/blueprint/stylesheets
                file:C:/Users/aliu/workspace/ui/jruby-compass-gems.jar!/gems/compass-0.11.5/frameworks/compass/stylesheets
                C:/Users/aliu/workspace/ui/src/main/webapp/apps/resources/sass/../../../lib/ext-4.0.7/resources/themes/stylesheets
                Compass::SpriteImporter
        on line 1 of file:C:/Users/aliu/workspace/ui/jruby-compass-gems.jar!/gems/compass-0.11.5/frameworks/compass/stylesheets/compass/css3/_border-radius.scss
        from line 1 of file:C:/Users/aliu/workspace/ui/jruby-compass-gems.jar!/gems/compass-0.11.5/frameworks/compass/stylesheets/compass/_css3.scss 

_border-radius.scss中的违规行是:

@import "shared";

请注意,加载路径包含指南针样式表。我发现罗盘能够找到_border-radius.scss而不是_shared.scss真的很奇怪,因为它们位于同一目录。我检查了jar内容以确保_shared.scss存在。有没有人经历过类似的事情,或者可以对这个问题有所了解?任何建议都表示赞赏。

更新:我测试了直接在${basedir}中运行compile.rb:

 compile.rb . compile src\main\webapp\apps\resources\sass

它正确地工作并创建了.css文件,这意味着问题在于从ant运行。这是否意味着我需要以某种方式纠正蚂蚁运行路径?

1 个答案:

答案 0 :(得分:0)

这是最好的解决方法,但我意识到虽然找不到@import "shared",但@import "compass/css3/shared"没问题,所以我修改了所有这些本地@import以引用更多的绝对路径。