Skip to content

Instantly share code, notes, and snippets.

@eduardolundgren
Created October 29, 2012 18:23
Show Gist options
  • Save eduardolundgren/3975460 to your computer and use it in GitHub Desktop.
Save eduardolundgren/3975460 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<project name="AlloySass" default="local" xmlns:antelope="antlib:ise.antelope.tasks">
<basename property="ant.file.basename" file="${ant.file}" />
<target name="build-ruby-gems">
<if>
<not>
<available file="${project.dir}/lib/ruby-gems.jar" />
</not>
<then>
<tstamp>
<format property="tstamp.value" pattern="yyyyMMddkkmmssSSS" />
</tstamp>
<get
dest="${project.dir}/lib/jruby.jar"
src="http://jruby.org.s3.amazonaws.com/downloads/1.6.7.2/jruby-complete-1.6.7.2.jar"
/>
<mkdir dir="${tstamp.value}/compass" />
<get
dest="${tstamp.value}/compass/compass-0.12.2.gem"
src="http://rubygems.org/downloads/compass-0.12.2.gem"
/>
<java
fork="true"
jar="${project.dir}/lib/jruby.jar"
>
<arg line="-S gem install -i ./${tstamp.value}/output ${tstamp.value}/compass/compass-0.12.2.gem --no-rdoc --no-ri" />
</java>
<jar
basedir="${tstamp.value}/output"
jarfile="${project.dir}/lib/ruby-gems.jar"
/>
<delete dir="${tstamp.value}" />
</then>
</if>
</target>
<target name="sass-parse">
<sass-parse />
</target>
<macrodef name="sass-parse">
<attribute name="folder.sass" default="${component.assets.base}" />
<attribute name="folder.sass.backup" default="${component.basedir}/.sass-tmp" />
<sequential>
<if>
<and>
<equals arg1="${ant.file.basename}" arg2="build.xml" />
<available file="@{folder.sass}" type="dir" />
</and>
<then>
<echo message="Parsing SASS" />
<if>
<not>
<equals arg1="@{folder.sass.backup}" arg2="" />
</not>
<then>
<copy todir="@{folder.sass.backup}" overwrite="true">
<fileset dir="@{folder.sass}" />
</copy>
</then>
</if>
<property name="file.path.pattern" value="@{folder.sass}/**/**.css" />
<path id="jruby">
<fileset file="${project.dir}/lib/jruby.jar"/>
<fileset file="${project.dir}/lib/ruby-gems.jar"/>
</path>
<script language="ruby" classpathref="jruby">
<![CDATA[
require 'rubygems'
require 'java'
require 'compass'
require 'compass/exec'
filePathPattern = $project.getProperty('file.path.pattern')
files = Dir.glob(filePathPattern)
Compass.add_project_configuration
load_paths = []
load_paths += Compass.configuration.sass_load_paths
files.each do | file |
fileContent = File.read(file)
engine = Sass::Engine.new(
fileContent,
{
:filename => file,
:syntax => :scss,
:load_paths => load_paths,
:ugly => true,
:style => :expanded
}
)
File.open(file, 'w') { |f| f.write(engine.render) }
end
]]>
</script>
</then>
</if>
</sequential>
</macrodef>
<target name="sass-postclean">
<sass-postclean />
</target>
<macrodef name="sass-postclean">
<attribute name="folder.sass" default="${component.assets.base}" />
<attribute name="folder.sass.backup" default="${component.basedir}/.sass-tmp" />
<sequential>
<if>
<and>
<available file="@{folder.sass}" type="dir" />
<equals arg1="${ant.file.basename}" arg2="build.xml" />
</and>
<then>
<delete dir="@{folder.sass}" />
<copy todir="@{folder.sass}" overwrite="true">
<fileset dir="@{folder.sass.backup}" />
</copy>
<delete dir="@{folder.sass.backup}" />
</then>
</if>
</sequential>
</macrodef>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment