Reduce cut and paste waste was: Here is my Centipede scepticism

Nick Chalko <[email protected]>
Newsgroups gmane.comp.krysalis.user
Message-ID <[email protected]>
see 
http://nick.chalko.com/cgi-bin/blosxom.cgi/2003/06/05#IsCentipedeTryingToSolveANonProblem
Mats Henricson wrote 
<http://sourceforge.net/mailarchive/message.php?msg_id=5176132>:

    I think Centipede is fundamentally wrong in two ways:
    1. It is trying to solve something that isn't a problem.
    To me, at least, ant is liberatingly simple. I would never dream of
    extending a hierarchy of messy makefiles, but ant is so simple. The
    ant documentation is pretty good. I have added a fair amount of
    standard and custom targets, and only in a few cases have I had
    problems. 

Centipede is ant. Just a handfull of custom targets, tasks and 
properties. But the magic is you don't have to cut-and-paste the targets 
into every project you build. If you want Javadoc, just <importcent 
name="java"/> and run cent javadoc

Mats goes on to say

    2. It is trying to automate/simplify something that is always going
    to have to be customized by hand.
    Take my JavaDoc ant task, as an example. It contains a LOT of things
    that are special to me and my project. I believe there is no way you
    can make it simpler than it already is. 

  <target name="javadoc" depends="compile" description="Create Javadoc API documentation">
    <mkdir          dir="${dist.home}/docs/api"/>
    <javadoc sourcepath="${src.home}"
                destdir="${dist.home}/docs/api"
           packagenames="*"
                 author="true"
                version="true"
                    use="true"
              protected="true"
             splitindex="true"
            windowtitle="UPL code">
      <doctitle>UPL code</doctitle>
      <header>UPL code</header>
      <bottom>< ![CDATA[<i>Copyright &#169; 2003 Mats Henricson. All Rights Reserved.</i>] ]></bottom>
      <link href="http://java.sun.com/j2se/1.3/docs/api/"/>
      <link href="http://java.sun.com/products/servlet/2.2/javadoc/"/>
      <link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
      <link href="http://java.sun.com/xml/docs/api/"/>
      <link href="http://www.junit.org/junit/javadoc/3.8.1/"/>
      <link href="http://jakarta.apache.org/log4j/docs/api/"/>
      <link href="http://xml.apache.org/xerces2-j/javadocs/api/"/>
      <link href="http://xml.apache.org/xalan-j/apidocs/"/>
      <link href="http://tyrex.exolab.org/api/"/>
      <link href="http://hibernate.bluemars.net/hib_docs/api/"/>
      <classpath refid="compile.classpath"/>
    </javadoc>
  </target>

I agree often you will want to do your own thing. No problem use the 
Javadoc target you just built. But instead of cut and pasting it 
everywhere. Make a cent out of it and share it between your projects. I 
have several custom cents I use at work.

But perhaps the centipede Javadoc target is good enough. Lets take a 
look. Here is the Javadoc target from java.cent 
<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/krysalis/krysalis-cents/java/src/xbuild.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup>

 <!-- =================================================================== -->
 <!-- Creates the API documentation                                       -->
 <!-- =================================================================== -->
  <target name="javadocs"
      description="Generates the API documentation in javadoc format">
      
      <if>
         <not> <isset property="java.cent.javadoc.overview"/></not>
         <then>
              <style in="module.xml"
                     out="${java.cent.work.dir}/javadocs/overview.html"
                     style="${java.cent.dir}/resources/stylesheets/module2overview.xsl">
              </style>
              <property name="java.cent.javadoc.overview" 
                        value="${java.cent.work.dir}/javadocs/overview.html"/>	
         </then>	
	</if>

      
    <mkdir dir="${java.cent.javadocs.dir}"/>
    <javadoc packagenames="${jxpath:/references/module.xml/root/module/project[@name=$project.name]/package}.*"
             sourcepath="${project.src.dir}"
             destdir="${java.cent.javadocs.dir}"
             author="true"
             version="true"
             use="true"
             failonerror="true"
             noindex="true"
             overview="${java.cent.javadoc.overview}"
             source= "${build.compiler.source}"
             group="${centipede.tools.java.cent.javadocs.group}"
             windowtitle="${project.name} ${project.version.package-version}  API"
             stylesheetfile="${java.cent.dir}/resources/stylesheets/javadoc.css">
 
     <classpath>
       <path refid="${project.name}.classpath"/> 
     </classpath>

    <doctitle>${project.name} ${project.version.package-version}  API</doctitle>
    <bottom><![CDATA[<center><i>Copyright &#169; ${YEAR} ${xgump.module.vendor}. 
    All Rights Reserved.</i></center>]]></bottom>
    <header><![CDATA[${project.name} ${project.version.package-version}]]></header>
    <footer><![CDATA[${project.name} ${project.version.package-version}]]></footer>
    <tag name="todo" scope="all" description="To do:" />
    <link offline="true" 
          href="http://java.sun.com/products/jdk/1.4/docs/api/" 
          packagelistLoc="${java.cent.dir}/resources/jdk14-project.version.package-list"/>
      
    </javadoc>
  </target>

This target does a pretty good job of producing generic Javadocs. Take a 
look at the Javadocs for the Krysalis Sample 
<http://www.krysalis.org/templates/krysalis-project/javadocs/index.html> 
project. Note the automatic version labeling. We also optionally create 
a simple overview.html from the infomation in the gump module.xml file. 
The main deficiency I see is, we only link to jdk 1.4 and jdk 1.4 is 
hardcoded. Looks like something we should fix. Perhaps you could supply 
a patch. ;-)

I got tired of cutting and pasting the same Javadoc target into every 
build.xml I wrote. I never kept them all uptodate. It was a giant 
headache. So I joined the Krysalis <http://krysalis.org> team. I have 
only worked on one Javadoc target since then. The one in java.cent 
<http://www.krysalis.org/cents/cents/java/index.html>.
smime.p7s (application/x-pkcs7-signature, 3.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.