how maven makes your development group look like a bunch of professionals
TRANSCRIPT
Venkaiah Chowdary Koneru
Fazreil Amreen Abdul Jalil
How maven makes your development group look like a bunch of professionals.
Agenda
• Maven
• Repository
• Complete Build solution
What’s the Problem?
• Manual handling of external Jars
• Inter-project dependencies
• Running tests
What is Maven ?
• A build tool
• Uniform build system
• Provides quality project information
• Transparent migration to new features
• Guidelines for best practices development
Conceptual Model
• Maven maintains model of a project
• Unique set of coordinates to a project
• Almost zero effort
• Encourages modular design
Default Directory Structure
Source folders
Test related Source folders
Generated class files and artifacts
Structure is based on the archetypes definition
POM
• Fundamental unit of work in maven
• An XML file
• Consists– Project information– Project relationships– Build settings– Build environment
POM
• Fundamental unit of work in maven
• An XML file
• Consists– Project information– Project relationships– Build settings– Build environment
<project ...> <parent /> <groupId /> <artifactId /> <version /> <packaging /> <modules> … </modules><propertie> ... </properties><developers /> <contributors /> <scm> ... </scm> <build>
<plugins> ... </plugins> </build> <dependencies> ... </dependencies> <repositories> ... </repositories> <pluginRepositories> ... </pluginRepositories> <profiles> ... </profiles> <reporting> ... </reporting>
</project>
POM
• Convention over Configuration
• Maven incorporates this by providing default behavior for projects
<project> <modelVersion>4.0.0</modelVersion> <groupId>my.fazreil.projects</groupId><artifactId>fireglass</artifactId><version>0.0.1</version></project>
Just put your sources in the correct directory
Life Cycle
• Contains phases in specific order
• Phase is made up of goals
• 3 built-in life cycles– default– clean and– test
Life Cycle - Defaultvalidate
initialize
compile test-compile
deploy
packagetest
install
Multi-Module Projects
• Why use a modular architecture ?– Separation of concerns– Easier to test– Flexible
• Reusing the configuration– Inheritance– Dependencies
• Aggregation
Multi-Module Projects
archetype
Project
module1 module2
Organization or team wide properties
Project wide properties
Module specific properties
Aggregation
Multi-Module Projects
• Organize your builds
• Speed up builds
• Speedup test process
Maven Repository
• Holds the build artifacts and dependencies
• Two types of repositories– Local – Remote
Local Repository
• Local cache for artifacts
• Can erase it completely
• Useful for offline builds
• Resides in User home’s .m2/ folder
Remote Repository
• Central repository to host all artifacts
• Local repository downloads from the central repository hosted @ maven.org
Local Repository(.m2\repository\)
Remote repository(http://repo1.maven.org/maven2)
Search order
Internal Repository
• Corporate repository
• Proxy for remote repositories
Local Repository(.m2\repository\)
Remote repository(http://repo1.maven.org/maven2)
Search order
Internal Proxy(http://{repository url})
What is Artifactory?
• It is a MAVEN repository
• Think of it as the ‘SVN’ for libraries.
• It is the place to obtain this information:
<dependency>
<groupId>my.fazreil.project</groupId>
<artifactId>fireglass</artifactId>
<version>0.0.1</version>
</dependency>
Do we need our own maven repo?
• Because we want to host our own libraries.
• And we would like to make our libraries available to the local network
• Yes, we can control the access.
Extra notes
• Artifactory acts as a proxy to the outside repository.
• Dependencies requested to Artifactory will be cached in Artifactory for quick retrieval.
Build solution
• Complete end-to-end solution
• 5 open source projects– Maven– Subversion– Hudson– Artifactory– Sonar
Ecosystem
• A typical maven project ecosystem
Source code changes
Automated builds
Publish artifacts
metrics
Distribute artifacts
Maven Release Cycle
• Develop against snapshot versions
• Release stable versions
• Automated releases– Update version numbers to next SNAPSHOT
versions