【问题标题】:Exclude directory and js minification with Ant使用 Ant 排除目录和 js 缩小
【发布时间】:2015-11-05 07:32:58
【问题描述】:

我想在构建项目时使用ant 来缩小jscss。请在下面找到我的项目的目录结构:

这里,scripts 目录有多个目录。 我想从ant 任务中排除脚​​本目录中名为“库”的目录。

“库”以外的目录有 js 文件。我想将这些js 文件包含在ant 缩小任务中。

请在下面找到我的build.xml

<project name="ITV" default="doMinification">
    <property name="webroot.dir" value="webapp/" /> 
    <target name="doMinification" depends="minifyjs" />

    <tstamp>
        <format property="TODAY_MY" pattern="yyyyMMdd-HHmmss"  locale="en,UK" />
    </tstamp>

    <!-- Minify JS -->
    <target name="minifyjs">                
        <apply executable="java" parallel="false" dest="webapp/scripts/" verbose="true">
            <fileset id="jsFiles" dir="webapp/scripts/">
                <exclude name="webapp/scripts/Libraries/" />                
                <include name="**/*.js"/>                   
            </fileset>
            <arg line="-jar"/>
            <arg path="yuicompressor-2.4.7.jar"/>
            <srcfile/>
            <arg line="-o"/>
            <mapper type="glob" from="**/*.js" to="*-min-${TODAY_MY}.js" />
            <targetfile/>
        </apply>            
    </target>
</project>

如何在ant javascript 缩小任务中排除特定目录并包含其他目录及其文件?

【问题讨论】:

    标签: javascript java xml ant


    【解决方案1】:

    您可能需要检查similar question here

    有这个答案:

    <exclude name="**/dir_name_to_exclude/**" />
    

    对于您的情况:

    <exclude name="**/Libraries/**" />
    

    例如:

     <target name="minifyjs">                
            <apply executable="java" parallel="false" dest="webapp/scripts/" verbose="true">
                <fileset id="jsFiles" dir="webapp/scripts/">
                    <exclude name="**/Libraries/**" />                
                    <include name="**/*.js"/>                   
                </fileset>
                <arg line="-jar"/>
                <arg path="yuicompressor-2.4.7.jar"/>
                <srcfile/>
                <arg line="-o"/>
                <mapper type="glob" from="**/*.js" to="*-min-${TODAY_MY}.js" />
                <targetfile/>
            </apply>            
        </target>
    

    我希望这会有所帮助。

    【讨论】:

    • @CodeLama- 感谢您的回答。我试过了,但什么也没发生。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 2013-04-10
    • 2010-09-14
    • 1970-01-01
    • 2011-09-24
    • 2012-10-22
    相关资源
    最近更新 更多