Changeset 2776

Show
Ignore:
Timestamp:
14/06/07 10:20:43 (5 years ago)
Author:
michael
Message:

Basic build system using Ant/Ivy

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build.xml

    r2750 r2776  
    1 <project name="xtc" default="dist" xmlns:ivy="antlib:fr.jayasoft.ivy.ant"> 
     1<project name="xtc" default="help" xmlns:ivy="antlib:org.apache.ivy.ant"> 
     2    <!-- Sarugo common ant configuration --> 
     3    <property name="ant.lib.dir" value="ant"/> 
     4    <property name="ant.server" value="http://ant.sarugo.org"/> 
     5    <property name="sarugo.ant.file" value="${ant.lib.dir}/common-build.xml"/> 
    26    <!-- Ivy configuration --> 
    3     <property name="ivy.install.version" value="1.4.1"/> 
    4     <property name="ivy.jar.dir" value="ivy"/> 
    5     <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/> 
     7    <property name="ivy.server" value="${ant.server}/ivy"/> 
     8    <property name="ivy.version" value="2.0.0-alpha-1-incubating"/> 
     9    <property name="ivy.dest.file" value="${ant.lib.dir}/ivy-${ivy.version}.jar"/> 
     10    <condition property="download-ivy.required"> 
     11        <not><available file="${ivy.dest.file}" type="file"/></not> 
     12    </condition> 
    613    <!-- Project directories --> 
    7     <property name="lib.dir" value="lib"/> 
    814    <property name="src.dir" value="src"/> 
    915    <property name="build.dir" value="build"/> 
    10     <property name="dist.dir" value="distrib"/> 
     16    <property name="dist.dir" value="dist"/> 
     17    <property name="lib.dir" value="lib"/> 
     18    <condition property="bootstrap.required"> 
     19        <not><and> 
     20            <available file="${ant.lib.dir}" type="dir"/> 
     21            <available file="${lib.dir}" type="dir"/> 
     22        </and></not> 
     23    </condition> 
    1124     
    12      
    13     <target name="install-ivy" description="Install Ivy dependency manager"> 
    14         <mkdir dir="${ivy.jar.dir}"/> 
     25    <target name="download-ivy" if="download-ivy.required"> 
    1526        <!-- download Ivy from web site so that it can be used even without any special installation --> 
    16         <get src="http://www.jayasoft.org/downloads/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true"/> 
    17         <path id="ivy.lib.path"> 
    18             <fileset dir="${ivy.jar.dir}" includes="*.jar"/> 
    19         </path> 
    20         <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml" uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/> 
     27        <get src="${ivy.server}/${ivy.version}/ivy-${ivy.version}.jar" dest="${ivy.dest.file}" usetimestamp="true"/> 
    2128    </target> 
    2229     
    23     <target name="install-libs" depends="install-ivy" description="Install 3rd party dependencies to local repository"> 
    24         <ivy:retrieve /> 
     30    <target name="bootstrap" description="Downloads common ant scripts and libraries"> 
     31        <mkdir dir="${ant.lib.dir}"/> 
     32        <antcall target="download-ivy"/> 
     33        <path id="ivy.lib.path"> 
     34          <fileset file="${ivy.dest.file}"/> 
     35        </path> 
     36        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 
     37        <ivy:configure file="ivysettings.xml"/> 
     38        <ivy:resolve file="ivy.xml"/> 
     39        <ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]"/> 
    2540    </target> 
    2641     
    27     <target name="compile" depends="install-libs" description="Compile the library"> 
     42    <target name="init" if="bootstrap.required"> 
     43        <fail message="You need to run ant bootstrap"/> 
     44    </target> 
     45     
     46    <target name="compile" depends="init" description="Compile the library"> 
    2847        <mkdir dir="${build.dir}/main/java" /> 
    2948        <javac source="1.5" target="1.5" destdir="${build.dir}/main/java"> 
     
    3150            <classpath> 
    3251                <pathelement path="${build.dir}/main/java"/> 
    33                 <fileset dir="${lib.dir}"> 
    34                     <include name="**/*.jar"/> 
    35                 </fileset> 
     52                <fileset dir="${lib.dir}" includes="**/*.jar"/> 
    3653            </classpath> 
    3754        </javac> 
    3855    </target> 
    3956     
    40     <target name="dist" depends="compile" description="Build distribution files and upload to repository"> 
     57    <target name="test" depends="compile" description="Build and run unit tests"> 
     58        <mkdir dir="${build.dir}/test/java" /> 
     59        <javac source="1.5" target="1.5" destdir="${build.dir}/test/java"> 
     60            <src path="${src.dir}/test/java"/> 
     61            <classpath> 
     62                <pathelement path="${build.dir}/main/java"/> 
     63                <pathelement path="${build.dir}/test/java"/> 
     64                <fileset dir="${lib.dir}" includes="**/*.jar"/> 
     65            </classpath> 
     66        </javac> 
     67    </target> 
     68     
     69    <target name="package" depends="compile" description="Build distribution files"> 
    4170        <mkdir dir="${dist.dir}"/> 
    4271        <jar destfile="${dist.dir}/xtc.jar"> 
     
    4473            <fileset dir="${src.dir}/main/resources" /> 
    4574        </jar> 
     75        <!-- Use ivy to copy the runtime dependencies to distribution directory --> 
     76        <path id="ivy.lib.path"> 
     77          <fileset file="${ivy.dest.file}"/> 
     78        </path> 
     79        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 
     80        <ivy:configure file="ivysettings.xml"/> 
     81        <ivy:resolve file="ivy.xml"/> 
     82        <ivy:retrieve pattern="${dist.dir}/[artifact]-[revision].[ext]" conf="default"/> 
     83    </target> 
     84     
     85    <target name="integration-test" depends="package" description="Test distribution files"> 
    4686    </target> 
    4787     
    4888    <target name="clean" description="Clean the project built files (not dist)"> 
    49         <delete includeemptydirs="true"
     89        <delete includeemptydirs="true" failonerror="false"
    5090            <fileset dir="${build.dir}"/> 
    5191        </delete> 
    5292    </target> 
    5393     
    54     <target name="clean-dist" depends="clean" description="Clean all generated (or downloaded) files"> 
    55         <delete includeemptydirs="true"> 
    56             <fileset dir="${lib.dir}"/> 
     94    <target name="clean-dist" depends="clean" description="Clean compiled, packaged and downloaded library files"> 
     95        <delete includeemptydirs="true" failonerror="false"> 
    5796            <fileset dir="${dist.dir}"/> 
    5897        </delete> 
    5998    </target> 
    6099     
     100    <target name="clean-all" depends="clean-dist" description="Clean all generated (or downloaded) files"> 
     101        <delete includeemptydirs="true" failonerror="false"> 
     102            <fileset dir="${ant.lib.dir}"/> 
     103            <fileset dir="${lib.dir}"/> 
     104        </delete> 
     105    </target> 
     106     
     107    <target name="help"> 
     108        <echo message="Run ant -p to see a list of targets."/> 
     109        <echo message="Most likely you want to test or package."/> 
     110    </target> 
     111     
    61112</project> 
  • trunk/ivy.xml

    r2750 r2776  
    11<ivy-module version="1.3"> 
    2   <info organisation="sarugo" module="xtc"/> 
     2  <info organisation="sarugo" module="xtc" revision="1.0.0" status="integration"> 
     3    <license name="CDDL" url="http://www.sun.com/cddl/"/> 
     4  </info> 
     5  <configurations> 
     6    <conf name="default" description="Runtime configuration"/> 
     7    <conf name="compile" visibility="private"/> 
     8    <conf name="test" visibility="private" extends="default,compile"/> 
     9  </configurations> 
    310  <dependencies> 
    4     <dependency org="org.restlet" name="org.restlet" rev="1.0.1" conf="default"/> 
     11    <dependency org="org.restlet" name="org.restlet" rev="1.0.1" conf="compile->default"/> 
     12    <dependency org="com.noelios.restlet" name="com.noelios.restlet.ext.simple" rev="1.0.1" conf="default"/> 
     13    <dependency org="de.odysseus.juel" name="juel" rev="2.1.0" conf="default,compile->default"/> 
     14    <dependency org="junit" name="junit" rev="3.8.2" conf="test->default"/> 
    515  </dependencies> 
    616</ivy-module> 
  • trunk/ivysettings.xml

    r2750 r2776  
    1 <ivyconf
    2   <conf defaultResolver="maven" /> 
     1<ivysettings
     2  <settings defaultResolver="maven" /> 
    33  <resolvers> 
    4     <chain name="maven"
     4    <chain name="maven" returnFirst="true"
    55      <ibiblio name="restlet" root="http://maven.restlet.org/" m2compatible="true" /> 
    6       <ivyrep name="ivyrep" /> 
     6      <ibiblio name="ibiblio" m2compatible="true" /> 
    77    </chain> 
     8    <filesystem name="public"> 
     9      <ivy pattern="${dist.dir}/publish/[organisation]/[module]/[revision]/ivy-[revision].xml"/> 
     10      <artifact pattern="${dist.dir}/publish/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"/> 
     11    </filesystem> 
    812  </resolvers> 
    9 </ivyconf> 
     13  <modules> 
     14    <module organisation="sarugo" name=".*" resolver="public"/> 
     15  </modules> 
     16</ivysettings>