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

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

Introducing JavaScript
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
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.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
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.
CSC 395 – Software Engineering Lecture 24: Apache Ant –or– Programming the results of programming Based upon a talk by Anthony Wat.
DT211/3 Internet Application Development
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Command Console Tutorial BCIS 3680 Enterprise Programming.
Tomcat Celsina Bignoli History of Tomcat Tomcat is the result of the integration of two groups of developers. – JServ, an open source.
Using Ant to build J2EE Applications Kumar
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,
4.1 JavaScript Introduction
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.
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.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
Interacting with a UNIX computer: Navigating through the directory tree.
The Basics of Javadoc Presented By: Wes Toland. Outline  Overview  Background  Environment  Features Javadoc Comment Format Javadoc Program HTML API.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Chapter 13. Applets and HTML HTML Applets Computer Programming with JAVA.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
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.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Javadoc Dwight Deugo Nesa Matic
Live and Learn – ant. Resources  Ant User Manual  Skip the book, most of the material is right here  Apache.
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.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
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.
Building Packages BCIS 3680 Enterprise Programming.
1 Week # 4 Introduction to PDM PDM is a workbench environment that lets programmers and system operators navigate the three levels of the AS/400’s object-based.
Java Package Advantage of Java Package
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.
Chapter 14 Using JavaBeans Components in JSP Documents.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
1 Example Uses of Java Reflection Explained Simply.
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 More Ant Features These slides are mainly based on “Java Development with Ant” - E. Hatcher & S.Loughran.
Makefiles Manolis Koubarakis Data Structures and Programming Techniques 1.
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 &
An Introduction to Ant. What is Ant? How do you use it? Why would you want to?
Software Development Tools
Software Development Tools
COMP220/COMP285 Seb Coope Ant: Structured Build
Command Syntax Chapter 2 Using the DIR Command with
Stata Basic Course Lab 2.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
SPL – PS1 Introduction to C++.
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

2 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

3 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

4 Filesets overview 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). <fileset dir="src" includes="**/*.java" id="source.fileset"/> 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

5 Filesets overview For example, copying source code to another directory using the above id="source.fileset" could be done by task by using the `inverse’ refid attribute as follows:

6 Paths overview A path can be defined in a build file to be used for compilation with task, and reused for execution with 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.

7 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

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

9 A comparison of javac command-line compiler switches to Ant's task attributes JDK’s javac switchesAnt’s 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 (continued)

10 A comparison of javac command-line compiler switches to Ant's task attributes JDK’s javac switchesAnt’s attributes/subelements -classpath (specify where to find referenced class files and libraries) <pathelement location=“lib/some.jar”/> -sourcepath (specify where to find input source files) or srcdir=“src” -d (specify where to place generated class files) destdir=“build/classes” etc.

11 Datatypes and Properties with (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"> 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.

12 Datatypes and Properties with (cont.) It was assumed in the above example that build file also contains somewhere path element like 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.

13 Properties with 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. [Comments to slides 11,12]

14 Datatypes (paths and filesets) with  The subelement -specifies a path by using a reference indicating which previously defined path to use.  The previously defined path element (see Slide 12) … - 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 (see Slide 11) - implicitly defines a fileset containing all files (to be compiled) in the specified directory tree. The nested of task specifies a pattern **/*.java - this constrains the files to only Java source files (at any depth). [Comments to slides 11,12]

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 or 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: 15

16 Paths in Ant 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:  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}. Or even shorter – for the single pathelement:

17 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!

18 Paths in Ant (cont.) Paths can also include a set of files: Ant assumes no order within a SELF-STUDY

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. 19

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 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 task) Check what from build directory was copied into directory new_build. 20

21 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 ". Hint: Use task involving either the first or the second fileset to see which files are really copied.

22 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 : casesensitive="false" and subelements in serve as patternsets. For example, **/*.jsp and **/*Test.java are patterns.

23 Fileset examples (cont.) There is also a way to abbreviate as by using attribute includes instead of subelement

24 Some default exclude patterns PatternTypical program that creates and uses these files **/*~ jEdit and other editors use this as previous version backup **/#*# editors **/.#* editors **/%*% editors Etc. To turn off the automatic exclusion, use the defaultexcludes attribute: SELF-STUDY

25 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   We postpone considering further data types.