This document provides an overview of build tools and focuses on Maven. It defines what build tools do, such as automating the process of compiling source code and packaging binaries. It discusses different build tools for various programming languages and frameworks. The document then describes Maven in more detail, covering its history, plugins, project object model (POM), dependencies, lifecycles, and an example command.
2. What do build tools do?
• Automate the process of turning the source code that you’ve written
to the end-product to be run by the user.
3. What do build tools do?
• Package your code
• (e.g. Compiling source code into binary code; packaging binary code)
• Deployment
• (e.g. putting the new programme on your web server or production systems;
Uploading the new programme for users to download)
• Tests
• (e.g. Running any unit/system tests we’ve written; Check that the code meets
standards)
• Integrate with other tools
• (e.g. Generate documentation from the code you’ve written; Kick off other
build tools)
4. Every environment/build tool is different
• Javascript
• Gulp, Grunt, Brocolli
• C#/.NET
• Nant, MSBuild
• Java/JVM
• Ant, Maven, Gradle, SBT, Leiningen
5. Maven
• Began production in 2002
• V1.0 released 2004;
• Maven 2 was a significant change (i.e. broke v1.0) and was released
very soon after in 2005
• Future mavens aim to be backward compatible, and was released in
2010.
6. Plugins
• Goal
• Like a task, i.e. “I want to do this thing now, please”
• e.g. “Run all my unit tests”
• Plugin
• A plugin is a collection of goals.
• E.g. “Maven Compiler Plugin” has “compiler:compile” and
“compiler:testCompile” – these can be run individually but don’t tend to be
(foreshadowing!)
• Some plugins are core to maven (e.g. “clean” or “surefire”) others have to be
imported.
• List of plugins: http://maven.apache.org/plugins/
7. POM.xml
• Project Object Model (pom.xml)
• Can contains lots of information:
• What the project is (e.g. name, version)
• What project you depend on (Super POM by default, but e.g. Forge POM)
• Dependencies
• Which plugins to use
• Variables (“properties”)
8. Lifecycle
• A “lifecycle” is a list of instructions that says “this is what I want to do
with this code”
• You will almost always use the default lifecycles (default, clean and site), but
can set up new ones.
• A lifecycle is made up of phases in order, and a phase is made up of
goals.
• To run a lifecycle, give it a phase in that lifecycle, and it will run
everything up until that phase.
9. Lifecycles: An Example
validate ensure all necessary information is available
compile compile the source code of the project
test unit test the source code using a suitable framework.
package package the code in its distributable format (e.g. JAR)
integration-test
deploy the package if necessary into an environment
where integration tests can be run
verify
run checks to verify the package is valid and meets
quality criteria
install install the package into the local repo
deploy project specific!