Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

561 lines (501 sloc) 22.585 kB
<?xml version="1.0" encoding="UTF-8"?>
<project name="sockso" default="run" basedir=".">
<description>Builds, runs and packages Sockso</description>
<!--
#############
INIT/PROPS
#############
-->
<property file="sockso.properties" />
<property name="sockso.version" value="1.5.3" />
<property name="dir.build" value="build/app" />
<property name="dir.build.test" value="build/test" />
<property name="dir.dist" value="dist" />
<property name="dir.docs" value="docs" />
<property name="dir.docs.junit" value="${dir.docs}/junit" />
<property name="dir.src" value="src" />
<property name="dir.src.test" value="test" />
<property name="dir.lib" value="lib/std" />
<property name="dir.lib-dev" value="lib/dev" />
<property name="dir.lib-opt" value="lib/opt" />
<property name="dir.temp" value="ant-temp-dir" />
<property name="dir.resources" value="resources" />
<property name="dir.packages" value="packages" />
<property name="dir.scripts" value="scripts" />
<property name="dir.javadocs" value="${dir.docs}/javadocs" />
<property name="dir.www" value="www" />
<!-- set classpaths for jars -->
<fileset id="sockso.jars" dir=".">
<include name="${dir.lib}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="app.classpath" refid="sockso.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert pathsep=" " property="jar.classpath" refid="sockso.jars">
<map from="${basedir}/" to=" "/>
</pathconvert>
<!-- classpath for dev jars -->
<fileset id="sockso-dev.jars" dir=".">
<include name="${dir.lib-dev}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="dev.classpath" refid="sockso-dev.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<!-- classpath for optional jars -->
<fileset id="sockso-opt.jars" dir=".">
<include name="${dir.lib-opt}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="opt.classpath" refid="sockso-opt.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert pathsep=" " property="jar-opt.classpath" refid="sockso-opt.jars">
<map from="${basedir}/" to=" "/>
</pathconvert>
<property name="junit.classpath" value="${dir.build}:${dir.build.test}:${app.classpath}:${dev.classpath}:${opt.classpath}" />
<taskdef name="jamon"
classname="org.jamon.ant.JamonTask"
classpath="${dir.lib}/jamon-runtime-2.3.1.jar:${dir.lib-dev}/jamon-api-2.3.0.jar:${dir.lib-dev}/jamon-processor-2.3.2.jar:${dir.lib-dev}/jamon-anttask-2.3.1.jar" />
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler"
classpath="${dir.lib-dev}/jarbundler-2.1.0.jar" />
<taskdef name="testability"
classname="com.google.ant.TestabilityTask"
classpath="${dev.classpath}" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpath="${dev.classpath}" />
<target name="init">
<mkdir dir="${dir.dist}" />
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.build.test}" />
<mkdir dir="${dir.packages}" />
<if>
<not><available file="sockso.properties" /></not>
<then>
<copy file="sockso.properties-sample" tofile="sockso.properties" />
</then>
</if>
</target>
<!--
################
COMPILE/BUILD
################
-->
<target name="compile-templates" depends="init" description="compile jamon source files to java classes">
<delete dir="${dir.src}/com/pugh/mymusic/tmpl" />
<jamon destdir="${dir.src}" srcdir="templates" />
</target>
<!-- creates a file with some properties info -->
<target name="create-properties">
<!-- write app properties file -->
<echo file="src/com/pugh/sockso/Sockso.java">
package com.pugh.sockso;
public class Sockso {
public static final String VERSION = "${sockso.version}";
}
</echo>
</target>
<target name="compile" depends="create-properties,compile-templates" description="compiles the project to build dir">
<!-- then do compile -->
<javac srcdir="${dir.src}"
destdir="${dir.build}"
classpath="${app.classpath}:${opt.classpath}"
source="1.5"
target="1.5"
debug="${debug}"
includeantruntime="true">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>
<target name="resources" depends="init" description="compiles the resources">
<!-- compile stub file -->
<javac srcdir="${dir.resources}"
destdir="${dir.resources}"
source="1.5"
target="1.5"
includeantruntime="true" />
<!-- remove locale javascript files, we don't want to pack them -->
<delete>
<fileset dir="${dir.resources}/htdocs/js" includes="locale*.js" />
</delete>
<!-- pack javascript -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/pack-resources.php" />
<arg value="${sockso.version}" />
</exec>
<!-- create locale javascript files -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/create-locale-javascript.php" />
<arg value="${sockso.version}" />
</exec>
<!-- create locale index file -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/create-locale-index.php" />
<arg value="${sockso.version}" />
</exec>
<!-- build jar -->
<jar basedir="${dir.resources}" destfile="${dir.dist}/resources.jar">
<fileset dir="${dir.resources}">
<exclude name="**/*.java" />
<!-- TODO: exclude all javascript but the packed javascript file -->
</fileset>
</jar>
<!-- copy files to dist dir -->
<copy todir="${dir.dist}/resources">
<fileset dir="resources" />
</copy>
</target>
<target name="dist" depends="jars" description="builds the distributable files">
<copy todir="${dir.dist}">
<fileset dir="dist-files" />
</copy>
<copy todir="${dir.dist}/lib/std">
<fileset dir="${dir.lib}" />
</copy>
<!-- windows tray icon -->
<mkdir dir="${dir.dist}/icons" />
<copy file="${dir.resources}/icons/tray.ico" todir="${dir.dist}/icons" />
</target>
<target name="jars" depends="jar,resources" description="builds the sockso jar and resources"/>
<target name="clean-tests" description="cleans compiled tests classes">
<delete dir="${dir.build.test}" />
</target>
<target name="clean" depends="clean-tests" description="cleans the dist build">
<delete dir="${dir.build}" />
<delete dir="${dir.dist}" />
<delete dir="${dir.src}/com/pugh/sockso/templates" />
<delete dir="${dir.packages}" />
</target>
<target name="jar" depends="compile" description="builds the main jar file">
<jar file="${dir.dist}/sockso.jar" basedir="${dir.build}">
<include name="**/*.class" />
<manifest>
<attribute name="Built-By" value="${developer.name}" />
<attribute name="Main-class" value="com.pugh.sockso.Main" />
<attribute name="Class-Path" value="resources.jar ${jar.classpath} ${jar-opt.classpath}" />
</manifest>
</jar>
</target>
<target name="lint-js" description="run jslint on javascript files">
<exec executable="rhino" failonerror="true">
<arg value="scripts/lint.js" />
</exec>
</target>
<!--
#####################
DOCS/PACKAGING
#####################
-->
<target name="javadocs" description="generate sockso javadoc files">
<javadoc sourcepath="${dir.src}" destdir="${dir.javadocs}" classpath="${app.classpath}:${dev.classpath}:${opt.classpath}" />
</target>
<target name="package" depends="clean,dist,website" description="make packages from dist">
<mkdir dir="${dir.temp}" />
<move file="${dir.dist}" tofile="${dir.temp}/sockso-${sockso.version}" />
<!-- OSX.
1. create .app folder -->
<jarbundler dir="${dir.packages}"
name="sockso-${sockso.version}"
shortname="Sockso"
mainclass="com.pugh.sockso.Main"
icon="${dir.resources}/icons/sockso.icns"
version="${sockso.version}"
infostring="Sockso - Personal Music Server"
arguments="--resourcestype=jar"
jvmversion="1.5+">
<jarfileset dir="${dir.temp}">
<include name="**/*.jar" />
</jarfileset>
</jarbundler>
<!-- 2. create dmg's from .app folder -->
<exec executable="hdiutil">
<arg line="create -srcfolder ${dir.packages}/sockso-${sockso.version}.app ${dir.packages}/sockso-${sockso.version}.dmg"/>
</exec>
<copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-latest.dmg" />
<copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-dev.dmg" />
<!-- 3. remove .app folder -->
<delete dir="${dir.packages}/sockso-${sockso.version}.app" />
<!-- we need the resources.jar files for the mac bundle, but not other packages -->
<delete file="${dir.temp}/sockso-${sockso.version}/resources.jar" />
<delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.class" />
<delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.java" />
<!-- make standard packages -->
<zip destfile="${dir.packages}/sockso-dev.zip" basedir="${dir.temp}" />
<zip destfile="${dir.packages}/sockso-latest.zip" basedir="${dir.temp}" />
<zip destfile="${dir.packages}/sockso-${sockso.version}.zip" basedir="${dir.temp}" />
<!-- @todo make 64bit windows archive -->
<!-- done, cleanup! -->
<move file="${dir.temp}/sockso-${sockso.version}" tofile="${dir.dist}" />
<delete dir="${dir.temp}" />
<!-- build optionals package -->
<zip destfile="${dir.packages}/sockso-optionals.zip" basedir="${dir.lib-opt}" />
</target>
<target name="website" description="updates the website (if it's configured) with information like current version">
<if>
<not><equals arg1="${website.path}" arg2="" /></not>
<then>
<property name="template" value="${website.path}/views/controllers/version/latest.tpl" />
<echo message="Updating website with latest version ${sockso.version}" />
<echo message="Template: ${template}" />
<echo file="${template}">${sockso.version}</echo>
</then>
</if>
</target>
<target name="optionals" description="includes optional components into the distribution">
<copy todir="${dir.dist}/lib/opt">
<fileset dir="${dir.lib-opt}" />
</copy>
</target>
<!--
##################
RUN/DEBUG
##################
-->
<target name="-runargs.init">
<condition property="run.opt.admin"
value="--admin" else="">
<isset property="run.arg.admin" />
</condition>
<condition property="run.opt.datadir"
value="--datadir=${run.arg.datadir}" else="">
<isset property="run.arg.datadir" />
</condition>
<condition property="run.opt.logtype"
value="--logtype=${run.arg.logtype}" else="">
<isset property="run.arg.logtype" />
</condition>
<condition property="run.opt.nogui"
value="--nogui" else="">
<isset property="run.arg.nogui" />
</condition>
<condition property="run.opt.resourcestype"
value="--resourcestype=${run.arg.resourcestype}" else="">
<isset property="run.arg.resourcestype" />
</condition>
<condition property="run.opt.ip"
value="--ip=${run.arg.ip}" else="">
<isset property="run.arg.ip" />
</condition>
<condition property="run.opt.locale"
value="--locale=${run.arg.locale}" else="">
<isset property="run.arg.locale" />
</condition>
<condition property="run.opt.dbtype"
value="--dbtype=${run.arg.dbtype}" else="">
<isset property="run.arg.dbtype" />
</condition>
<condition property="run.opt.dbhost"
value="--dbhost=${run.arg.dbhost}" else="">
<isset property="run.arg.dbhost" />
</condition>
<condition property="run.opt.dbuser"
value="--dbuser=${run.arg.dbuser}" else="">
<isset property="run.arg.dbuser" />
</condition>
<condition property="run.opt.dbpass"
value="--dbpass=${run.arg.dbpass}" else="">
<isset property="run.arg.dbpass" />
</condition>
<condition property="run.opt.dbname"
value="--dbname=${run.arg.dbname}" else="">
<isset property="run.arg.dbname" />
</condition>
<condition property="run.opt.ssl"
value="--ssl" else="">
<isset property="run.arg.ssl" />
</condition>
<condition property="run.opt.sslKeystore"
value="--sslKeystore=${run.arg.sslKeystore}" else="">
<isset property="run.arg.sslKeystore" />
</condition>
<condition property="run.opt.sslKeystorePassword"
value="--sslKeystorePassword=${run.arg.sslKeystorePassword}" else="">
<isset property="run.arg.sslKeystorePassword" />
</condition>
<condition property="run.opt.upnp"
value="--upnp" else="">
<isset property="run.arg.upnp" />
</condition>
</target>
<target name="run" depends="dist,optionals,-runargs.init" description="runs the project">
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
</java>
</target>
<target name="debug" depends="clean,dist,optionals,-runargs.init"
if="netbeans.home" description="runs the project in debug mode">
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n" />
</java>
</target>
<target name="profile" depends="dist,optionals,-runargs.init" if="netbeans.home">
<nbprofiledirect>
</nbprofiledirect>
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
<jvmarg value="${profiler.info.jvmargs.agent}" />
</java>
</target>
<!--
##################
TESTING
##################
-->
<target name="compile-tests" description="compiles test classes">
<javac srcdir="${dir.src.test}"
destdir="${dir.build.test}"
classpath="${dir.build}:${app.classpath}:${dev.classpath}"
source="1.5"
target="1.5"
debug="on"
includeantruntime="true">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>
<!-- init before we do tests -->
<target name="init-tests">
<if>
<equals arg1="${mysql.enabled}" arg2="1" />
<then>
<sql driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://${mysql.host}"
userid="${mysql.user}"
password="${mysql.pass}"
classpath="${opt.classpath}"
onerror="continue">
<transaction src="test/data/mysql/drop.sql"/>
<transaction src="test/data/mysql/create.sql"/>
</sql>
</then>
</if>
</target>
<!-- the class to test needs to be specified on the command line by using:
-Dclass=FULL_CLASSNAME -->
<target name="test-single" depends="compile,compile-tests,init-tests" description="tests a particular class">
<fail unless="class">Must set property 'class'</fail>
<junit haltonfailure="true" fork="yes" dir="." showoutput="true">
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<classpath path="${junit.classpath}" />
<test name="${class}" todir="${dir.docs.junit}/results"/>
</junit>
</target>
<target name="test" depends="clean,compile,compile-tests,init-tests" description="run all tests and generate reports">
<delete dir="${dir.docs.junit}" />
<mkdir dir="${dir.docs.junit}" />
<mkdir dir="${dir.docs.junit}/html" />
<mkdir dir="${dir.docs.junit}/results" />
<junit haltonfailure="true" dir=".">
<classpath path="${junit.classpath}" />
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${dir.docs.junit}/results">
<fileset dir="${dir.build.test}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${dir.docs.junit}">
<fileset dir="${dir.docs.junit}/results">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${dir.docs.junit}/html"/>
</junitreport>
</target>
<target name="testability" depends="clean,dist" description="runs the testability reports">
<testability
filter=""
resultfile="${dir.docs}/testability.result.html"
errorfile="${dir.docs}/testability.err.txt"
printdepth="2"
print="html"
mincost="1"
maxexcellentcost="50"
maxacceptablecost="100"
worstoffendercount="25"
whitelist="com.pugh.sockso."
cyclomatic="1"
global="10"
failproperty="testability.failproperty">
<classpath>
<fileset dir="${dir.dist}">
<include name="sockso.jar"/>
</fileset>
</classpath>
</testability>
</target>
<target name="test-all" depends="test,test-js" description="test everything"/>
<target name="test-js-server" description="starts the js test server">
<java jar="${dir.lib-dev}/JsTestDriver-${jstestdriver.version}.jar" fork="true">
<arg value="--port" />
<arg value="${jstestdriver.port}" />
</java>
</target>
<target name="test-js" description="runs the js tests">
<waitfor maxwait="1" maxwaitunit="second">
<socket server="localhost" port="${jstestdriver.port}"/>
</waitfor>
<!--
<condition property="tests" value="${tests}" else="all">
<isset property="tests" />
</condition>
-->
<java jar="${dir.lib-dev}/JsTestDriver-${jstestdriver.version}.jar" fork="true">
<arg value="--config" />
<arg value="test/js/jsTestDriver.conf" />
<arg value="--tests" />
<arg value="all" />
</java>
</target>
</project>
Jump to Line
Something went wrong with that request. Please try again.