Tip: Uploading to Google Code

I learned this the hard way: put a version number in your Google Code releases!

I kept receiving an error when I tried to upload my new Jar file.  It was the same 403 error as this person.  The problem is that you can’t overwrite files any more.  Each new download needs to have it’s own unique file name.

So, the easy fix is to include and incrementing version number in the file name.

From Ant, I was able to accomplish the version number is this manner:

  • I created a version.txt to hold a minor number and major number property — saves the version
  • In the destfile parameter of the Jar step, I use the ${major.number} and ${minor.number} properties in the file name.
  • In the release section, I use the propertyfile command to increment the version number

Here is the full Ant Build file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><project default="all" name="Create Runnable Jar for Project ProjectShaphan">    <target name="all" depends="clean,compile,create_run_jar"/>
 <target name="clean">       <delete dir="bin"/>    </target>
 <target name="compile">       <mkdir dir="bin"/>       <javac destdir="bin">          <src path="src"/>          <classpath>             <pathelement path="/home/skp/app/workspaces/pscompare/ProjectJob/demo-bin"/>          	<fileset dir="lib">          		<include name="**/*.jar"/>          	</fileset>          </classpath>       </javac>    </target>
 <target name="create_run_jar">    <!--this part was created by Eclipse Runnable JAR Export Wizard-->    <!--ANT 1.7 is required                                        -->        <property file="./version.txt"/>        <jar destfile="project-shaphan-${major.number}.${minor.number}.jar" filesetmanifest="mergewithoutmain">            <manifest>                <attribute name="Built-By" value="${user.name}"/>                <attribute name="Main-Class" value="com.skp.shaphan.ShaphanApp"/>                <attribute name="Class-Path" value="."/>            </manifest>            <fileset dir="bin"/>            <zipfileset excludes="META-INF/*.SF" src="lib/derby.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/sqljdbc4.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/ojdbc6.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/grouplayout.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/iText-2.1.7.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/iText-rtf-2.1.7.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/iText-rups-2.1.7.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/mysql-connector-java-5.1.7-bin.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/ProjectJob.jar"/>            <zipfileset excludes="META-INF/*.SF" src="lib/jtds-1.2.5.jar"/>        </jar>    </target>
 <target name="release">         <taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpath="lib/ant-googlecode-0.0.2.jar" name="gcupload"/>        <property file="./version.txt"/><gcupload         username="${google.code.username}"         password="${google.code.password}"         projectname="project-shaphan"         filename="project-shaphan-${major.number}.${minor.number}.jar"         targetfilename="project-shaphan-${major.number}.${minor.number}.jar"         summary="Runnable Jar File"        labels="Featured, Jar, OpSys-All" />        <propertyfile file="./version.txt">	   <entry key="minor.number" type="int" operation="+" value="1" pattern="00"/>        </propertyfile>    </target></project>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: