我可以使用less4j编译少进CSS的蚂蚁? [英] Can I use less4j to compile less into css in ANT?

查看:216
本文介绍了我可以使用less4j编译少进CSS的蚂蚁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果有一个人可以给我演示。当我使用less4j,在标签,我应该怎么放?我在网上搜了很久,但似乎没有关于使用ANT在less4j的所有信息。

但由于less4j可以在命令行中执行,因此它必须在ANT实现的。请帮我这个,谢谢!


解决方案

 <?XML版本=1.0编码=UTF-8&GT?;
<项目名称=编译默认值=css.concatenateBASEDIR =&gt的帮助。
<属性名=字符集VALUE =UTF-8/>
< macrodef NAME =less4j>
                <属性名=SRC/>
                <属性名=CSS/>
                <&连续GT;
         < java的DIR =$ {} BASEDIR / lib中/ COM / github上/索梅里/ less4j /命令行类名=的CommandLine叉=false的>
                                <&类路径GT;
                                        < pathelement位置=$ {} BASEDIR /lib/less4j.jar/>
                                        < pathelement位置=$ {} BASEDIR /lib/jcommander.jar/>
                                        < pathelement位置=$ {} BASEDIR /lib/antlr-runtime.jar/>
                                        < pathelement位置=$ {} BASEDIR /lib/commons-io.jar/>
                                        < pathelement位置=$ {} BASEDIR /lib/commons-beanutils.jar/>
                                        < pathelement位置=$ {} BASEDIR /lib/commons-logging.jar/>
                                < /类路径>
                                < ARG值=@ {} SRC/>
                                < ARG值=@ {} CSS/>
                        < / JAVA>
                < /顺序>
        < / macrodef><! - 编译LESS - ><目标名称=css.concatenate>
    < CONCAT destfile =$ {} BASEDIR /src/main/webapp/cons/cons.less>
        <文件集DIR =$ {} BASEDIR /钢骨混凝土/主/ web应用/少>
            <包括姓名=*少。/>
        < /文件集>
    < / CONCAT>
    <回声>缺点是做<!/回声>
< /目标与GT;<目标名称=CSS取决于=css.concatenate描述=创建CSS>
                < MKDIR DIR =$ {BASEDIR} / tryGotCSS/>
                < less4j
                        SRC =$ {} BASEDIR /src/main/webapp/cons/cons.less
                        CSS =$ {} BASEDIR /src/main/webapp/css/trycore.css/>        < /目标与GT;
<目标名称=变迁理论>
            <回声>在变迁理论< /回声>< /目标与GT;<! - precompile车把 - >    &所述;! - - >< /项目>

我试图运行此脚本,而是生成将失败,它无法找到类命令行(它的主要方法)的原因,但是当我检查less4j源$ C ​​$ C,我是pretty确保命令行类是$ {} BASEDIR / lib目录下的/ COM / github上/索梅里/ less4j /命令行类名=的CommandLine。

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.

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>

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.

这篇关于我可以使用less4j编译少进CSS的蚂蚁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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