Thursday, June 21, 2012

BUILD FAILED java.lang.NullPointerException at org.tigris.subversion.svnant.Status.execute(Unknown Source)


<property name="svnUrl" value="svn://svn.sample.com/repo/proj" />
<property name="commonSrc" location="${commonBaseDir}/src"/>

Code snippet 01: Incorrect
<svn username="${svnUser}" password="${svnPwd}">
<status path="${svnUrl}" textStatusProperty="status.text" propStatusProperty="status.prop" revisionProperty="revision"/>
</svn>

Code snippet 02: Correct
<svn username="${svnUser}" password="${svnPwd}">
<status path="${commonBaseDir}" textStatusProperty="​status.text" propStatusProperty="​status.prop" revisionProperty="revision"/>
</svn>


When I had this error, I was referring to the wrong path (svnUrl is the path where remote project source code actually lives). I was able to solved it by pointing to the base project (your check out version of the project). It is required to check out the project (will become base project) before you check the "status". "Status" command  read the status information from the local check out project not from the remote server. (One of the mistakes I did ;-)) 


Here is the correct code snippet to print the latest checked out version.

<project name="MyProject" default="init" basedir=".">
    <description>
        Print latest check out revision
    </description>
 
    <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask">
        <classpath>
            <pathelement location="/opt/svnant/lib/svnant.jar" />
            <pathelement location="/opt/svnant/lib/svnClientAdapter.jar" />
            <pathelement location="/opt/svnant/lib/svnjavahl.jar" />
            <pathelement location="/opt/svnant/lib/svnkit-1.3.1.jar" />
        </classpath>
    </taskdef>
 
    <!-- set global properties for this build -->
<property name="svnUrl" value="svn://svn.sample.com/opt/repos/proj" />
    <property name="svnUser" value="" />
    <property name="svnPwd" value="" />
    <property name="projectDir" value="my_project" />
    <property name="javac" value="/opt/java/bin/javac" />
    <property name="tomcatShared" value="/opt/tomcat/shared/lib" />
    <property name="webapps" value="/opt/tomcat/webapps" />

  <target name="init">
    <property name="commonBaseDir" value="${projectDir}/common" />
    <property name="commonSrc" location="${commonBaseDir}/src"/>
    <property name="propTest"  location="propTest.mimeType"/>
    <property name="revision"  location="revisionrevisionrevision"/>

 <svn username="${svnUser}" password="${svnPwd}">
<checkout url="${svnUrl}/Common2/branches/SKY-301" destPath="${commonBaseDir}" />
 </svn>

    <echo message="-------------------------S T A T U S--------------------------------" />
 
<svn username="${svnUser}" password="${svnPwd}">
<status path="${commonBaseDir}" textStatusProperty="​status.text" propStatusProperty="​status.prop" revisionProperty="revision"/>
</svn>

    <echo message="${revision}" />
    <!--  Write to a text file-->
    <echo file="output.txt" append="true">Revision:${revision}</echo>
  </target>
</project>

Reference: 
    1. svn.html file in the svnant distribution
    2. http://ant.apache.org/manual/using.html
    3. http://ant.apache.org/manual/Tasks/property.html
Reference for Issues: 
    4. http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=605389
    5. http://svn.haxx.se/subusers/archive-2005-11/0119.shtml

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home