ant on the wire using ftp, mail, svn, and vss tasks (and a bonus task)

34
ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Upload: jasmine-thorington

Post on 01-Apr-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

ANT on the Wire

Using FTP, Mail, SVN, and VSS tasks

(and a bonus task)

Page 2: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Your host… Marc Esher

CF since 2000 Java since 2001 Contributor to MXUnit unit testing

framework for CF NOT an ANT guru Plug alert: come see us talk about

MXUnit and unit testing at Webmaniacs in May!

Page 3: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

What this is not

A high-level ANT overview A cursory look at a bunch of neat

features A crash course in basic ANT The last word on any of these topics

Page 4: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

What this is

A “how-to” session; as such, it will be slightly slower-paced than most meetups

A solid look at a few really useful features

Page 5: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Takeaways Know where to go to download all dependencies for these

ANT tasks Know how to install all dependencies and configure ANT

to run these tasks Run these tasks from Eclipse or command line Learn by example how to use these tasks for common

operations Learn how to read the ANT documentation for more info

on these tasks Not be afraid to try any of this on your own Familiar enough with these tasks that a more complicated

build file is not overwhelming

Page 6: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Tasks we’ll cover

Email FTP SVN (for accessing subversion

repository) VSS (demo how to configure and what

the task looks like) Version numbering using propertyfile

Page 7: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Beginning with the End

Putting all these tasks together to:

Check out version.properties file, increment version, use version for zip file name, check it back in

Package app into zip (not covered in pres.) Run unit tests and email results Upload zip file to google code (not covered in pres.) FTP version.properties file to website Re-init application so it reads that file FTP test results to website

Page 8: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo Build File

Page 9: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Let’s go: The ANT manual http://ant.apache.org/manual/index.html 3 key sections:

• Concepts and Types – explains all about directory concepts (**/ vs */, filesets, etc) and tons of other stuff

• Core tasks – all the built-in tasks you can usually use out of the box (with some exceptions)

• Optional tasks – stuff you probably have but also are more likely to require downloading additional dependencies

NOTE: tasks requiring dependencies let you know they require dependencies

Page 10: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Our dependencies FTP needs: commons-oro and commons-net

• http://commons.apache.org/downloads/download_net.cgi• http://jakarta.apache.org/site/downloads/downloads_oro.cgi

Mail needs: javamail and activation framework• http://java.sun.com/products/javamail/downloads/index.html• http://java.sun.com/products/javabeans/jaf/downloads/index.html

SVN needs: svnant task• JavaHL: easiest to install Subclipse plugin through Eclipse update site (even if you disable the plugin as soon as you

install it!)

• http://subclipse.tigris.org/update_1.0.x (we’ll use this in eclipse)• http://subclipse.tigris.org/svnant.html

VSS needs• No jars, but you do need vss client installed on your machine

Eclipse users: Once these are added to your file system, you need to tell ANT about them in Eclipse

Page 11: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Setting up ANT

Assumes you have Eclipse installed If not, you can download ANT separately

and do all of this stuff without Eclipse Good idea to know how to use ANT

outside of eclipse – makes automation easier

For this demonstration, I’ll be using ANT 1.7 that is bundled with Eclipse 3.3

Page 12: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Cont.

Find ANT bin directory. For Eclipse, this is in %eclipse_root%\plugins\org.apache.ant_1.7….\bin

Add ANT bin directory to system environment “path” variable

Run ant –version to get some basic information

Page 13: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo ANT at command line

Page 14: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Cont.

If you get a “cannot find tools.jar” message, it means ANT’s using the JRE and NOT the JDK.

Only important if you need a compiler (or get annoyed by the tools.jar message)

Install the JDK (if you don’t have it) http://java.sun.com/javase/downloads/index.jsp

Find your JDK’s bin path. Copy and replace the existing java bin directory with the new bin directory in your environment PATH variable

Page 15: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo adding JDK

Page 16: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Our build file

Simple build file with test targets• init

• testEmail

• testFTP

• testSVN

• testVSS

• testVersion

• HINT: even for the final build file in your projects, keep these test targets… they’re great for confirming that new folks working on the project are correctly configured

Page 17: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

testEmail (core task)

1. Run and confirm it fails2. Add dependencies to ANT lib dir

• http://java.sun.com/products/javamail/downloads/index.html• http://java.sun.com/products/javabeans/jaf/downloads/index.html

3. Run and confirm it fails… no properties set up

4. (switch to real properties file)5. Run in Eclipse6. Run at command line

Page 18: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo testEmail

Page 19: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Another Email example

MXUnit build file• runTests

Page 20: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Learn more about mail task

http://ant.apache.org/manual/index.html Ant tasks – Core Tasks – Mail You can do all the normal mail stuff You can attach files to messages Cool tip: use the messagefile attribute for

easier-to-manage html emails

Page 21: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

testFTP (optional task)

1. Run and confirm it fails

2. Add dependencies to ANT lib dir• http://commons.apache.org/downloads/download_net.cgi• http://jakarta.apache.org/site/downloads/downloads_oro.cgi

3. Run and confirm it fails (no properties)

4. Switch to real properties file

5. Run in Eclipse

6. Run at command line

Page 22: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo testFTP

Page 23: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

A few more FTP examples

MXUnit build file• updatewebsite

• publishTestResults

Page 24: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Learn more about FTP task

http://ant.apache.org/manual/index.html Ant tasks – Optional Tasks – FTP You can use this to synchronize using

the various “time…” attributes You can control the target directory for

put operations

Page 25: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

testSVN (the trickiest)

1. Run and confirm it fails2. Install plugin using Update Site

• http://subclipse.tigris.org/update_1.0.x

3. Add dependencies to ANT lib dir• Get at http://subclipse.tigris.org/svnant.html

4. In Eclipse plugins directory, navigate to the org.tigris.subversion.javahl.win32 directory. Copy that path.

5. Paste that path into your system’s PATH environment variable

6. RESTART YOUR COMPUTER

Page 26: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

testSVN, cont.

7. Run and confirm it fails

8. Add taskdef

9. Run in eclipse

10. Run in command line

Page 27: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo testSVN

Page 28: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Another SVN example

MXUnit build file• incrementVersion

• tagVersion

Page 29: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

testVSS (optional tasks… I’ll be showing vssget)

1. Run and confirm it fails

2. Add vss path to environment PATH variable

e.g. C:\Program Files\Microsoft Visual Studio\VSS\win32

3. Run and imagine it succeeded

Page 30: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo testVSS

Also show the entries from GetLatest.xml

Page 31: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Learn more about VSS tasks

http://ant.apache.org/manual/index.html Ant tasks – Optional Tasks – Microsoft Visual

SourceSafe Tasks This is a suite of tests… vssget, vsslabel,

vsscheckin, vsscheckout, etc For vssget, I advise using failonerror=“false”,

writablefiles=“skip”, filetimestamp=“updated” Vsslabel is similar to tagging in SVN

Page 32: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Bonus: propertyfile for versioning

propertyfile task writes/updates a properties file

You can perform increments on properties

You then read those properties using the property task with the file attribute

Perfect for versioning

Page 33: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Demo testVersion

Eclipse Command line

See version number increase Note we didn’t manually create the file Add constructs like “rc” notations

Page 34: ANT on the Wire Using FTP, Mail, SVN, and VSS tasks (and a bonus task)

Q & A