You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Brad Neuberg <bk...@columbia.edu> on 2004/10/21 18:42:02 UTC

[feedparser] Patch to Improve Build System

The following is a patch for the feed parser's build system.  It does the 
following:

* Changes build.xml to use a build.properties file for the following two 
properties:
     * feedparser.home - The location of the feed parser installation; 
defaults to ".". Needed so that we can update our unit tests to run 
cross-platform (they used to only run on Kevins Linux box :)
     * ext.lib.path - The location of external JARs needed by the feed 
parser but which are not included, such as junit.jar. The location to these 
used to be hard coded in the build.xml file, which is nasty and doesn't 
work cross-platform.
* Added help to the build.xml file - essentially this is an ant task, 
'help', that provides information on the available tasks and how to 
configure your system to get the feed parser to work.
* Added ant-contrib.jar to the lib directory and wire it in. Ant-contrib is 
a nice collection of advanced ant tags, such as an if tag, that can help to 
make more maintainable ant files. It is opensource.
* Cleaned up the unit testing targets. Right now we have several testing 
targets that aren't rationalized. I've created a single task, "test", that 
by default runs every available task. This task allows an optional 
argument, "test.only.local", that will only test the local tasks and not 
the remote ones so that they run faster (Kevin asked for this).

To make this patch work you will also need to add ant-contrib-0.6.jar to 
the lib directory, since I can't attach JARs to emails for this list:

<http://p2psockets.jxta.org/source/browse/p2psockets/lib/ant-contrib-0.6.jar?rev=1.1>http://p2psockets.jxta.org/source/browse/p2psockets/lib/ant-contrib-0.6.jar?rev=1.1 


Here is the patch:

Index build.xml
===================================================================
RCS file /home/cvspublic/jakarta-commons-sandbox/feedparser/build.xml,v
retrieving revision 1.9
diff -u -B -r1.9 build.xml
--- build.xml   18 Oct 2004 001223 -0000        1.9
+++ build.xml   21 Oct 2004 011158 -0000
@@ -1,6 +1,10 @@
  <?xml version="1.0" encoding="ISO-8859-1"?>

-<project name="feedparser" default="jakarta-feedparser.jar" basedir=".">
+<project name="feedparser" default="help" basedir=".">
+
+    <property environment="env"/>
+
+    <property file="build.properties"/>

      <property name="project" value="feedparser"/>

@@ -28,36 +32,76 @@

          </fileset>

-        <!--
-        <fileset dir="c/usr/local/ksa/lib">
+        <fileset dir="${ext.lib.path}">

               <include name="*.jar"/>

          </fileset>
-         -->
+
+        <fileset dir="${ant.home}/lib">
+            <include name="*.jar"/>
+        </fileset>

      </path>

+    <!-- ant-contrib tasks path http//ant-contrib.sourceforge.net;
+         this includes custom tags, such as an 'if' tag -->
+    <property name="ant-contrib.jar" value="./lib/ant-contrib-0.6.jar"/>
+    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
+        <classpath>
+            <pathelement location="${ant-contrib.jar}"/>
+        </classpath>
+    </taskdef>
+
+    <taskdef name="junit"
+ 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
+
      <target name="compile">

          <mkdir dir="compile"/>

-        <javac srcdir="src/java/"
+        <javac srcdir="src/java/"
                 classpathref="project.classpath"
-               destdir="compile"
+               destdir="compile"
                 debug="true"/>

      </target>

+    <target name="clean">
+        <delete dir="compile"/>
+    </target>
+
+    <target name="clobber">
+        <delete dir="compile"/>
+    </target>
+
+    <target name="jakarta-feedparser.jar" depends="compile">
+
+        <mkdir dir="lib"/>
+
+        <jar compress="yes" jarfile="lib/jakarta-feedparser.jar">
+
+            <fileset dir="compile">
+
+                <include name="org/**"/>
+                <include name="feedparser/**"/>
+                <include name="*.class"/>
+
+            </fileset>
+
+        </jar>
+
+    </target>
+
      <target name="run-example" description="Runs the example feed parser 
class"
              depends="jakarta-feedparser.jar">
         <java classpathref="project.classpath"
               classname="org.apache.commons.feedparser.example.HelloFeedParser"
               fork="true"
               failonerror="true">
