Maven for building Java applications By Nalin De Zoysa
Notes This is an interactive session Please ask questions Prerequisites – Introduction to the Java Stack
Outline Introduce maven Basic Maven Pom File and Project Structure Dependencies Maven Central Repository Maven Basic Operations
Introduce Maven What is maven – Apache Maven is a build tool to support the developer at the whole process of a software project. – Based on the concept of XML Project Object Model (POM). –Originally developed for building Turbine. – A small core with numerous plugins
Introduce Maven What it does - Automate the process of the creation of the initial folder structure - Performing the compilation and testing and the packaging and deployment - Convention over configuration(avoid as much configuration as possible, by supplying project templates (archtypes)) - Dependency management: - dependencies to other projects.(resolves the dependencies)
Introduce Maven Cont.. NameDescription groupIddefines a unique base name of the organization or group that created the project. This is normally a domain name. For the generation the groupId also defines the package of the main class. artifactIddefines the unique name of the artifact. In our case it's the same like the groupId, but it could also be a simple name like "SuperCalculator". The generation uses this value as name of the root folder for out project. packagingdefines the packaging method. This could be e.g. jar, war or ear. This setting has influence on the whole life cycle. versionThis defines the version of the artifacts generated from our project.
Maven Under the Hood forehead classloader util launcher maven core, jelly, werkz Maven plugins javajarwarejb eargumpxdocletjavadoc test jalopy cactusartifactxdoc sitejunitetc… ant
Maven Architecture Overview Build System Local Repo Remote Repo maven project.xml (pom) maven.xml (goals) http Site The Most Important Feature Remote Repository
Basic Operations - mvn install # default to run Maven #compiles, build and install the build result - mvn clean install -o # work off-line, i.e. use the local maven repository - mvn test Instead of running a full build with packaging it is also possible to just run single phases of a life cycle.
Demonstration... Lets use maven demo
Get More c c ml ml maven.html maven.html