小编Chr*_*ann的帖子

ANT脚本用于编译dir中的所有(css)LESS文件和使用RHINO的子目录

我想编译*.less特定文件夹中的所有脚本,并使用less-rhino-1.1.3.js进行子目录.

在github上有一个例子,用于为特定文件执行此操作,这非常有效.但是我想为一个完整的文件夹做同样的事情.我尝试了很多,这是我的最后一次尝试.

它不起作用,propertyregex似乎不是标准的ANT,我不想用这样的东西.我甚至不确定这段代码是否有用.

<project name="test" default="main" basedir="../../">
<property name="css.dir" location="public/css"/>
<property name="tool.less" location="bin/less/less-rhino-1.1.3.js"/>
<property name="tool.rhino" location="bin/tools/rhino/js.jar"/>
<macrodef name="lessjs">
    <attribute name="input" />
    <attribute name="output" />
    <sequential>
        <java jar="${tool.rhino}" fork="true" output="@{output}">
            <arg path="${tool.less}"/>
            <arg path="@{input}"/>
        </java>
        <echo>Lessjs: generated @{output}</echo>
    </sequential>
</macrodef>

<target name="main">
     <echo>compiling less css</echo>
     <fileset dir="${css.dir}" id="myfile">
          <filename name="**/*.less" />
     </fileset>
     <property name="lessfilename" refid="myfile"/>
     <propertyregex property="cssfilename"
          input="${lessfile}"
          regexp="^(.*)\.less$"
          replace="^\1\.css$" 
          casesensitive="true" />
     <lessjs input="lessfile" output="cssfilename"/>
</target>
</project>
Run Code Online (Sandbox Code Playgroud)

ant rhino less

10
推荐指数
2
解决办法
1万
查看次数

标签 统计

ant ×1

less ×1

rhino ×1