1. Apache build projects
A practical session on Apache Maven, Ant and Subversion
By. S. Suhothayan & Prabath Abaysekara
2. Subversion (SVN)
ď˝ If more than one developer is working on a
project - how can they all make changes to the
source code...?
3. Why version control?
ď˝ This gives us a history of a software project
ď˝ If we accidentally delete some code, we can look for an
older version that still has the code
ď˝ We can see who made what changes
ď˝ Serves as a backup
4. Terminology
ď˝ Repository: a storage location for projects that
SVN will manage
ď˝ Checkout: to download a copy of a project from
a repository
ď˝ Commit: to upload files to a repository after
making changes
ď˝ Update: to download the latest versions of files
from a repository when your local copies are out
of date
5. How its doneâŚ
ď˝ More than one developer is working on a
ď˝ project...
from: OpenMRS
6. How its doneâŚ
ď˝ more than one developer to works on the same revision
file... and trying to commit at the same time!
from: OpenMRS
7. How its doneâŚ
ď˝ What if the changes are on the same line !!!
from: OpenMRS
9. Ant
ď˝ A software tool for automating software build processes
ď˝ Similar to MAKE, but:
ď˝ Written in and developed primarily for Java
ď˝ Uses XML scripts
10. How Ant build files written?
ď˝ Build-scripts are created from existing Ant-tasks.
ď˝ The Ant tasks do not prescribe any conventions or
configuration.
ď˝ Therefore the definition of project layout is your
responsibility.
ď˝ Advantage
ď˝ You have full control of whatever you are doing
ď˝ Disadvantage
ď˝ Can become a problem in bigger projects.
11. How to run Ant ?
ď˝ Can be run from the command line
ď˝ By default the command line client looks for a build script
build.xml in the current directory
> ant
ď˝ To use a different build script, we have to specify it
> ant -buildfile other.xml
12. Targets
ď˝ Build scripts contain targets, the different jobs that they
can performed
ď˝ We can specify the name of the target to run the specific
target .
> ant compile
ď˝ Note: If nothing specified will run the default target
13. Maven
ď˝ A software project management and comprehension
tool.
14. What it Maven?
ď˝ Maven = âAnt With Convention Over Configurationâ
ď˝ Directories
ď˝ Source, Tests, Resources
ď˝ Goals
ď˝ Clean, Test, Deploy, Package, Install, Site...
ď˝ But... you have to learn the conventions!
15. Maven Lifecycle
ď˝ validate
Validate the project is correct and all necessary information is available
ď˝ compile
Compile the source code of the project
ď˝ test
Test the compiled source code using a suitable unit testing framework.
ď˝ package
Take the compiled code and package it in its distributable format, such as a JAR.
ď˝ verify
Run any checks to verify the package is valid and meets quality criteria
ď˝ install
Install the package into the local repository, for use as a dependency in other
projects locally
ď˝ deploy
Done in an integration or release environment, copies the final package to the
remote repository for sharing with other developers and projects.
16. Create a project
ď˝ With the archetype
mvn archetype:generate
-DarchetypeGroupId=org.apache.maven.archetypes
-DgroupId=org.apache.meetup
-DartifactId=calcualtor-app
17. Dependencies
ď˝ Dependencies are uniquely identified by their
ď˝ Group
ď˝ Artifact
ď˝ Version
ď˝ Declare dependencies in the POM and the Maven will find
it for you!
18. Dependency management
ď˝ The real strength!
ď˝ You only have to declare the dependencies â
ď˝ maven will download them
ď˝ setup the classpath and
ď˝ even deploy the dependencies with your application.
ď˝ Maven manages not only the direct dependencies - but
even the dependencies of the dependecies (transitive
dependencies)
19. Maven
Repositories
ď˝ Repositories are used to host dependencies
1. Remote
The servers that hold released binaries
e.g. Artifactory, Nexus
2.Local
~/.m2/repository
20. Maven
Plugins
ď˝ Reporting
ď˝ Test Coverage (Sonar)
ď˝ Javadoc auto-generation
ď˝ CheckStyle
ď˝ FindBugs
ď˝ Ant
21. Releasing your project
ď˝ Single command to deploy
ď˝ Pushing artifact to server
ď˝ (Almost) Single Command To Release your project!
mvn release:prepare release:perform