Blog | ant

« ant » Feed

Ebfe6ecd50f96701fabd9ad15aa061c9

A Java hello-world application on Google App Engine (part 2)

2010-11-25 14:25

Write comment

Before you start reading this article I recommend that you take a look at the previous part, so you can understand this one better.
Anyway what we gonna see today is some configuration, to help Ant compiling our helloworld GAE project and deploy it on GAE, you could see it in link and download the whole project i've covered during part 1 and part 2 of this simple tutorial.
First of all, a short notice for people who have tried GAE using Python:
Java is a compiled programming language so you need to compile your source code in favor to use it, but in our case we gonna need a tool to automate building our project, like Apache Ant or just let’s just call it Ant.

Back on track, let me first tell you that Ant will look for a file named build.xml by default.
After that, it’ll do exactly what it was told to do, so let’s edit that helloworld/build.xml file to make things work:

<project>
  <property name="sdk.dir" location="../" />
  <import file="${sdk.dir}/config/user/ant-macros.xml" />
 <path id="project.classpath">
    <pathelement path="war/WEB-INF/classes" />
    <fileset dir="war/WEB-INF/lib">
      <include name="**/*.jar" />
    </fileset>
    <fileset dir="${sdk.dir}/lib">
      <include name="shared/**/*.jar" />
    </fileset>
  </path>
</project>

watch out from this line <property name="sdk.dir" location="Path/To/Your/GAE/SDK" />
to be more safe and less confused while debugging just put the absolute path instead of relative.
Next we gonna need the ant macro, that comes with the SDK, and  what in it exactly is a bunch of  functions-declaration-like, that we gonna need later.

Read more…

6c4a91744a9f857f00ddd8802edb7465

Using 'Ant' the 'batch' way

2010-10-08 10:26

Write comment

Apache Ant is a wonderfull tool for automating software build processes, most of the cases for Java software as it is implemented with Java and requires the VM. Netbeans offers native ability to run projects using Ant, it only requires you to put the build.xml file in the root of your project folder and the targets become right-clickable, simply amazing !

Every project having a build.xml for Ant targets implements these build automation tasks:
  • Build
  • Clean
  • Run
  • Deploy
  • Debug
  • ... etc
And what if i want to create batch-style tasks such as:
  • Deleting some files (maybe cache files or old unused files).
  • Moving/copying files
  • Creating skeleton files or folders (think about a project template, module template ...)
  • Backuping, restoring and even Subversion commands
  • Sending an email
  • Doing an SQL manipulation
  • ... etc ... just anything having no 'direct' relation to software build automation

Read more…

Ebfe6ecd50f96701fabd9ad15aa061c9

A Java hello-world application on Google App Engine (part 1)

2010-10-21 20:22

Write comment

The fact that google is offering us the ability to share its platforms made me looking forward to taste piece of that pie.

So starting from scratch, I began with downloading the Google App Engine java SDK, or let me just call it GAE.

You notices that I mentioned Java specifically, because folks at google loves Python, so they gave it a SDK too, any way, I may cover that next time.

As I'm writing this article, google has released the 1.3.8 version, if you notice while you're in the download page there is a table containing some valuable information, like the release date, download link, size and some important it's called thing checksum, we will come to that later.
So let's open the terminal and try to set it up.

#create our development directories under the current user home
mkdir -p ~/dev/appengine/java/
# change directory to it
cd dev/appengine/java/
#download the app engine SDK
wget -c http://googleappengine.googlecode.com/files/appengine-java-sdk-1.3.8.zip

After you finish downloading the zip file, you should checksum before you can install it, but we won't do it the old fashion way, check this out:

www-browser -source http://code.google.com/appengine/downloads.html | grep $undefinedsha1sum appengine-java-sdk-1.3.8.zip | cut -d' ' -f1) | wc -l

This is actually a bunch of command that will prompt  zero or one as simple as that, but guess what it actually prompted a zero!
So that means that the file we downloaded is not the perfect thing to install.
I believe that I gonna download it again, but before that let me delete it first.

rm appengine-java-sdk-1.3.8.zip

Do the previous commands again, eventually we got "1" as result, now we can proceed.
Assuming that you have java 1.6 installed we go on and extract the downloaded file in the current directory.

unzip appengine-java-sdk-1.3.8.zip
cd appengine-java-sdk-1.3.8

Now we will create our first project using GAE for java.
We actually have a project template waiting for us under demo/new_project_template so we gonna copy the whole thing in our new project that we of course gonna name it "hello world", don't ask me why, because everybody loves it.

mkdir helloworld && cp demos/new_project_template/ helloworld/

Unfortunately we didn't get all the necessary files, because I decided to take this war weaponless with any IDE, to appreciate the victory later, so I will create them all by hand, fallow me:

1st step we will create our business logic in a file that eventually we gonna name it HelloWorld.java that resides under helloworld/src/
please paste the code below:

Read more…

 Nbre d'élements: 3/
3