我可以在 ANT 中使用 less4j 将 less 编译成 css 吗? [英] Can I use less4j to compile less into css in ANT?

查看:20
本文介绍了我可以在 ANT 中使用 less4j 将 less 编译成 css 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以给我一个演示.当我使用less4j时,在标签中,我应该放入什么?网上查了半天,好像根本没有关于在ANT中使用less4j的资料.

I am wondering if some one could give me a demo. When I use less4j, in tag, what should I put in ? I searched online for a long time, but it seems that there are no information about using less4j in ANT at all.

但是由于less4j可以在命令行中实现,所以它必须可以在ANT中实现.请帮我解决这个问题,谢谢!

But since less4j could be implemented in command line, so it must be implementable in ANT. Please help me with this, thanks!

推荐答案

<?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 dir="${basedir}/lib/com/github/sommeri/less4j/commandline" classname="CommandLine" fork="false">
                                <classpath>
                                        <pathelement location="${basedir}/lib/less4j.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>
                                <arg value="@{src}" />
                                <arg value="@{css}" />
                        </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/cons/cons.less"
                        css="${basedir}/src/main/webapp/css/trycore.css" />

        </target>


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

</target>

<!-- precompile handlebars -->

    <!-- -->



</project>

我试图运行这个脚本,但是由于找不到类Commandline"(它有main方法),构建失败,但是当我检查less4j的源代码时,我很漂亮确保命令行类位于 ${basedir}/lib/com/github/sommeri/less4j/commandline" classname="CommandLine.

I was trying to run this script, but the build will fail for the reason that it could not find the class "Commandline"(which has the main method), but when I check the source code of less4j, I am pretty sure that the Commandline class is under the ${basedir}/lib/com/github/sommeri/less4j/commandline" classname="CommandLine.

这篇关于我可以在 ANT 中使用 less4j 将 less 编译成 css 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