Simplified Build Management with Maven

Similar documents
Maven. INF5750/ Lecture 2 (Part II)

What is Maven? Apache Maven is a software project management and comprehension tool (build, test, packaging, reporting, site, deploy).

Apache Maven. Created by anova r&d bvba

Pour aller plus loin : Programmation outillée

MAVEN INTERVIEW QUESTIONS

Topics covered. Introduction to Maven Maven for Dependency Management Maven Lifecycles and Plugins Hands on session. Maven 2

Content. Development Tools 2(57)

Set up Maven plugins in Eclipse. Creating a new project

Package Management and Build Tools

Apache Maven MarsJUG. Arnaud Héritier exo platform Software Factory Manager

Maven Introduction to Concepts: POM, Dependencies, Plugins, Phases

Maven POM project modelversion groupid artifactid packaging version name

MAVEN MOCK TEST MAVEN MOCK TEST I

4. Check the site specified in previous step to work with, expand Maven osgi-bundles, and select slf4j.api,

Component based Development. Table of Contents. Notes. Notes. Notes. Web Application Development. Zsolt Tóth

Why switch exist-db from Ant to Maven?

... Fisheye Crucible Bamboo

Struts 2 Maven Archetypes

MAVEN MOCK TEST MAVEN MOCK TEST IV

Software Engineering - Development Infrastructure 2. Kristjan Talvar Nortal

Maven in the wild. An introduction to Maven

I Got My Mojo Workin'

Repository Management and Sonatype Nexus. Repository Management and Sonatype Nexus

Setting up a Maven Project

Session 24. Spring Framework Introduction. Reading & Reference. dev.to/lechatthecat/how-to-use-spring-boot-java-web-framework-withintellij-idea-202p

Hello Maven. TestNG, Eclipse, IntelliJ IDEA. Óbuda University, Java Enterprise Edition John von Neumann Faculty of Informatics Lab 2.

TIBCO StreamBase 10.2 Building and Running Applications in Studio, Studio Projects and Project Structure. November 2017

Administering Apache Geronimo With Custom Server Assemblies and Maven. David Jencks

Maven 2 & Continuum. by Trygve Laugstøl

DevOps and Maven. Eamonn de Leastar Dr. Siobhán Drohan Produced by:

maven Build System Making Projects Make Sense

AUTOMATION TESTING FRAMEWORK FOR LUMINOUS LMS

Introduction to project industrialization using Maven YaJUG 06/10/2009. Copyright Pierre-Antoine Grégoire License Creative Commons 2.

Maven 2 The powerful buildsystem. a presentation for EL4J developers by Martin Zeltner (MZE) November 2007

Produced by. Agile Software Development. Eamonn de Leastar

MANUAL DO ALUNO DE ENGENHARIA DE SOFTWARE

Getting started with Geomajas. Geomajas Developers and Geosparc

Software Building (Sestavování aplikací)

Sonatype CLM - IDE User Guide. Sonatype CLM - IDE User Guide

... Maven.... The Apache Maven Project

Construction: version control and system building

MAVEN MOCK TEST MAVEN MOCK TEST III

sites</distribsiteroot>

STQA Mini Project No. 1

Sonatype CLM Enforcement Points - Nexus. Sonatype CLM Enforcement Points - Nexus

Groovy. Extending Java with scripting capabilities. Last updated: 10 July 2017

TOP REASONS WHY YOU SHOULD SWITCH TO MAVEN 3

Build Automation Kurt Christensen

Overall Design of SSS Software

SpringSource Tool Suite 2.7.1

gradle : Building Android Apps Mobel Meetup

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

EPL451: Data Mining on the Web Lab 6

FROM NOTHING TO COMPLETE ENVIRONMENT WITH MAVEN, OOMPH & DOCKER. Max Bureck, 21. June 2017

Continuous Integration & Code Quality MINDS-ON NUNO 11 APRIL 2017

Oracle Code Day Hands On Labs (HOL) (Install, Repository, Local Deploy, DevCS, OACCS)

ONAP Developer Typical Setup 2017 July ONAP Virtual Developers Event

Build Tools. Software Engineering SS 2007

The Actual Real World at EclipseCon/ALM

Fat / Uber jars - Using the Shade Plugin

The Workshop. Slides (you have a copy in the zip) Practical labs Ask questions

JDO Tools Guide (v5.1)

JPA Tools Guide (v5.0)

... SysML version SNAPSHOT Developer Guide.... Eclipse

Contents. Enterprise Systems Maven and Log4j. Maven. What is maven?

Junit. Presentation & Tools (Eclipse, Maven, Mockito, Spring)

Build Tools. Software Engineering SS A tool was needed. Agenda for today. Build tools. Software complexity. Build tools

