在Ant中使用less4j来编译较少的css

时间:2014-07-11 14:52:33

标签: java css ant less

我试图在Ant中使用less4j来编译LESS到CSS。似乎应该以非常简单的方式使用less4j(许多人在网上推荐它)。但似乎需要很多其他jar文件。以下是我使用的build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="compile" default="css.concatenate" basedir=".">
<property name="charset" value="utf-8"/>


<macrodef name="less4j">
                <attribute name="src" />
                <attribute name="css" />
                <sequential>
                        <java jar="${basedir}/lib/less4j-0.0.5.jar" fork="true">
                            <arg value="@{src}" />
                            <arg value="@{css}" />
                                <classpath>
                                    <pathelement location="${basedir}/lib/less4j-0.0.5.jar" />
                                    <pathelement location="${basedir}/lib/jcommander.jar" />
                                    <pathelement location="${basedir}/lib/antlr-runtime.jar" />
                                    <pathelement location="${basedir}/lib/commons-io.jar" />
                                    <pathelement location="${basedir}/lib/commons-beanutils.jar" />
                                    <pathelement location="${basedir}/lib/commons-logging.jar" />
                                </classpath>

                        </java>
                </sequential>
        </macrodef>

<!-- compile LESS -->

<target name="css.concatenate">
    <concat destfile="${basedir}/src/main/webapp/cons/cons.less">
        <fileset dir="${basedir}/src/main/webapp/less">
            <include name="*.less"/>
        </fileset>
    </concat>
    <echo>cons is done!</echo>
</target>



<target name="css" depends="css.concatenate" description="Create CSS">
                <mkdir dir="${basedir}/tryGotCSS" />
                <less4j
                        src="${basedir}/src/main/webapp/less/lessFile.less"
                        css="${basedir}/src/main/webapp/css/trycore.css" />

        </target>


<target name="trasition" >
            <echo> in trasition </echo>

</target>

<!-- precompile handlebars -->

    <!-- -->



</project>

然而,错误是这样的:

Buildfile: C:\Users\di_yu\workspace\serverCompiler\build.xml
css.concatenate:
 [echo] cons is done!
trasition:
 [echo]  in trasition 
css.concatenate:
 [echo] cons is done!
css:
 [java] Errors produced by compilation of     C:\Users\di_yu\workspace\serverCompiler/src/main/webapp/less/lessFile.less
 [java] ERROR 13:3 no viable alternative at input 'div' in ruleset (which started at 10:1)
 [java] ERROR 13:9 no viable alternative at input '.' in ruleset (which started at 13:3)
 [java] ERROR 13:23 missing ')' at '0' in abstract mixin or namespace (which started at 13:9)
 [java] ERROR 13:23 missing '{' at '0' in abstract mixin or namespace (which started at 13:9)
 [java] ERROR 13:23 no viable alternative at input '0' in abstract mixin or namespace (which started at 13:9)
 [java] ERROR 13:33 mismatched input ')' expecting '{' in ruleset (which started at 13:23)
 [java] Could not compile the file C:\Users\di_yu\workspace\serverCompiler/src/main/webapp/less/lessFile.less
BUILD SUCCESSFUL
Total time: 1 second

有人可以告诉我这是什么问题?????这个虫子杀了我......

0 个答案:

没有答案