autopublish your current javadocs on your intranet server





7
Date Submitted Mon. May. 15th, 2006 11:25 AM
Revision 4 of 4
Helper jbuchberger
Tags ant | builds | Java
Comments 0 comments
if you use the same buildfiles on your local codebase and your continuous integration buildserver, the if-attribute for ant's targets comes in handy...

for this ant buildfile snippet to only create+publish javadoc when executed on the buildserver, the buildserver only has to set the referred system property, e.g. on its startup by using a Java D-option "-Dcontinuous.build=true" ...

ant buildtool website


  <property name="libs"     value="path/to/your/libs" />
  <property name="classes"  value="path/to/your/classes" />
  <property name="sources"  value="path/to/your/sources" />

  <path id="classpath_default">
    <pathelement location="${classes}" />
    <fileset dir="${libs}">
       <include name="**/*.jar"/>
    </fileset>
  </path>

  <!-- copy apidocs to webserver; only, if executed by continuous buildtester, i.e. not for manual user builds -->
  <target name="publish-docs" if="continuous.build" >
    <javadoc source="1.4"
             destdir="path/to/your/webserver/pages/apidocs/fooapi"
             classpathref="classpath_default"
             author="true"
             version="true"
             use="true"
             overview="true"
             windowtitle="YOUR API">

      <packageset dir="${sources}" defaultexcludes="yes">
        <include name="yourpackage/**" />
        <exclude name="yourpackage/**/*TestCase.java"/>
        <exclude name="yourpackage/**/*Test.java"/>
        <exclude name="yourpackage/**/*AbstractTest.java"/>
        <exclude name="yourpackage/**/*Suite.java"/>
      </packageset>
      <doctitle><![CDATA[<h1>YOUR API</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright (c)2006 by YOU...</i>]]></bottom>
      <link href="http://yourserver/apidocs/java_api/" packagelistLoc="/tmp/java"/>
      <link href="http://yourserver/apidocs/foo2/" packagelistLoc="/tmp/foo2"/>
      <link href="http://yourserver/apidocs/foobar/" packagelistLoc="/tmp/foobar"/>
      <link href="http://yourserver/apidocs/barapi/" packagelistLoc="/tmp/barapi"/>
    </javadoc> 
    <touch>
      <fileset dir="path/to/your/webserver/pages/apidocs">
        <include name="fooapi" />
      </fileset>
    </touch>
  </target>

 

Joerg Buchberger

Comments

There are currently no comments for this snippet.

Voting