MAVEN SUCKS NO(W) REALLY

Overview of Web Application Development

Moven. Machine/Deep Learning Models Distribution Relying on the Maven Infrastructure. Sergio Fernández (Redlink GmbH) November 14th, Sevilla

Oracle Code Day Hands On Labs HOL

Red Hat JBoss Fuse 6.2

Unit Testing. CS 240 Advanced Programming Concepts

Red Hat Fuse 7.0 Installing on Apache Karaf

Jahia Studio JAHIA DOCUMENTION

juddi Developer Guide

Gant as Ant and Maven Replacement

Packaging, automation, Continuous Integration

Apache Buildr in Action

Application prerequisites

Developing ONOS Apps

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

Apache Maven: Best Practices

GlassFish V3 Engineer's guide

mvn package -Dmaven.test.skip=false //builds DSpace and runs tests

Hello Gradle. TestNG, Eclipse, IntelliJ IDEA. Óbuda University, Java Enterprise Edition John von Neumann Faculty of Informatics Lab 2.

Red Hat JBoss Fuse 6.2.1

Red Hat JBoss Fuse 6.1

Continuous Integration INRIA

vrealize Code Stream Plug-In SDK Development Guide

Red Hat JBoss Fuse 6.3

JBoss DNA. Randall Hauch Principal Software Engineer JBoss Data Services

Action Developers Guide

Unable To The Artifact From Any Repository Maven-clean-plugin

Introduction: Manual Testing :

Jaxb2 Maven Plugin Could Not Process Schema

Tuscany: Applying OSGi modularity after the fact

CONTINUOUS DELIVERY IN THE ORACLE CLOUD

Sonatype CLM - CI User Guide. Sonatype CLM - CI User Guide

Denn n i n s i s L und n b d erg r

Transcription:

Simplified Build Management with Maven Trasys Greece Kostis Kapelonis 11/06/2010

Menu Kitchen says hi!(motivation) Starters (Maven sample pom) Soup (Maven philosophy) Main dish (Library management) Side dish (Repositories) Dessert (Lifecycle integration and reports) Coffee (Discussion) 2

Kitchen says Hi 3

Build management Now Trasys uses Ant exclusively Trees of hand-made Ant scripts Manual management of libraries Libraries in subversion (bloat!) Different projects use different scripts Custom scripts for reports/jar packaging/configurations No historical reports Minimal integration with build system 4

Maven Motivation Maven is a superset of Ant. Ant is just a build tool Maven is a build system With Ant you describe how it needs to be done With Maven you describe what needs to be done You can use Ant from Maven (Maven plugin) You can use Maven from Ant (Ant task) 5

Maven goals Unify build practices No ad-hoc build systems (different in each project) No more custom Ant scripts New developer should be up and running in minutes Dependencies (no JAR library Hell) Artifact management (jars, wars, ears) Centralized Company repository Only source code goes in SVN (the Right Thing) IDE integration Archetypes (template projects) 6

Starters 7

Maven installation Download and uncompress Maven You get mvn executable (similar to Ant) ~/.m2 directory (autocreated on first run) Settings.xml (optional) Personal repository (holds Java Libraries) You use Maven by editing a single pom.xml in a project 8

Custom Ant scripts You define EVERYTHING You write the goals You write all the steps Ant properties for file locations File grows quickly Copy/Paste from other scripts No defined standard 40 lines in XML 9

Maven sample pom.xml <project> <modelversion>4.0.0</modelversion> <groupid>eu.echa.csat</groupid> <artifactid>csat-common</artifactid> <version>1.0-snapshot</version> <packaging>jar</packaging> </project> 7 lines mvn clean compile package creates a jar Notice lack of file paths (src, build et.c.) 10

Assume we want JUnit <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.3.1</version> <scope>test</scope> </dependency> </dependencies> mvn test is now enabled With Ant you download junit and add more tasks 11

Assume we want Hibernate <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate</artifactid> <version>3.2.6.ga</version> </dependency> Hibernate is now enabled No hibernate download No extra ant stuff (shared.jars, included.jars e.t.c.) No commons, antlr, dom4j, asm e.t.c 12

Soup 13

Convention over configuration src/main/ src/main/java/ src/main/resources/ src/test/ src/test/java src/test/resources Directories can be changed (in pom.xml) These affect all maven plugins 14

Maven goals (vs Ant tasks) validate generate-sources process-resources compile test-compile test package install verify deploy Maven has 25+ predefined phases Phases are grouped in goals More goals/phases from plugins Findbugs/PMD/checkstyle Site goals 15

Maven pom file 16

