Software Development Tools

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Software Development Tools COMP220/COMP285 Seb Coope Ant and XML: Getting Started These slides are mainly based on “Java Development with Ant” - E. Hatcher.
ANT: Another Nice Tool Ali Beyad October 1, 2003.
ANT – Another Neat Tool Representation and Management of Data on the Internet.
ANT: Another Nice Tool Ali Beyad October 1, 2003.
Object-Oriented Enterprise Application Development Tomcat 3.2 Configuration Last Updated: 03/30/2001.
1 Ant – Another Neat Tool Representation and Management of Data on the Internet.
© S Ramakrishnan1 Systems V & V, Quality and Standards Dr Sita Ramakrishnan School CSSE Monash University.
DT211/3 Internet Application Development
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Introduction to Java.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Software Development Tools COMP220 Seb Coope Week 8 Lecture 1 Ant, Testing and JUnit (2) These slides are mainly based on “Java Development with Ant” -
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
Ch 21 Command Syntax Using the DIR Command with Parameters and Wildcards.
Apache Ant Java-Based Build Tool. Making your builds boring… Building projects should be easy and standardized. You should not be spending a substantial.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
The Basics of Javadoc Presented By: Wes Toland. Outline  Overview  Background  Environment  Features Javadoc Comment Format Javadoc Program HTML API.
Ant Build Tools.  Creating a product from source may take several steps: Compile Link Copy files to various directories Remove intermediate files Generate.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
Javadoc: Advanced Features & Limitations Presented By: Wes Toland.
Ant Presentation by: Bart Taylor. What is Ant? The simple definition: A Java-based build tool The Official Definition: “Apache Ant is a Java-based build.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
Javadoc Dwight Deugo Nesa Matic
Chapter 3 Understanding Ant datatypes and properties.
Software Development COMP220/COMP285 Seb Coope Introducing Ant These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran.
Chapter 1 Introducing Ant. What is ant? Ant is a build tool  Automate the tasks of compiling code, running test, and packaging the results for redistribution.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Using Ant in Eclipse Dwight Deugo Nesa Matic
Software Development Tools COMP220 Seb Coope Ant: Datatypes and Properties These slides are mainly based on “Java Development with Ant” - E. Hatcher &
Software Development Tools COMP220 Seb Coope More Ant Features These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran.
Software Development COMP220 Seb Coope Ant: Structured Build These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran. Manning.
Software Development Tools COMP220 Seb Coope Ant: Datatypes and Properties These slides are mainly based on “Java Development with Ant” - E. Hatcher &
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
An Introduction to Ant. What is Ant? How do you use it? Why would you want to?
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Software Development Tools
Chapter 2: The Visual Studio .NET Development Environment
Unit 4 Representing Web Data: XML
LOCO Extract – Transform - Load
COMP220/COMP285 Seb Coope Ant: Structured Build
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Command Syntax Chapter 2 Using the DIR Command with
CMPE 152: Compiler Design ANTLR 4 and C++
JAR Files Objectives: 1. Archiving and Packaging Java Code
Instructor: Prasun Dewan (FB 150,
Chapter 7 Representing Web Data: XML
Operation System Program 4
Lecture 22 Inheritance Richard Gesick.
How to Run a Java Program
How to Run a Java Program
CPE 528: Lecture #3 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
Applying OO Concepts Using Java
Stata Basic Course Lab 2.
(Computer fundamental Lab)
Object Oriented Programming in java
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Introducing JavaScript
Running a Java Program using Blue Jay.
SPL – PS1 Introduction to C++.
Introduction to Python
Presentation transcript:

Software Development Tools COMP220 Seb Coope Ant: Datatypes and Properties These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran. Manning Publications, 2003

Ant Datatypes and Properties Now, after getting started in previous lectures, we will consider Ant concepts in more detail. Two most foundational concepts of Ant are datatypes properties

Ant datatypes overview To build a typical Java project we mostly deal with files and paths (such as classpaths). This leads to Ant datatypes : fileset path and several others 3.1.1?

Filesets overview Fileset is a common entity to manipulate for such tasks as compiling, packaging, copying, deleting, and documenting. Fileset is a group of files represented like <fileset dir="src" includes="**/*.java" id="source.fileset"/> dir is mandatory attribute to denote a base (or root) directory of the fileset - here src. Files in the fileset can be found in a directory tree starting from this fileset base directory. includes attribute shows which files from this directory to include. id attribute is a reference which can be used later wherever this fileset is required to use (possibly repeatedly).

Filesets overview For example, copying source code to another directory using the above id="source.fileset" could be done by <copy> task by using the `inverse’ refid attribute as follows: <copy todir="backup"> <fileset refid="source.fileset"/> </copy> refid attribute tells fileset with which id to use. See the fileset on previous slide.

Paths overview A path can be defined in a build file to be used for compilation with <javac> task, and reused for execution with <java> task. Classpath can be easily and tightly controlled by Ant. This reduces CLASSPATH configuration problems, both for compilation and execution. Examples will be presented later.

Properties overview Ant's property handling mechanism allows for parameterizing the build file by string-specified items. For example, we can change a build to use a different version of library (JAR file) by one command like this: In this example struts.jar after –D (no white space!) represents an Ant property (or parameter) with the assigned value “/home/ant/newstruts/struts.jar”. Build file uses special syntax ${struts.jar} to refer to this property. A key feature of an Ant property is its immutability : - once a property is set, it resists change. >ant -Dstruts.jar=/home/ant/newstruts/struts.jar (with some rare exceptions)

Datatypes and Properties with <javac> The <javac> task is an Ant’s version of Java source compilation command javac with associated switches. Let us compare Sun's JDK 1.3.1 javac command-line compiler switches to Ant's <javac> task attributes. This is shown in the following table.

Ant’s <javac> attributes A comparison of javac command-line compiler switches to Ant's <javac> task attributes JDK’s javac switches Ant’s <javac> attributes -g (generate all debugging info) debug=“yes” -g:none (generate no debugging info) debug=“no” -verbose (output messages about what the compiler is doing) verbose=“true” The -g option tells the compiler to include debugging information [in the compiled class] for future use by the debugger jdb as explained in http://www.student.cs.uwaterloo.ca/~isg/res/java/jdb/ -g:{lines,vars,source} (Generate only some debugging info) debug=“yes” debuglevel= “lines,vars,source” --------------- -o (optimise) optimise=“yes” ----------------- -nowarn (generate no warnings) nowarn=“true” (The -g option tells the compiler to include debugging information [in the compiled class] for future use by the debugger jdb as explained in http://www.student.cs.uwaterloo.ca/~isg/res/java/jdb/) (continued)

Ant’s <javac> attributes/subelements -classpath A comparison of javac command-line compiler switches to Ant's <javac> task attributes JDK’s javac switches Ant’s <javac> attributes/subelements -classpath (specify where to find referenced class files and libraries) <classpath> <pathelement location=“lib/some.jar”/> </classpath> -sourcepath (specify where to find input source files) <src path=“src”/> or srcdir=“src” -d (specify where to place generated class files) destdir=“build/classes” etc. srcdir=“src”??? -deprecation (output source locations where deprecated APIs are used) deprecation=“on” -bootclasspath <path> (override location of bootstrap class files) <bootclasspath.../> -extdirs <dirs> (override location of installed extensions) <extdirs …/> -encoding <encoding> (specify character encoding used by source files) encoding=“…” -target 1.1<release> (generate class files for specific VM version) target=“1.1” -source 1.4<release> (enable JDK 1.4 assertions source=“1.4”

Datatypes and Properties with <javac> (cont.) Consider Java compilation with Ant utilizing Ant's datatypes (paths and filesets), properties and references to datatypes: <javac destdir="${build.classes.dir}" debug="${build.debug}" srcdir="${src.dir}" includeAntRuntime="no"> <include name="**/*.java"/> <classpath refid="compile.classpath"/> </javac> build.classes.dir, build.debug, src.dir are property names. We refer to an Ant property, e.g. as in srcdir=“${src.dir}”, by using ${...}. This will work if we have already somehow assigned separately a value of the property such as src.dir to be the real directory name src. Compare this with the direct reference to the value like in srcdir=“src” where src is the real directory name. includeAntRuntime="yes"

Datatypes and Properties with <javac> (cont.) It was assumed in the above example that build file also contains somewhere path element like <path id="compile.classpath"> <pathelement location="${lucene.jar}"/> <pathelement location="${jtidy.jar}"/> </path> refid="compile.classpath" in the previous slide refers to this path element because of id="compile.classpath". It shows where to find two JAR files needed for the compilation. See more on “${...}” notation on the next slide.

Properties with <javac> [Comments to slides 11,12] The “${...}” notation refers to an Ant property : a mapping from a property name to a string value, referring to the compiling destination directory ${build.classes.dir}, what debug mode to use ${build.debug}, the source directory ${src.dir}, and JAR locations ${lucene.jar} and ${jtidy.jar}. Note that dot notation is used in naming properties, like above, or IDs, like compile.classpath This imitates the natural language. In particular, lucene.jar is considered here as the property name, not as the file name, however, they could coincide for the convenience.

Datatypes (paths and filesets) with <javac> [Comments to slides 11,12] The subelement <classpath refid="compile.classpath"/> specifies a path by using a reference indicating which previously defined path to use. The previously defined path element (see Slide 12) <path id="compile.classpath"> … </path> - indicates which JAR files to use. These JAR files are specified by the use of properties within the location attribute (see Slide 12). The srcdir attribute of <javac> (see Slide 11) - implicitly defines a fileset containing all files (to be compiled) in the specified directory tree. The nested <include> of <javac> task specifies a pattern **/*.java - this constrains the files to only Java source files (at any depth).

Ant task reference For the future, see also descriptions of the concepts of Ant in the Ant task reference (Appendix E: to the Ant book) available via http://manning.com/hatcher/ or http://www.manning-source.com/books/hatcher/hatcher_apxE.pdf See also in your computers in University labs: C:\JAVA\Ant1.8.1\docs\manual\index.html or on the most fresh version of Ant in the Internet: http://ant.apache.org/manual/index.html

Paths in Ant location attribute specifies a single file or directory. A path, or “path-like structure”, is an ordered list of pathelements. It is analogous to the Java CLASSPATH where each element in the list could be either a file or directory separated by a delimiter. Example in Ant: <classpath> <pathelement path="${classpath}"/> <pathelement location="lib/some.jar"/> </classpath> Or even shorter – for the single pathelement: <classpath location="lib/some.jar"/> location attribute specifies a single file or directory. path attribute accepts colon- or semicolon-separated list of locations (like in the following slide), assuming this is the value of the property ${classpath}.

Paths in Ant (cont.) Example of a list of locations, using path attribute (instead of location): Or even shorter – for the single path element : Both semicolon (;) and colon (:) above are allowed as separator. Ant is "bi-slashed": use either forward-slash (/) or back-slash (\), regardless of operating system. - Extremely user friendly! <classpath> <pathelement path="build/classes;lib/some.jar"/> </classpath> <classpath path="build/classes;lib/some.jar"/>

SELF-STUDY Paths in Ant (cont.) Paths can also include a set of files: <classpath> <fileset dir= "lib"> <include name="*.jar"/> </fileset> </classpath> p.52 N1 Ant assumes no order within a <fileset>

Filesets Implicitly, all build processes such as compile, copy, delete, etc. operate on sets of files. Ant provides the fileset as native datatype. It is difficult to imagine any useful build that does not use a fileset. Some tasks assume filesets implicitly, while other tasks support filesets explicitly. A fileset is a set of files rooted from a single directory. By default, a fileset specified with only a root directory will include all the files in that entire directory tree, including files in all sub-directories recursively (with some exceptions; see below on default exclude patterns). Filesets can appear in a build file either inside tasks – the elements of targets, or at the same level as targets.

Filesets (cont.) Let us CREATE a new copy.xml file in C:\Antbook\ch02\secondbuild by extending the build file structured.xml with a new target containing new <copy> task: First RUN copy.xml: ant -f copy.xml compile (to do init -> compile) Then RUN ant -f copy.xml copy (to execute the above <copy> task) Check what from build directory was copied into directory new_build. <target name="copy"> <copy todir="new_build"> <fileset dir="build"/> </copy> </target> C:\Antbook\ch02\secondbuild> ant -f copy.xml compile C:\Antbook\ch02\secondbuild> ant -f copy.xml copy (with archive a default target)

Fileset examples TRY to check – by creating appropriate build and other files – that 1. Fileset includes all JAR files from the lib directory non-recursively, i.e. no subdirectories are considered. 2. Fileset includes all .java files in and below the test directory that end with the string "Test". <fileset dir="lib"> <include name="*.jar"/> </fileset> <fileset dir="test"> <include name="**/*Test.java"/> </fileset> 3.4.1 Fileset examples Hint: Use <copy> task involving either the first or the second fileset to see which files are really copied.

Fileset examples (cont.) 3. includes only non-JSP files in the web directory and below. By default, include and exclude values are case sensitive. But this can be disabled by specifying the attribute of <fileset>: casesensitive="false" <include> and <exclude> subelements in <fileset> serve as patternsets. For example, **/*.jsp and **/*Test.java are patterns. <fileset dir="web"> <exclude name="**/*.jsp"/> </fileset> 3.4.1 Fileset examples

Fileset examples (cont.) There is also a way to abbreviate <fileset dir="web"> <include name="**/*.jsp"/> </fileset> as <fileset dir="web" includes="**/*.jsp"/> p.55 (*) by using attribute includes instead of subelement <include>

Some default exclude patterns SELF-STUDY Pattern Typical program that creates and uses these files **/*~ jEdit and other editors use this as previous version backup **/#*# editors **/.#* **/%*% Etc. To turn off the automatic exclusion, use the defaultexcludes attribute: <fileset dir="..." defaultexcludes="no">

Patternsets and Selectors There is also some additional mechanism of patternsets and selectors to form filesets which we will not consider. See Sections 3.5 and 3.6 in Antbook, and also C:\JAVA\Ant1.8.1\docs\manual\index.html http://ant.apache.org/manual/index.html We postpone considering further data types.