Advertisement
Guest User

Untitled

a guest
Mar 29th, 2012
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 9.42 KB | None | 0 0
  1. <?xml version="1.0" encoding = "UTF-8"?>
  2. <project xmlns:ivy="antlib:org.apache.ivy.ant" name="PhotobucketAPI" default="all" basedir=".">
  3.     <!-- Local properties first -->
  4.     <property file="local.properties"/>
  5.  
  6.     <!-- User properties next -->
  7.     <property file="${user.home}/ant.properties"/>
  8.    
  9.     <!-- Load environment variables. Needed for Hudson BUILD_NUMBER-->
  10.     <property environment="env"/>
  11.    
  12.     <property name="version.prefix" value=""/>
  13.     <property name="version.suffix" value="-${user.name}"/>
  14.    
  15.     <!-- set global properties for this build -->
  16.     <property name="core.src.dir" value="core/src" />
  17.     <property name="service.src.dir" value="service/src" />
  18.     <property name="lib.dir"  value="lib"/>
  19.     <property name="build.dir" value="build"/>
  20.     <property name="dist.dir"  value="dist"/>
  21.     <property name="core.test.dir"  value="core/test"/>
  22.     <property name="service.test.dir"  value="service/test"/>
  23.     <property name="reports.dir"  value="reports"/>
  24.    
  25.     <path id="src.path">
  26.         <pathelement path="core/src"/>
  27.         <pathelement path="service/src"/>
  28.     </path>
  29.     <path id="src.test.path">
  30.         <pathelement path="core/test"/>
  31.         <pathelement path="service/test"/>
  32.     </path>
  33.    
  34.     <target name="init" description="Init the project">
  35.         <mkdir dir="${build.dir}"/>
  36.         <mkdir dir="${build.dir}/api-android"/>
  37.         <mkdir dir="${build.dir}/api-j2se"/>
  38.         <mkdir dir="${build.dir}/test"/>
  39.         <mkdir dir="${build.dir}/test/core"/>
  40.         <mkdir dir="${build.dir}/test/service"/>
  41.         <mkdir dir="${dist.dir}"/>
  42.         <mkdir dir="${dist.dir}/lib"/>
  43.         <mkdir dir="${reports.dir}" />
  44.        
  45.         <!-- Default these if not supplied -->
  46.         <property name="env.BUILD_NUMBER" value="DEV-BUILD"/>
  47.         <property name="build.version" value="${version.prefix}${env.BUILD_NUMBER}${version.suffix}"/>
  48.         <echo>Build version: ${build.version}</echo>
  49.     </target>
  50.    
  51.     <target name="clean" description="clean up" >
  52.         <delete dir="${build.dir}"/>
  53.         <delete dir="${dist.dir}"/>
  54.         <delete dir="${basedir}/bin" />
  55.         <delete dir="${reports.dir}" />
  56.     </target>
  57.    
  58.     <target name="init.ivy">
  59.         <!-- Configure Ivy -->
  60.         <property name="ivy.settings.dir" value="${user.home}/.ivy2" />
  61.         <available property="ivy.settings.file.exists" file="${ivy.settings.dir}/ivysettings.xml" />
  62.         <fail unless="ivy.settings.file.exists" message="Unable to find ivysettings.xml in ${ivy.settings.dir}"/>
  63.         <property file="${ivy.settings.dir}/ivysettings.properties" />
  64.         <ivy:settings file="${ivy.settings.dir}/ivysettings.xml" />
  65.     </target>
  66.  
  67.     <target name="resolve" depends="init.ivy">
  68.         <!-- First retrieve what we need to build for Android -->      
  69.         <ivy:retrieve conf="android.build" pattern="${lib.dir}/android.build/[artifact]-[revision].[ext]" />
  70.        
  71.         <!-- Next retrieve what we need to build for J2SE -->
  72.         <ivy:retrieve conf="default" pattern="${lib.dir}/default/[artifact]-[revision].[ext]" />
  73.        
  74.         <!-- Lastly, retrieve what we need to build and run the unit tests -->
  75.         <ivy:retrieve conf="test" pattern="${lib.dir}/test/[artifact]-[revision].[ext]" />
  76.     </target>
  77.    
  78.     <target name="init.classpath">
  79.         <path id="javac.bootclasspath.android">
  80.             <fileset dir=".">
  81.                 <include name="${lib.dir}/android.build/android-*.jar" />
  82.             </fileset>
  83.         </path>
  84.         <property name="javac.bootclasspath.android.text" refid="javac.bootclasspath.android"/>
  85.        
  86.         <path id="javac.classpath.android">
  87.             <fileset dir=".">
  88.                 <include name="${lib.dir}/android.build/*.jar" />
  89.                 <exclude name="${lib.dir}/android.build/android-*.jar"/>
  90.             </fileset>
  91.         </path>
  92.         <property name="javac.classpath.android.text" refid="javac.classpath.android"/>
  93.        
  94.         <path id="javac.classpath.j2se">
  95.             <fileset dir=".">
  96.                 <include name="${lib.dir}/default/*.jar" />
  97.             </fileset>
  98.         </path>
  99.         <property name="javac.classpath.j2se.text" refid="javac.classpath.j2se"/>
  100.        
  101.         <path id="javac.classpath.test">
  102.             <fileset dir=".">
  103.                 <include name="${lib.dir}/test/*.jar" />
  104.             </fileset>
  105.         </path>
  106.         <property name="javac.classpath.test.text" refid="javac.classpath.test"/>
  107.        
  108.         <path id="junit.classpath">
  109.             <pathelement path="${build.dir}/test" />
  110.             <fileset dir=".">
  111.                 <include name="${lib.dir}/test/*.jar" />
  112.             </fileset>
  113.         </path>
  114.         <property name="junit.classpath.text" refid="junit.classpath"/>
  115.  
  116.         <echo>Android bootclasspath: ${javac.bootclasspath.android.text}</echo>
  117.         <echo>Android classpath: ${javac.classpath.android.text}</echo>
  118.         <echo>J2SE classpath: ${javac.classpath.j2se.text}</echo>
  119.         <echo>Test Compile classpath: ${javac.classpath.test.text}</echo>
  120.         <echo>Test Run classpath: ${junit.classpath.text}</echo>
  121.     </target>
  122.    
  123.     <target name="compile.api.android" depends="init,init.classpath" description="Compiles the API classes against the Android SDK">
  124.         <javac
  125.             destdir="${build.dir}/api-android"
  126.             source="1.5"
  127.             target="1.5"
  128.             includeAntRuntime="false"
  129.             includeJavaRuntime="false"
  130.             bootclasspathref="javac.bootclasspath.android"
  131.             classpathref="javac.classpath.android"
  132.             debug="on">
  133.             <src refid="src.path" />
  134.         </javac>
  135.     </target>
  136.    
  137.     <target name="compile.api.j2se" depends="init,init.classpath" description="Compiles the API classes against J2SE + supporting libs">
  138.         <javac
  139.             destdir="${build.dir}/api-j2se"
  140.             source="1.5"
  141.             target="1.5"
  142.             includeAntRuntime="false"
  143.             includeJavaRuntime="false"
  144.             classpathref="javac.classpath.j2se"
  145.             debug="on">
  146.             <src refid="src.path" />
  147.         </javac>
  148.     </target>
  149.    
  150.     <target name="compile.test" depends="init,init.classpath" description="Compiles unit tests">
  151.         <javac
  152.             destdir="${build.dir}/test"
  153.             source="1.5"
  154.             target="1.5"
  155.             includeAntRuntime="false"
  156.             includeJavaRuntime="false"
  157.             classpathref="javac.classpath.test"
  158.             debug="on">
  159.             <src refid="src.path"/>
  160.             <src refid="src.test.path"/>
  161.         </javac>
  162.         <copy todir="${build.dir}/test">
  163.             <fileset dir="core/test" includes="**/*.properties"/>
  164.         </copy>
  165.     </target>
  166.    
  167.     <target name="compile" depends="compile.api.android,compile.api.j2se,compile.test" description="Compiles everything" />
  168.  
  169.     <target name="jar.common">
  170.         <manifest file="${dist.dir}/MANIFEST.MF">
  171.             <attribute name="Implementation-Version" value="${build.version}"/>
  172.         </manifest>
  173.     </target>
  174.        
  175.    
  176.     <target name="jar.android" depends="jar.common">
  177.         <jar destfile="${dist.dir}/pbapi-android.jar" manifest="${dist.dir}/MANIFEST.MF">
  178.             <fileset dir="${build.dir}/api-android" includes="**/*"/>
  179.         </jar>
  180.     </target>
  181.  
  182.     <target name="jar.j2se" depends="jar.common">
  183.         <jar destfile="${dist.dir}/pbapi-j2se.jar" manifest="${dist.dir}/MANIFEST.MF">
  184.             <fileset dir="${build.dir}/api-j2se" includes="**/*"/>
  185.         </jar>
  186.     </target>
  187.    
  188.     <target name="jar" depends="compile,jar.android,jar.j2se"/>
  189.    
  190.     <target name="zip" depends="jar">
  191.         <zip destfile="${dist.dir}/pbapi-full.zip">
  192.             <fileset dir="${dist.dir}">
  193.                 <include name="pbapi-j2se.jar" />
  194.                 <include name="pbapi-android.jar" />
  195.             </fileset>
  196.             <zipfileset dir="${lib.dir}" prefix="lib">
  197.                 <include name="**/*.jar" />
  198.                 <exclude name="android.build/android-*.jar" />
  199.             </zipfileset>
  200.         </zip>
  201.     </target>
  202.  
  203.     <!-- This will copy the template and populate with build system defaults if they're defined -->
  204.     <target name="test.prepare" if="test.api.oauthid">
  205.         <echo>Preparing consumer.properties...</echo>
  206.         <copy file="core/test/consumer.properties.template" tofile="${build.dir}/test/consumer.properties" overwrite="false" />
  207.         <propertyfile file="${build.dir}/test/consumer.properties">
  208.             <entry key="oauth.consumer" value="${test.api.oauthid}" operation="=" />
  209.             <entry key="oauth.consumer.key" value="${test.api.oauthkey}" operation="=" />
  210.             <entry key="subdomain" value="${test.api.subdomain}" operation="=" />
  211.             <entry key="username" value="${test.api.username}" operation="=" />
  212.             <entry key="password" value="${test.api.password}" operation="=" />
  213.             <entry key="differentUser" value="${test.api.differentUser}" operation="=" />
  214.         </propertyfile>
  215.     </target>
  216.    
  217.     <target name="test" depends="compile.test,test.prepare" description="Run unit tests">
  218.         <junit>
  219.             <classpath refid="junit.classpath" />
  220.             <formatter type="xml" />
  221.             <batchtest fork="true" todir="${reports.dir}">
  222.                 <fileset dir="${build.dir}/test">
  223.                     <include name="com/photobucket/api/core/*Test*.class" />
  224.                     <include name="com/photobucket/api/service/*Test*.class" />
  225.                 </fileset>
  226.             </batchtest>
  227.         </junit>
  228.     </target>
  229.  
  230.     <target name="javadoc" depends="compile">
  231.         <javadoc destdir="${dist.dir}/doc" author="true" version="true" use="true" windowtitle="Photobucket Java Client API Documentation">
  232.             <classpath>
  233.                 <pathelement path="${build.dir}/api-j2se" />
  234.             </classpath>
  235.             <fileset dir="." defaultexcludes="yes">
  236.                 <include name="core/src/**/*.java"/>
  237.                 <include name="service/src/**/*.java"/>
  238.             </fileset>
  239.             <doctitle><![CDATA[<h1>Photobucket Java Client API</h1>]]></doctitle>
  240.             <bottom><![CDATA[<i>Copyright &#169; 2011 Photobucket, LLC. All Rights Reserved.</i>]]></bottom>
  241.         </javadoc>
  242.     </target>
  243.    
  244.     <target name="all" depends="clean,jar,javadoc,zip,test" />
  245.    
  246.     <target name="publish" depends="init.ivy,resolve,all">
  247.         <fail unless="env.BUILD_NUMBER" message="env.BUILD_NUMBER property not set"/>
  248.         <!-- Perform a resolve to initialize ivy -->
  249.         <delete file="${dist.dir}/ivy.xml"/>
  250.         <ivy:publish artifactspattern="${dist.dir}/[artifact].[ext]"
  251.             resolver="photobucket-projects-writable"
  252.             pubrevision="${build.version}"
  253.             conf="android,default"
  254.             status="release"
  255.             forcedeliver="true" />
  256.     </target>
  257. </project>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement