7. Build Tool - Outputs
JAR / WAR / EAR files
Zip files
Reports
8. Ant Maven
Procedural Declarative
1. Set path 1. Define name & version
2. Compile jars 2. Define as WAR project
3. Run unit tests 3. Specify dependencies
4. Create reports 4. Specify unit test plugin
5. Copy files
6. Assemble WAR
9. Ant
“make for java”
Properties, paths, and filesets
Targets
Target dependencies
Tasks
10. Ant Installation
Download
Unzip
Add to PATH
Set ANT_HOME env variable
Extend by adding jars to lib/
Customize by modifying XSL in etc/
24. More Ant
Ant
http://ant.apache.org/
Core tasks
http://ant.apache.org/manual/coretasklist.html
External tools
http://ant.apache.org/external.html
IVY
http://ant.apache.org/ivy/
25. Maven
Project and artifact-based build
platform
Uses repositories to manage
artifacts and third party libraries
Customized by modifying the
behavior of the life-cycle via plugins.
27. Maven Artifacts
Output of the build process
JARs, WARs, EARs, zip files
Stored in repositories
Published and consumed by Maven
One per project
28. Maven Dependencies
Items needed during build process
Managed as artifacts and metadata
within remote repositories
Usually created and published by
other Maven builds
Though not necessarily
33. Maven Project Object Model
“POM”
Fundamental unit of work in Maven
Build components inherit from best
practices and common base
34. Maven Build Life-Cycle
Consistent pattern
Portable process knowledge
Modify build with plugins
Extensible in decoupled way
Large number of phases, not all
required
Compile, test, package, install, deploy
39. Maven Settings
Two setting files
Installation settings:
conf/settings.xml in install directory
User settings: ~/.m2/settings.xml
C:Usersusername on Windows Vista
C:Documents and Settingsusername on XP
40. Maven Settings
Separate installation and user settings
User settings are things you don't share
server usernames and passwords, local paths, etc.
Installation settings are things that should
be the same on all Maven installations
can distribute various ways: check out Maven install
from SCM, provide a re-bundled Maven, etc.
41. Maven Archetypes
POJO jar
Web applications
AppFuse, Wicket, MyFaces, etc
Groovy
43. Maven Resources
Accessed by code at runtime
Not required for compilation
Packaged within the artifact
Can be filtered with custom values
44. Maven Plugins
Reusable pieces of build functionality
Perform a clearly defined task based on a set of
input configuration
Maven takes responsibility for orchestrating their
execution
Primarily written in Java, but can be written in a
number of scripting languages
Are also stored and downloaded from repositories
45. Maven Repositories
Repositories are a storage location for artifacts
Maven has two types:
Remote repository - repository accessible over HTTP, FTP, filesystem, etc that
contains artifacts to consume and as a place to publish build artifacts
Local repository - a cache of artifacts on your machine, downloaded from
several remote repositories
Maven is pre-configured to use the Central Repository for
dependencies
A large collection of open source and re-distributable artifacts,
primarily for Java
Can establish and manage your own remote repositories
Can be used by build systems other than Maven
47. Archiva
Helps to manage Maven repositories
Control your environment for your
team
Can be run personally for offline
cache
48. Archiva
A repository management server
manages Maven remote repositories and the artifacts inside them
Used by a group or team for an “internal” remote repository
deploy your own build artifacts
control content from external sources
on demand downloading of artifacts
CI server companion
Can be used as a personal server
make it easier to clean your local repository without downloading remotely again
must be careful about introducing build inconsistencies localized to your
environment, however
49. Installing Archiva
Two choices
Existing servlet container or application server
Standalone
pre-configured instance of Jetty 6, Java Service Wrapper, Apache Derby
Configuration files
APP_BASE/conf/jetty.xml - server port, outgoing mail server and databases
standalone only, configure using container settings for others
APP_BASE/conf/archiva.xml - maintained by the application
applies to both choices
Two databases – users and repository statistics
When using standalone, recommend a separate conf directory
set ARCHIVA_BASE environment variable to point to a copy of the conf directory
makes upgrading easier
50. Configuring Maven For Archiva
There are a number of alternatives for configuring Maven to use a repository
manager:
add to the POM
used in addition to central, but always checked first
add to Maven settings
as above, but applies to all projects
override or mirror central
never use the central repository, everything else the same
override or mirror all repositories given
Could add the repositories to the POM
what if the parent POM is in the repository, not the check out?
use the POM if users must build using that repository without configuring settings
Use Maven settings instead
generally prefer the mirror all repositories