I'm looking for SASS implementation in Java (could be used with JSP/JSF). For Python I've found CleverCSS, but there is nothing for Java. Anyone heard something about this sort of tool for generating CSS?
With ANT:
<path id="JRuby">
<fileset file="libs/jruby-complete-[VERSION].jar"/> <!-- Location of JRuby jar file -->
</path>
<target name="compileSCSS">
<echo message="Compiling scss files..." />
<property name="filesIn" value="${dir.css}/scss/**/[^_]*.scss" />
<property name="fileOutDir" value="/${dir.css}/${dir.css.build}" />
<script language="ruby" classpathref="JRuby">
<![CDATA[
require 'libs/sass-[VERSION]/lib/sass'
require 'sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))
files.each do
| file |
puts " [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])
opts.parse
end
]]>
</script>
<echo message="Done compiling scss files!" />
</target>
With MAVEN:
Maven can also do this: Using the antrun plugin:
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>compileAndMinify</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}/compiled" />
<echo message="Compiling scss files..."/>
<path id="JRuby">
<fileset file="${basedir}/jars/jruby-complete-[VERSION].jar"/>
</path>
<property name="filesIn" value="${project.build.directory}/css/**/[^_]*.scss" />
<property name="fileOutDir" value="${project.build.directory}/compiled/css" />
<script language="ruby" classpathref="JRuby">
<![CDATA[
require 'libs/sass-[VERSION]/lib/sass'
require 'sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
Dir.mkdir($project.getProperty('fileOutDir')) unless File.exists?($project.getProperty('fileOutDir'))
files.each do
| file |
puts " [sass compiler] " + file + " -> " + $project.getProperty('fileOutDir') + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::Sass.new(["--load-path", File.dirname(file), file, File.join($project.getProperty('fileOutDir'), File.basename(file, ".*") + ".css")])
opts.parse
end
]]>
</script>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>