SASS implementation for Java? [closed]
With ANT:
- Download JRuby complete jar file (JRuby Complete jar download page)
- Download the latest HAML/SASS code (HAML/SASS tarball), and extract it. Put it in "/libs/sass-[VERSION]"
- Add the following to an ant build file.
- Replace [VERSION] in the script to the corresponding versions of JRuby and SASS
- Run the ant script, and the sass or scss files will be compiled!
<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>
ZUSS is a good alternative to LESS and SASS. It is similar to LESS. Unlike LESS and SASS, the processing of the ZUSS files doesn't require the JavaScript interpreter.
Disclaimer: I am the developer of ZUSS. I developed it simply because I can't find a neat solution for Java.