Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0b5c7a0191
Fetching contributors…

Cannot retrieve contributors at this time

file 155 lines (128 sloc) 5.768 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
<project name="nui" default="build.all">

    <!-- version number -->
    <property name="nui.version" value="0.1.0" />

    <!-- the directories containing the source files -->
    <property name="src.dir" value="./src" />
    <property name="tests.dir" value="./tests" />
    
    <!-- the directories and files to output to -->
    <property name="build.dir" value="./build" />
    <property name="release.dir" value="./release" />

    <!-- the directory containing library files -->
    <property name="lib.dir" value="./lib" />
    
    <!-- output filenames -->
    <property name="core.build.file" value="nui-core.js"/>
    <property name="core.tests.file" value="nui-core-tests.js"/>
    
    <!-- embeddable license -->
    <loadfile property="license.text" srcfile="LICENSE" />

    <!-- get a timestamp -->
    <tstamp>
      <format property="RIGHT_NOW"
              pattern="d-MMMM-yyyy hh:mm:ss"
              locale="en,US"/>
    </tstamp>
    <tstamp>
      <format property="SIMPLE_DATE"
              pattern="MMMM d, yyyy"
              locale="en,US"/>
    </tstamp>
    
    <!-- clean -->
    <target name="clean">
        <delete dir="${build.dir}" />
    </target>
    
    <target name="changelog.update">
        <exec executable="git" failonerror="true" outputproperty="git.tag">
            <arg line="tag"/>
        </exec>
        <script language="javascript"><![CDATA[
//get the most recent tag to get the diff
var tags = nui.getProperty("git.tag").replace("\r", "").split("\n"),
lastTag = tags[tags.length-1];
nui.setProperty("git.log.range", lastTag + "..HEAD");
]]></script>
        
        <!-- git log -pretty=format:'* %s (%an)' v0.4.0..v0.5.0-->
        <exec executable="git" failonerror="true" outputproperty="git.changelog">
            <arg line="log --pretty=format:'* %s (%an)' ${git.log.range}"/>
        </exec>
        
        <concat destfile="CHANGELOG.tmp" fixlastline="true">
            <header trimleading="yes">${SIMPLE_DATE} - v${nui.version}
            
            ${git.changelog}
            
            </header>
            <fileset dir="." includes="CHANGELOG" />
        </concat>
        
        <delete file="CHANGELOG"/>
        <move file="CHANGELOG.tmp" tofile="CHANGELOG"/>
        
    </target>
    
    <!-- validate JS files with JSHint -->
    <target name="jslint">
        <fileset dir="${src.dir}" includes="**/*.js" id="jsfiles.raw"/>
        <pathconvert pathsep=" " property="jsfiles.clean" refid="jsfiles.raw" />
        <exec executable="java">
            <arg line="-jar"/>
            <arg path="${lib.dir}/js.jar"/>
            <arg path="${lib.dir}/jshint.js" />
            <arg line="${jsfiles.clean} curly=true,forin=true,latedef=true,noempty=true,undef=true,rhino=false" />
        </exec>
    </target>

    <!-- validate CSS files with CSS Lint -->
    <target name="csslint">
        <fileset dir="${src.dir}" includes="**/*.css" id="cssfiles.raw"/>
        <pathconvert pathsep=" " property="cssfiles.clean" refid="cssfiles.raw" />
        <exec executable="java" failonerror="true">
            <arg line="-jar"/>
            <arg path="${lib.dir}/js.jar"/>
            <arg path="${lib.dir}/csslint-rhino.js" />

            <!-- your customized arguments go here -->
            <arg line="${cssfiles.clean} --errors=errors --quiet"/>
        </exec>
    </target>
    
    <!-- all linting -->
    <target name="lint" depends="jslint,csslint"/>

    <!-- run tests on the command line -->
    <target name="test" depends="build.all,lint">
        <exec executable="java" failonerror="true">
            <arg line="-jar"/>
            <arg path="${lib.dir}/js.jar"/>
            <arg path="${lib.dir}/yuitest-rhino-cli.js" />
            <arg path="${build.dir}/core/${core.build.file}" />
            <arg path="${build.dir}/core/${core.tests.file}" />
            <arg line="--groups=core" />
        </exec>
    </target>

    <!-- build the core library -->
    <target name="build.core">
        
        <concat destfile="${build.dir}/core/${core.build.file}" fixlastline="true">
            <header trimleading="yes">/*!
            ${license.text}
            */
            /* Version v@VERSION@, Build time: ${RIGHT_NOW} */
            </header>
            <filelist dir="${src.dir}/core" files="nui.js" />
            <fileset dir="${src.dir}/core" includes="*.js" excludes="nui.js"/>
        </concat>
    </target>
    
    <!-- build the controls -->
    <target name="build.controls">
        <copy todir="${build.dir}">
            <fileset dir="${src.dir}" includes="**/*.js" excludes="core/*.js"/>
        </copy>
    </target>
    
    <!-- build the tests into a single file -->
    <target name="build.tests">
        <concat destfile="${build.dir}/core/${core.tests.file}" fixlastline="true">
            <fileset dir="${tests.dir}/core" includes="**/*.js" />
        </concat>
    </target>

    <!-- Create a release with version number embedded -->
    <target name="release" depends="test,build.all,changelog.update">
        <delete dir="${release.dir}" />
        <mkdir dir="${release.dir}"/>
        <copy todir="${release.dir}">
            <fileset dir="${build.dir}" includes="**/*" />
        </copy>
        <replaceregexp match="@VERSION@" replace="${nui.version}" flags="g" byline="true">
            <fileset dir="${release.dir}" includes="**/*"/>
        </replaceregexp>
    </target>
    
    <!-- Build all files -->
    <target name="build.all" depends="clean,build.core,build.tests,build.controls"/>

</project>
Something went wrong with that request. Please try again.