Developing Build Scripts - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Developing Build Scripts

Description:

May also be used for other batch process needs ... in any way with any project name outside of Ant. ... copying files and/or directories. 13. Task Example ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 19
Provided by: jfis9
Category:

less

Transcript and Presenter's Notes

Title: Developing Build Scripts


1
Developing Build Scripts
  • Using the Ant Build Tool
  • July 28, 2003

2
What is a build script?
  • A special script designed to compile source code
    into a format that can be executed.

3
Why are build scripts needed?
  • Build process is complex
  • Manage complexity
  • Provide consistent and repeatable results
  • Prevent modules from be inadvertently forgotten
    in the deployment process

4
How are build scripts created?
  • The same way homes are built with tools.
  • A common tool used to create software builds is
    the Ant tool.

5
About Ant
  • Stands for Another Neat Tool
  • Thoroughly tested and well understood in the Java
    community primarily for executing build
    deployment scripts.
  • May also be used for other batch process needs
  • Based on cross platform technologies (e.g. Java
    and XML).
  • Executes quickly and has proven to be effective
    in large scale enterprise deployments.
  • Received Java Pro 2003 Readers' Choice Award for
    Most Valuable Java Deployment Technology

6
Ant Concepts
  • Build script file
  • Script file execution
  • Next steps

7
Build Script File
  • Building blocks of the Ant script
  • Project
  • Targets
  • Tasks

8
Project Tag
  • No buildfile can be without one, nor can it have
    more than one.
  • The ltprojectgt tag has three attributes name,
    default, and basedir.
  • name gives the project a name
  • default refers to the automatic target in which
    execute
  • basedir defines the root directory of a project
  • The ltprojectgt tag is not connected in any way
    with any project name outside of Ant.

9
Project Example
  • Create a project titled MyProject.
  • ltproject name"MyProject" default"all"
    basedir"."gt
  • ...
  • lt/projectgt

10
Target Tag
  • Typically consist of coarse-grained operations
  • Consist of tasks that do the actual work of
    accomplishing the target goal

11
Target Example
  • The purpose of this target is to compile source
    code and create a Java ARchive (JAR) from the
    compiled classes.
  • lttarget name"build-lib"gt
  • ltjavac srcdirsrc.java.dir"
  • destdir"build.dir"
  • debug"on"
  • deprecation"on"
  • includes"/.java"gt
  • ltclasspathgt
  • ltpathelement location"."/gt
  • ltpathelement location"lib.dir/somelib
    .jar"/gt
  • lt/classpathgt
  • lt/javacgt
  • ltjar jarfile"dist/lib/finallib.jar"
    basedir"build.dir"/gt
  • lt/targetgt

12
Task Tag
  • Solve the more granular goals of a build
  • perform the actual work
  • compiling source code
  • packaging classes
  • copying files and/or directories

13
Task Example
  • This task in particular copies a set of files
    from one directory to another.
  • ltcopy todir"weblogic.dir/server.home/public
    _html/jsp"gt ltfileset dir"src.www.dir/jsp"/gt
  • lt/copygt

14
Build Script Execution
  • Once the build script is created, execute the
    ant.bat file from the prompt
  • Ant searches first to the default build.xml file
  • Can specify another build script file as an
    argument from the prompt
  • The compilation is performed by the Java
    Development Kit found in the system path

15
Items to Consider
  • Limitations in deployment
  • Eclipse does provide extensions for Ant

16
Summary
  • Purpose of deployment scripts
  • Ant build deployment tool concepts
  • Ant build script examples
  • Extensions to the Ant tool

17
Next Steps
  • Ant Website http//ant.apache.org/
  • OReilly Book Ant the Definitive Guide

18
Question Answer
Write a Comment
User Comments (0)
About PowerShow.com