-       </java>
+       </java>
      </target>
-
+
      <target name="debug-feed" description="Debugs a feed"
              depends="jakarta-feedparser.jar">
         <java classpathref="project.classpath"
@@ -65,77 +109,50 @@
               fork="true"
               failonerror="true">
            <arg value="${feed-url}"/>
-       </java>
+       </java>
      </target>
-
+
      <target name="test-autodiscover" description="Runs the testing class 
for autodiscovery"
              depends="jakarta-feedparser.jar">

         <java classpathref="project.classpath"
-             classname="org.apache.commons.feedparser.locate.FeedLocator"
+             classname="org.apache.commons.feedparser.locate.TestFeedLocator"
               fork="true"
               failonerror="true">
-       </java>
+            <sysproperty key="feedparser.home" value="${feedparser.home}"/>
+       </java>

      </target>
-
-       <target name="test-probing" description="Runs the testing class for 
aggresive probing"
-                   depends="jakarta-feedparser.jar">
+
+    <target name="test-probing" description="Runs the testing class for 
aggresive probing"
+                depends="jakarta-feedparser.jar">

         <java classpathref="project.classpath"
               classname="org.apache.commons.feedparser.test.TestProbeLocator"
               fork="true"
               failonerror="true">
-       </java>
-
-    </target>
-
-    <target name="clean">
-        <delete dir="compile"/>
-    </target>
-
-    <target name="jakarta-feedparser.jar" depends="compile">
-
-        <mkdir dir="lib"/>
-
-        <jar compress="yes" jarfile="lib/jakarta-feedparser.jar">
-
-            <fileset dir="compile">
-
-                <include name="org/**"/>
-                <include name="feedparser/**"/>
-                <include name="*.class"/>
-
-            </fileset>
-
-        </jar>
+          <sysproperty key="feedparser.home" value="${feedparser.home}"/>
+       </java>

      </target>

      <target name="test" depends="jakarta-feedparser.jar" description="Run 
junit tests.">
-
-        <taskdef name="junit" 
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
-
          <junit printsummary="withOutAndErr"
                 fork="true"
                 filtertrace="true"
-               haltonfailure="true">
-
+               haltonfailure="true"
+               haltonerror="true">
+            <sysproperty key="feedparser.home" value="${feedparser.home}"/>
              <classpath refid="project.classpath"/>
-
              <formatter type="plain" usefile="false"/>
-
              <test name="org.apache.commons.feedparser.test.TestFeedFilter"/>
-            <test name="org.apache.commons.feedparser.test.TestFeedLocator"/>
-
-            <test name="org.apache.commons.feedparser.test.TestProbeLocator"/>
              <test name="org.apache.commons.feedparser.test.TestAtom"/>
              <test 
name="org.apache.commons.feedparser.test.TestFeedParserUTF8"/>
-
+            <test name="org.apache.commons.feedparser.test.TestFeedLocator"
+                  unless="test.only.local"/>
+            <test name="org.apache.commons.feedparser.test.TestProbeLocator"
+                  unless="test.only.local"/>
          </junit>
-
-        <echo message="tests done"/>
-
      </target>

      <target name="javadoc">
@@ -156,7 +173,7 @@
      </target>

      <!--<target name="docs">-->
-
+
          <!-- anakia config borrowed from Lucene -->

          <!--<taskdef name="anakia"
@@ -167,7 +184,7 @@

          <anakia basedir="xdocs"
                  destdir="docs/"
-                extension=".html"
+                extension=".html"
                  style="./site.vsl"
                  projectFile="stylesheets/project.xml"
                  excludes="**/stylesheets/** empty.xml"
@@ -177,28 +194,69 @@

      </target>-->

