Managing your builds with Maven 2 Craig Walls LoneStar Software Symposium 2007

Slides:



Advertisements
Similar presentations
Vincent Massol, 1 st December 2006 Quality with Maven2.
Advertisements

Apache Maven: J2EE Front to Back Jesse McConnell -
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
Developing in CAS. Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug.
Introduction to Maven Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to the Java Stack.
Build your Android App with Gradle Android new build system.
ANT – Another Neat Tool Representation and Management of Data on the Internet.
Java Build Tool Comparison HJUG - April 29th, 2009 John Tyler.
Maven 2.0 Project management and comprehension tool.
Java development infrastructure at FMI Pekka Rantala FMI.
Maven: Build and project management in the 21th century.
Intermediate Maven Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions No making fun of my microphone Prerequisites –
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 10: Server Administration.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Automating the Build Process using ANT SE-2030 Dr. Mark L. Hornick 1.
Open source administration software for education research administration Lin-Long Shyu System Analyst Kuali Coeus Technical Team Indiana University
Open source administration software for education 2012 User Conference April 22-24, 2012 – Atlanta, Georgia “Together Toward Tomorrow” Chris Denne, Colorado.
Using Ant to build J2EE Applications Kumar
Enterprise Java v090401JavaEE EAR1 Java EE Enterprise Archive (EAR)
APACHE MAVEN Bhavana Sudharshan Jaydeep Patel. Introduction What is Maven? “Maven is a software management and comprehension tool based on the concept.
This presentation will guide you though the initial stages of installation, through to producing your first report Click your mouse to advance the presentation.
Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack.
Using Maven2. Free Maven Books Maven: The Definitive Guide (alpha)‏ Better Builds with Maven
Maven & Bamboo CONTINUOUS INTEGRATION. QA in a large organization In a large organization that manages over 100 applications and over 20 developers, implementing.
MAVEN-BLUEMARTINI Yannick Robin. What is maven-bluemartini?  maven-bluemartini is Maven archetypes for Blue Martini projects  Open source project on.
IPT2 user interface customization and locale translation Alan Yang, Kun Chi Lai, Jim Hsu Biodiversity Research Center, Academia Sinica.
What’s new in Stack 3.2 Michael Youngstrom. Disclaimer This IS a presentation – So sit back and relax Please ask questions.
LDS Account Integration. Disclaimer This is a training NOT a presentation. – Be prepared to learn and participate in labs Please ask questions Prerequisites:
Tomcat Spencer Uresk. Notes This is a training NOT a presentation Please ask questions This is being recorded
Demystifying By Mike Desjardins 1. Topics Installation Shock and Awe: Comparison with ant Project Object Model (POM) Inheritance and Modules Dependencies.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Using the ALM Module Fully Automated Deployments in Stack 3.2.
INFSOM-RI Juelich, 10 June 2008 ETICS - Maven From competition, to collaboration.
Juggling Java EE with Enterprise Apache Maven Jesse McConnell -
Using the ALM Module Michael Youngstrom. Disclaimer This is a training NOT a presentation. – Be prepared to learn and participate in lab Please ask questions.
LDS Account Integration. Disclaimer This is a training NOT a presentation. – Be prepared to learn and participate in labs Please ask questions Prerequisites:
1 dec 20, 2007 Maven project automation for dummies Aino Andriessen AMIS.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
1 may 31, 2007 Build, test and deploy ADF applications without effort with the use of Maven2 Aino Andriessen AMIS.
Introduction to Maven 2. Basics Convention over Configuration Declarative project management DRY.
Maven 2.0 Improve your build patterns Vincent Massol CTO Pivolis.
Maven for building Java applications By Nalin De Zoysa
Enterprise Java v090125Dev Env Overview1 Enterprise Java ( ) Development Environment Overview.
Spring-Batch Tutorial Getting Started Guide. Agenda  Software prerequisites  Creating new batch application  Setting up database  Running a job.
Maven, Eclipse and OSGi working together Carlos Sanchez March 17, 2008.
Build Systems Presentation December 14, 2015 Noon-1pm Kathy Lee Simunich Bldg. 203/ D120 Brought to you by: Argonne Java.
Maven 2 The Maven Apache. Overview What's new in Maven 2.0 Maven 2.0 and Ant... and anything else you'd like to know about.
Software Deployment & Release 26/03/2015 1EN-ICE.
OpenMRS Create New Module.
8/29/10 Maven Repository Management with Nexus Jim McMahon.
Maven. Introduction Using Maven (I) – Installing the Maven plugin for Eclipse – Creating a Maven Project – Building the Project Understanding the POM.
CS520 Web Programming Introduction to Maven Chengyu Sun California State University, Los Angeles.
Exploring Maven 2 Craig Walls Gateway Software Symposium 2007 Blog: Wiki: Examples:
Maven and Jelly James Strachan. Introduction Maven and Jelly are both Apache projects at Jakarta Ultimately both will be top.
Maven & NetBeans Platform. Agenda ● Maven NetBeans Platform Project Types ● Three NetBeans RCP project types ● Differences with Ant project types ● All.
Platform & Maven2 David Šimonek. Certified Engineer Course Agenda What is Maven? Why Maven? NB IDE & Maven NB Platform & Maven.
Open-O Integration Project Introduction
Maven 04 March
CS520 Web Programming Introduction to Maven
Plan What is Maven ? Links : mvn command line tool
Bhavana Sudharshan Jaydeep Patel
Test Driven Development
prepared by hasan.we4tech.com
Project management and comprehension tool
Maven IIB9 Plug-in Version 9.0
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Escidoc build and development environment
Software Engineering and Architecture
Presentation transcript:

