DOC PREVIEW
CALTECH CS 11 - Advanced Java

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS11 Advanced Java Winter 2011 2012 Lecture 4 Today s Topics n n No real programming topics today Project management tools q q n Automating the build process Source code management tools This week s focus q q q Get your project into better structural shape Automate your project s build process Get your sources into a version control system The Build Process n We have multiple steps for our project now q q q n This is a lot of work q n Compile our code and our unit test code Run javadoc to generate API documentation Run unit tests and check the results Automate this process to make it faster and easier Current structure is also pretty messy q q Program code and test code are in same directory Libraries and generated class files in there too Apache Ant n Ant is a platform independent build tool q q q Written entirely in Java Takes a build xml file describing build process Pluggable architecture with many build tasks n n n n n n n Compile Java sources Run javadoc Run JUnit or TestNG test suites and generate a report Perform code generation steps e g for J2EE projects Move copy delete files create remove directories Send e mails or other notifications Interact with source code repositories Example build xml File project name myproject default compile basedir Global properties used in build property name srcDir location src property name buildDir location build property name buildClassesDir location buildDir classes Use Ant properties to specify config values in one place target name init Initialization target tstamp mkdir dir buildDir target target name compile depends init description Build the project sources mkdir dir buildClassesDir javac destdir buildClassesDir Targets can specify their dependencies src path srcDir javac They specify a series target of tasks to complete project Running Ant n n Ant executable is called ant Just type ant by itself to build default target q n build xml specifies the default build target Specify target s to run at command line ant clean test doc n Can also specify other options q q q Verbose output Set Java properties Many more v or verbose DpropName value Ant Properties n Properties are simple name value pairs q q q q n Both name and value are strings Can be specified at top of project file Can be specified inside a build task Use property s value by wrapping it in propName Example property name buildDir value build property name codegenDir value buildDir codegen n Properties can be set once q q If specified again elsewhere it is silently ignored run ant verbose to see details of when properties are set and when they are set multiple times Ant Properties 2 n A nifty example target name debug description Set up for debug build property name java debug value on property name java opt value off target target name release description Set up release build property name java debug value off property name java opt value on target target name compile depends debug javac debug java debug optimize java opt target q q By default compilation will use debug settings To override at command line do this ant release compile Ant Build Targets n target tags specify the build targets q Each target has a name target name compile q Targets can also be given descriptions target name compile description Compile the sources q Names starting with a hyphen cannot be specified on command line internal use only tasks target name init Target Dependencies n Targets can also have dependencies q q Ant performs dependency analysis at build time Executes all required tasks in the proper order target target target target q q name init name clean depends init name compile depends init name test depends compile You run ant test Ant executes init compile and test targets in that order Project Help n Don t know what targets are available ant projecthelp q q n Lists all build targets that have descriptions Also prints out any description you specify at top of build xml file Example project name paint default compile basedir description A simple program for drawing images description project Project Directory Structure n So far everything has been in one directory q n A much better approach Use different directories q q q q n Source code stays in its own directory structure Generated files class files etc go somewhere else Protects sources from overwriting during build process Makes build cleanup easy Just blow away the build dir Similarly separate test sources from project sources q n Project sources test sources class files Shouldn t be part of final package so keep them separate Any other resources docs images etc also go in their own directories Example Project Structure n n n n n n src lib test res doc build q q q q q q Project sources Libraries that your project requires Test source code Resources images grammars config Design documents manual not javadocs Generated results go here codegen Generated Java sources if any classes class files generated by javac javadoc Generated API documentation tests Compiled test classes from javac results Output logs from running test suite Generated jar file s can stay in build directory Ant and Project Structure n Using our Ant properties specify relevant directories at top of build xml file property name srcDir location src property name buildDir location build property name buildClassesDir location buildDir classes q n Use earlier Ant properties to specify subdirectory paths In Ant targets refer to relevant directories using properties target name compile depends debug mkdir dir buildClassesDir javac destdir buildClassesDir classpathref libs path src path srcDir javac target Common Concepts and Types n n Ant has several concepts that most tasks use FileSet a group of files within a directory q Specified with fileset element n q Very sophisticated path matching capabilities n n Base directory of FileSet typically specified with dir attribute Include or exclude files that match specific patterns A very simple example q A file set of all test sources except those in the subpackage foo where the sources aren t ready yet fileset dir testSrcDir include name Test java exclude name foo fileset q wildcard matches zero or more directory levels Many Ant tasks can function as a FileSet as well Common Concepts and Types 2 n Path Like Structures q q n A mechanism for constructing sophisticated classpaths and other sets of paths Frequently used on tasks that compile or run Java code Example classpaths classpath pathelement location libDir foo jar pathelement


View Full Document

CALTECH CS 11 - Advanced Java

Download Advanced Java
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Advanced Java and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Advanced Java 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?