Apache build projectsA practical session on Apache Maven, Ant and Subversion By. S. Suhothayan & Prabath Abaysekara
Subversion (SVN) If more than one developer is working on a project - how can they all make changes to the source code...?
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
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
How its done… More than one developer is working on a project... from: OpenMRS
How its done… more than one developer to works on the same revision file... and trying to commit at the same time! from: OpenMRS
How its done… What if the changes are on the same line !!! from: OpenMRS
Ant A software tool for automating software build processes Similar to MAKE, but: Written in and developed primarily for Java Uses XML scripts
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.
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
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
Maven A software project management and comprehension tool.
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!
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.
Create a project With the archetype mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=org.apache.meetup -DartifactId=calcualtor-app
Dependencies Dependencies are uniquely identified by their Group Artifact Version Declare dependencies in the POM and the Maven will find it for you!
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)
MavenRepositories Repositories are used to host dependencies1. Remote The servers that hold released binaries e.g. Artifactory, Nexus2.Local ~/.m2/repository
MavenPlugins Reporting Test Coverage (Sonar) Javadoc auto-generation CheckStyle FindBugs Ant
Releasing your project Single command to deploy Pushing artifact to server (Almost) Single Command To Release your project! mvn release:prepare release:perform