-    <target name="test-feeds" description=""
-            depends="jakarta-feedparser.jar">
-
-        <!-- this test just performs raw local feed parsing -->
+    <target name="help">
+        <echo message="U S A G E "/>
+        <echo message=""/>
+
+        <echo message="[clean,clobber]"/>
+        <echo message="Delete old builds"/>
+        <echo message=""/>
+
+        <echo message="[compile]"/>
+        <echo message="Compiles the source tree"/>
+        <echo message=""/>
+
+        <echo message="[jakarta-feedparser.jar]"/>
+        <echo message="Generates a JAR file for the feed parser"/>
+        <echo message=""/>
+
+        <echo message="[run-example]"/>
+        <echo message="Runs the example feed parser class"/>
+        <echo message=""/>
+
+        <echo message="[debug-feed]"/>
+        <echo message="Debugs a single feed by attempting to retrieve it."/>
+        <echo message="To use"/>
+        <echo message="ant debug-feed -Dfeed-url=http//www.someblog.com"/>
+        <echo message=""/>
+
+        <echo message="[test]"/>
+        <echo message="Runs all the JUnit testing classes"/>
+        <echo message="This target has an optional value.  If run as 
follows"/>
+        <echo message="ant test -Dtest.only.local=true"/>
+        <echo message="Then any tests that involve network traffic are 
_not_ run. "/>
+        <echo message="This is useful because the remote tests can take a 
long time "/>
+        <echo message="to run.  By default we run remote tests."/>
+        <echo message=""/>
+
+        <echo message="[test-autodiscover]"/>
+        <echo message="Runs the testing class for autodiscovery"/>
+        <echo message=""/>
+
+        <echo message="[test-probing]"/>
+        <echo message="Runs the testing class for aggresive probing"/>
+        <echo message=""/>
+
+        <echo message="[javadoc]"/>
+        <echo message="Generates JavaDoc for this project"/>
+        <echo message=""/>
+        <echo message=""/>
+
+        <echo message="General information"/>
+        <echo message="A file named 'build.properties' exists in this"/>
+        <echo message="directory that can be used to control the build 
process."/>
+        <echo message="The following attributes are available"/>
+        <echo message=""/>
+        <echo message="feedparser.home"/>
+        <echo message="The full path to where the Jakarta Feed Parser is 
installed,"/>
+        <echo message="such as 'c/jakarta/feedparser'; use forward slashes 
instead of"/>
+        <echo message="backslashes on Windows."/>
+        <echo message=""/>
+        <echo message="ext.lib.path"/>
+        <echo message="The file path location to where all of our external "/>
+        <echo message="JARs are located that are not bundled with the "/>
+        <echo message="Jakarta Feed Parser, such as junit.jar."/>

-        <junit printsummary="withOutAndErr"
-               fork="true"
-               filtertrace="true"
-               haltonfailure="true">
-
-            <classpath refid="project.classpath"/>
-
-            <formatter type="plain" usefile="false"/>
-
-            <test name="org.apache.commons.feedparser.test.TestFeedFilter"/>
-            <test name="org.apache.commons.feedparser.test.TestAtom"/>
-
-            <!-- FIXME make sure this uses tests -->
-            <test 
name="org.apache.commons.feedparser.test.TestFeedParserUTF8"/>
-
-        </junit>
-
-    </target>
+      </target>

  </project>
Index build.properties
===================================================================
RCS file /home/cvspublic/jakarta-commons-sandbox/feedparser/build.properties,v
retrieving revision 1.1
diff -u -B -r1.1 build.properties
--- build.properties    21 Oct 2004 010704 -0000        1.1
+++ build.properties    21 Oct 2004 011158 -0000
@@ -0,0 +1,8 @@
+<!-- The full path to where the Jakarta Feed Parser is installed,
+        such as "c/jakarta/feedparser"; use forward slashes instead of
+        backslashes on Windows. -->
+feedparser.home=c/feedparser
+
+<!-- The file path location to where all of our external JARs are located
+     that are not bundled with the Jakarta Feed Parser, such as junit.jar. 
--%>
+ext.lib.path=c/usr/local/ksa/lib




Brad Neuberg, bkn3@columbia.edu
Senior Software Engineer, Rojo Networks
Weblog: http://www.codinginparadise.org

=====================================================================

Check out Rojo, an RSS and Atom news aggregator that I work on.  Visit 
http://rojo.com for more info. Feel free to ask me for an invite!

Rojo is Hiring!  If you're interested in RSS, Weblogs, Social Networking, 
Java, Open Source, etc... then come work with us at Rojo.  If you recommend 
someone and we hire them you'll get a free iPod!  See 
http://www.rojonetworks.com/JobsAtRojo.html.