Question

So I'm using Yuicompressor to minify my javascripts/css on my ant script. This process takes a long time for my project. I'm wondering if there is any way to make it only execute on files that were modified.

<for param="file">
                        <path>
                            <fileset dir="${folder}">
                                <include name="*.js" />
                                <include name="*.css" />
                            </fileset>
                        </path>
                        <sequential>
                            <var name="file" value="@{file}"/>

                            <echo message="Minifying ${file}" /> 
                            <java jar="yuicompressor.jar" fork="true">
                                <arg value="${file}" />
                                <arg value="-o" />
                                <arg value="${outfile}" />
                            </java>
                        </sequential>
</for>

Also I'm doing some very hacky stuff to generate ${outfile} (using lots of propertyregex tags). I would like to place all my minified files in a min folder in a more elegant way. For example:

folder/source.js

goes to

min/folder/source.js

and

folder/subfolder/source.js

goes to

min/folder/subfolder/source.js

Was it helpful?

Solution

I see that you are already using antcontrib task in your script.

Because of this take a look at OutOfDate task from the same library -> http://ant-contrib.sourceforge.net/tasks/tasks/outofdate.html

I think it will help you achieve what you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top