Managing your builds with Maven 2 Craig Walls LoneStar Software Symposium

About you… Java?.NET? Ruby/Rails? Erlang? –Java 6? Java 5? Java 1.4? Java 1.3? 1.2 or older? Who’s using Maven? How long? –Maven 1? Maven 2?

About me Agile developer with Semantra –Natural language data access Developing software professionally for over 13 years –Telecom, Finance, Retail, Education –Java for most of that –Also some C/C++, C#/.NET, Ruby Spring fanatic

Agenda Intro to Maven 2 Exploring the POM Dependencies Profiles Project relationships Archetypes Project web site generation Q & A

Maven resources “Get the most out of Maven 2 site generation” “The Maven 2 POM Demystified” “Better Builds with Maven: How-to Guide for Maven 2” “Maven: The Definitive Guide”

Intro to Maven 2

What is Maven? Build tool? Project management tool? Dependency management tool? Documentation tool?

Maven vs. Ant Ant Boilerplate build code Explicit target definitions Explicit project structure Dependencies must be provided by programmer Maven Declarative Common tasks are built-in Project structure imposed by Maven Dependencies declared (Maven gets them for you)

MYTH: Maven is hard Maven is different than Ant…but not necessarily harder. Q: Is Chinese harder than English? –1.2 billion people don’t think so. In most cases, Maven is significantly simpler than Ant. You must be willing to think differently about how you build your projects.

MYTH: Maven is slow Fact: Maven is slow when it needs to download a lot of dependencies. Dependencies are cached locally, so future builds will be faster. Typical builds are at least as fast (and maybe faster) than Ant.

Maven principles Convention over configuration Declarative execution Reuse of build logic Coherent organization of dependencies

Consistent directory structure How Maven knows where everything is. How the developer knows where everything is.

Maven lifecycle 1.validate 2.generate-sources 3.process-sources 4.generate-resources 5.process-resources 6.compile 7.process-classes 8.generate-test-sources 9.process-test-sources 10.generate-test-resources 11.process-test-resources 12. test-compile 13. test 14. package 15. pre-integration-test 16. integration-test 17. post-integration-test 18. verify 19. install 20. deploy

Running Maven % maven [options] [goal(s)] [phase(s)] Examples: % maven -o clean package % maven tomcat:deploy % maven site

Exploring the POM

Key POM sections Basic project info Build section Dependencies section Reporting section Profiles section

Basic project info Poker Service com.habuma Poker 1.0 war Sample Spring-WS service

Build section Poker …

Build section: Java 1.5 maven-compiler-plugin 1.5

Build section: Cargo org.codehaus.cargo cargo-maven2-plugin 0.2 tomcat5x remote runtime localhost 8080 admin password

Build Section: Jetty Adding the Jetty plugin: org.mortbay.jetty maven-jetty-plugin Start Jetty from Maven (and run your app): % mvn jetty:run

Misc properties 2.0 org.springframework spring ${spring.version} compile

Dependencies

Dependency resolution Dependencies are automatically resolved… –First looks in local repository: ~/.m2/repository –Then looks in one or more remote repositories Default: Transitive dependencies –Your project depends on Hibernate… –…which depends on cglib…which depends on… SNAPSHOT dependencies –Downloaded anew once every day

Other repositories Add a new repository to your build: Codehaus Codehaus Repository default

Dependency resolution (2) org.springframework spring 2.0 compile Resolves to: [repository]/org/springframework/spring/spring-2.0.jar