Maven execution 1. Run Maven from command line 2. Parses pom.xml 3. Downloads all needed plugins if not present 4. Downloads all needed libraries if not present 5. Executes tasks 6. Reports a final result (success/fail) Netbeans has native Maven support Eclipse has a maven plugin Hudson supports Maven by default 17

Main dish 18

Maven Libraries Uses groupid, artifactid, version Supports transitive dependencies Library scopes (instead of shared.jars and included.jars) compile test provided runtime system Retrieved from public or internal (company) repository Stored on local repository (~/.m2/repository) Therefore SCM contains NO libraries 19

Ant libraries (1/2) With Ant things are complicated Manual download is needed for all libraries Locate dependencies by hand (spring, hibernate e.t.c) Copy all jars in a huge lib folder Hacks with shared.jars and included.jars Several libraries are included more than once It is not clear what project uses what Upgrading a single library might break everything 20

Ant libraries (2/2) Libraries are essentially in 3 places 1. In the lib directory 2. In shared.jars (text file for ANT) 3. In a user library in Eclipse Each new library needs 3 updates Several broken builds caused by libraries 21

Maven - Single point of truth 22

Graphical Dependencies 23

Side dish 24

Common Maven Pitfalls Maven downloads the whole internet The central repository is down The central repository does not have the latest version Closed-source library X is not in the central repository I cannot publish my library in the central repository I still need to mail my colleague with my jar These are not problems. These are symptoms and they show that you use Maven wrong. 25

Using Maven the wrong way 26

Internal Company Repository 27

Internal Maven repository benefits Caching artifacts Manually add 3 rd party artifacts Publish company artifacts (e.g Trasys commons) Get an overview of all libraries used in all projects Executives can verify Trasys policies (Legal, licences) Developers can even publish snapshots Graphical GUI for artifact management Interactive search for artifacts 28

Artifact browser (Nexus) 29

Dessert 30

Maven site Out of the box site building Contains general information (Company, developers) Test reports (JUnit, coverage) Quality reports (PMD, Checkstyle, Findbugs) Other reports (Javadoc, jdepend, xref e.t.c) Hierarchical analysis of dependencies Fully customizable using CSS Created by mvn site Can even be deployed automatically via SFTP 31

Maven site sample (vanilla) 32

Maven hudson Hudson has native support for Maven It can display graphically all quality reports Graphical reports can show progress over time With Ant this is simply not done now (in Trasys) Hudson can even publish artifacts in a repository Developers can get latest version from other projects Hudson is also aware for parent and child Maven projects 33

Hudson Maven reports 34

Coffee Thank you 35

Backup slides Maven archetypes Build profiles Alternatives to Maven Using Ant from Maven Using Maven from Ant Sonar 36

Maven archetypes Usually programmers start a project with copy/paste Get the base structure from an old project Maven has project templates (archetypes) Several archetypes (simple, spring-osgi, myfaces) Using an archetype 1. Creates the basic directories (Maven format) 2. Adds needed libraries (e.g Wicket libraries) 3. Preconfigures files (e.g. Wicket servlet in web.xml) 37

Maven Archetype - IDE 38

Build profiles (1/2) <profiles># <profile> <id>production</id># <build># <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <configuration> <debug>false</debug># <optimize>true</optimize> </configuration> </plugin> </plugins> </build> </profile> </profiles> 39

Build profiles (2/2) <profiles> <profile> <id>production</id> <properties> <jdbc.driverclassname>oracle.jdbc.driver.oracledriver</jdbc.driver ClassName> <jdbc.url>jdbc:oracle:thin:@proddb01:1521:prod</jdbc.url> <jdbc.username>prod_user</jdbc.username> <jdbc.password>s00p3rs3cr3t</jdbc.password> </properties> </profile> </profiles> 40

Alternatives There is also Ivy (dependency Management) It is Maven versus Ant+ Ivy Ivy uses the Maven repository format Gradle recently appeared Gradle geared towards Groovy Gradle is Ivy and Maven compatible 41

Using Ant from Maven <id>ftp</id> <phase>deploy</phase> <configuration> <tasks> <ftp action="send" server="myhost" remotedir="/home/test" userid="x" password="y" depends="yes" verbose="yes"> <fileset dir="${project.build.directory}"> <include name="*.jar" /> </fileset> </ftp> <taskdef name="mytask" classname="com.acme.mytask" classpathref="maven.plugin.classpath"/> <mytask a="b"/> </tasks> </configuration> 42

Using Maven from Ant <target name="minstall" depends="initmaven,jar" description="install all parts of this project in a local Maven repository"> <artifact:install file="${build.lib}/${maven.project.artifactid}.jar"> <pom refid="maven.project"/> </artifact:install> </target> 43

Sonar DashBoard 44