04.03
- 4.3 Script a build in Ant
- Learning Objectives
- EXERCISE: Run Ant build
- EXERCISE: Create a Rake build script (OPTIONAL)
4.3 Script a build in Ant
Learning Objectives
By the end of this lesson you will be able to:
- Script a build that packages software so that it can be deployed.
EXERCISE: Run Ant build
From the AWSCLI, install using yum
“` $ sudo yum -y install ant
“`
Go to the build directory.
cd /home/ec2-user/continuous_integration_example/software/build
Type ant from the command line
ant
You should receive a message like this:
Buildfile: build.xml does not exist! Build failed
From the build directory, create an Ant build file called myantbuild.xml
“` $ sudo vim myantbuild.xml
“`
Create an Ant project within the myantbuild.xml file
“` <?xml version=“1.0” encoding=“iso-8859-1”?>
“`
Define properties between the project tags.
“`
“`
Define targets after the property definitions
“`
“`
Add tasks to targets (within the compile-src target)
“`
“`
Define dependent targets
<target name="all" depends="compile-src">
The entire myantbuild.xml file should look like this:
“`
<?xml version=“1.0” encoding=“iso-8859-1”?>
“`
Run myantbuild.xml file from the command line
“` $ ant -f myantbuild.xml
“`
Add the file in Git
“` $ git add .
“`
Commit the file to Git
“` $ git commit -m “Modified build script”
“`
Push it to the Git master.
“` $ git push
“`
EXERCISE: Create a Rake build script (OPTIONAL)
- From your AWSCLI instance go to sample_app, open some build scripts.
- You can also find these files by going to https://github.com/stelligent/sample_app/blob/master/Rakefile and https://github.com/stelligent/sample_app/blob/master/lib/tasks/sample_data.rake.
- Make a modification to the contents of the file and save it.
Add the file in Git
“` $ git add .
“`
Commit the file to Git
“` $ git commit -m “Modified build script”
“`
Push it to the Git master.
“` $ git push
“`