Dependency scopes compile - Dependency is made available in all classpaths (compile, test, and runtime) –Most dependencies will be in this scope provided - Dependency is made available during compile, but will be provided by JDK or container at runtime. –The Servlet API JAR is in this scope test - Dependency is made available only at test time –This scope is appropriate for JUnit. runtime - Dependency is made available in test and runtime classpaths, but not at compile-time system - Like “provided” but you must explicitly provide the dependency JAR file.

Online vs. offline Remote dependency resolution depends on internet connection. If you’ll be offline, run Maven with -o switch –Dependencies will only be resolved from local repository –Of course, dependencies must be in local repository

Those pesky firewalls Create ~/.m2/settings.xml: true http proxy.habuma.com 8080 mwalls letmeout01

What if a JAR isn’t in repository? If it’s open source, look again. It’s probably there. Licenses prevent commercial and some other (SUN) JAR files from being placed in public Maven repositories. –Options: Install in your own private corporate repository Install in your local repository

Installing JARs % mvn install:install-file -DgroupId=com.webmethods -DartifactId=glue -Dversion= Dpackaging=jar -Dfile=glue jar

Profiles

Profiles enable you to override certain properties for different scenarios. Defined in section: itest … Enacted with -P switch on command line.

Trick: Excluding integration tests In normal SureFire plugin maven-surefire-plugin **/*ITest* Test classes whose names end with “ITest” won’t be run.

Excluding integration tests(part 2) In “itest” profile itest org.apache.maven.plugins maven-surefire-plugin none Run integration tests with… % mvn test -Pitest

Project relationships

Parent POMs Projects can inherit project details from parent projects. –Properties, build details, and even dependencies are inherited Unless declared otherwise, a POM inherits from the “Super POM” –Think of it as Maven’s java.lang.Object Use in child POM: com.habuma basepom 1.0

Multi-module projects Base projects with POM containing… – pom – … Child projects to build individual JARs, WARs, etc. Could inherit common properties and dependencies from base project Child projects could be built individually or all at once (by building base project)

Archetypes

Zero to working app in 10 secs Archetypes are great way to kick-start a project. Running archetype generates a baseline project structure, ready to build. You add project details.

Running an archetype % mvn archetype:create -DarchetypeGroupId=com.habuma -DarchetypeArtifactId=spring-webapp-archetype -DarchetypeVersion=1.0 -DgroupId=com.habuma -DartifactId=MySillyWebApp -Dversion=0.1

Creating an archetype Build a project with the following structure:

An archetype’s pom.xml com.habuma spring-webapp-archetype maven-plugin 1.0

META-INF/archetype.xml webapp src/main/java/HomeController.java src/main/java/AddressFormController.java src/main/java/Address.java src/test/java/HomeControllerTest.java.project.classpath.springBeans src/main/webapp/WEB-INF/web.xml src/main/webapp/WEB-INF/mvc.xml …

archetype-resources Where the project template lives Includes any resources and source code that needs to be included in generated project. Source files are “packaged” automatically (be sure to include ${package} in.java files). Text files are filtered and placeholders are replaced.

Site generation

Developer list craig Craig Walls Head honcho Developer habuma.com -5

Continuous Integration Cruise Control

Issue Management JIRA jira.habuma.com

Licenses Apache License, Version repo

Mailing Lists Poker Service Mailing List

Reporting: JavaDoc maven-javadoc-plugin

Reporting: Java XRef org.codehaus.mojo jxr-maven-plugin

Reporting: Test coverage org.codehaus.mojo cobertura-maven-plugin

Reporting: Test reports org.apache.maven.plugins maven-surefire-plugin

Reporting: JDepend org.codehaus.mojo jdepend-maven-plugin

Additional site content Placed in src/site/… –…/apt : Almost plain text –…/fml : FAQ markup –…/xdoc : XDoc files –site.xml : Site structure

Final tips, gotchas and help

Tips & Gotchas Resolve dependency ambiguities manually Avoid SNAPSHOT dependencies Only deploy non- SNAPSHOT dependencies once Not all projects have quality POM files Be careful when upgrading Maven--test first!

Maven help help:active-profiles –Lists the profiles that are currently active for the build help:effective-pom –Displays the effective POM for the current build, with active profiles factored in help:effective-settings –Prints out calculated settings for the project, given any profile enhancement and the inheritence of global settings into the user settings. help:describe –Describes a plugin and its attributes

Q & A Feel free to ask by anytime: Recommended reading:

Thank you! Have a great day! Remember to return evaluations!