First things first, we need a home:
$ mkdir agilephil
$ cd agilephil
$ git init
Initialized empty Git repository in /Users/phil/agilephil/.git/
Okay, one repository, created! No immediate plans to put onto github, though that's really more to do with the fact that I have nobody asking for it. Next, a branching model. The one proposed by Vincent Driessen at nvie.com is nicely explained, so I'll be aiming to follow this one.
$ cat <<EOF > README
This is a CRM-type of application I've created to learn Scala and Lift. It is super-basic and won't win any awards. Probably.
Follow along with me at agilephil.blogger.com.
EOF
$ git add README
$ git commit -m 'initial project version'
$ git checkout -b develop master
Switched to a new branch 'develop'
$ git checkout -b features/MultiUser1 develop
Switched to a new branch 'features/MultiUser1'
Creating the Project
So now, we're ready to rock and roll. We have a features branch called MultiUser1 into which we'll complete our first user story. The only trick: I need a project structure that Lift will like. To do this, there are a number of maven archetypes available as described on liftweb's wiki page Using Maven. I think I'll start out with "basic":
$ mvn archetype:generate \
-DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-basic_2.9.1 \
-DarchetypeVersion=2.4-M4 \
-DarchetypeRepository=http://scala-tools.org/repo-releases \
-DremoteRepositories=http://scala-tools.org/repo-releases \
-DgroupId=org.philgra \
-DartifactId=contactdb \
-Dversion=0.1
$ git add contactdb
$ git commit -m 'creating initial project structure from basic archetype'
The Using Maven page also describes a pom.xml file (the maven build metadata), but I'm not entirely sure why, as the archetype included one of these. Needless to say, lesson learned: ignore that incomplete-looking pom.xml and stick with the one that came with the archetype.
Starting the Project
A quick test that it works, as allegedly we should have a working application:
$ cd contactdb
$ mvn jetty:run
And browse to http://localhost:8080 ... presto! Well, not so "presto"... maven resolved a TON of dependencies and spent the better part of 5 minutes downloading bits (my 3 Mbps "broadband" connection is stellar).
Curiously, I note a number of links on the menu, including "Login" and "Sign up". Perhaps my story has already been written for me!
Stopping jetty, and then checking out a few new additions to my project folder:
# On branch features/MultiUser1
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# lift_proto.db.h2.db
# lift_proto.db.trace.db
# target/
So, "target" is the compiled code and it seems strange to track anything there. Furthermore, I don't think I care to keep these .db files in my repository (they are presumably the underlying database...I'll figure out how to get that onto a MySQL server later).
A .gitignore file will come in handy:
$ cat <<EOF > .gitignore
/target/
/*.db
EOF
$ git add .gitignore
$ git commit -m 'ignore target and database files'
Well, that's me done then for the night. The next task will be to work out how, exactly, test-driven development works in Lift/Scala. No friends, we do not write the application first...we write our tests first, and then we fix our broken tests.
No comments:
Post a Comment