CS520 Web Programming Introduction to Maven

Slides:



Advertisements
Similar presentations
Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
Advertisements

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.
1 OBJECTIVES To generate a web-based system enables to assemble model configurations. to submit these configurations on different.
Developing CAS in Eclipse
Java Build Tool Comparison HJUG - April 29th, 2009 John Tyler.
Maven: Build and project management in the 21th century.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Open source administration software for education research administration Lin-Long Shyu System Analyst Kuali Coeus Technical Team Indiana University
APACHE MAVEN Bhavana Sudharshan Jaydeep Patel. Introduction What is Maven? “Maven is a software management and comprehension tool based on the concept.
Maven and Stack Starter Michael Youngstrom. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack.
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.
LDS Account Integration. Disclaimer This is a training NOT a presentation. – Be prepared to learn and participate in labs Please ask questions Prerequisites:
Using the ALM Module Fully Automated Deployments in Stack 3.2.
Struts2 Plugin Development - Extending Struts2 Justin Yip.
INFSOM-RI Juelich, 10 June 2008 ETICS - Maven From competition, to collaboration.
Search Technologies Maven Repository (Mirror) Central Repository (repo1.maven.org) Local Repository (/users/you/.m2) Local Machine Project target Project.
Juggling Java EE with Enterprise Apache Maven Jesse McConnell -
Development Environment Matthew Sell, CSSE Student MASS Research Participant, October 2014.
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.
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 for building Java applications By Nalin De Zoysa
UAB Versioning: Definition 1 07/05/2014. Summary UAB component definition UAB component release UAB component query UAB component installation Create.
Build Systems Presentation December 14, 2015 Noon-1pm Kathy Lee Simunich Bldg. 203/ D120 Brought to you by: Argonne Java.
Software Deployment & Release 26/03/2015 1EN-ICE.
Time to apply stuff… Faculty of Mathematics and Physics Charles University in Prague 5 th October 2015 Workshop 1 – Java Wrestling.
8/29/10 Maven Repository Management with Nexus Jim McMahon.
CS520 Web Programming Bits and Pieces of Web Programming (II) Chengyu Sun California State University, Los Angeles.
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.
The Maven Alfresco SDK™ At the end of a journey, there is always a new beginning…
Maven and Jelly James Strachan. Introduction Maven and Jelly are both Apache projects at Jakarta Ultimately both will be top.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
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.
CS3220 Web and Internet Programming Introduction to Java Servlets
CS3220 Web and Internet Programming RESTful Web Service
CS5220 Advanced Topics in Web Programming Version Control with Git
with Some Eclipse Tricks included Safa Bacanlı Fall 16
Maven 04 March
Build Automation with Gradle
What are they? The Package Repository Client is a set of Tcl scripts that are capable of locating, downloading, and installing packages for both Tcl and.
Plan What is Maven ? Links : mvn command line tool
External Web Services Quick Start Guide
Bhavana Sudharshan Jaydeep Patel
CS520 Web Programming Bits and Pieces of Web Programming (II)
Play Framework: Introduction
Data Virtualization Demoette… JDBC Clients
Test Driven Development
prepared by hasan.we4tech.com
UAB Development Status
CS5220 Advanced Topics in Web Programming Version Control with Git
Project management and comprehension tool
Chengyu Sun California State University, Los Angeles
Maven IIB9 Plug-in Version 9.0
With Some Eclipse Tricks included.
JavaTeaching and Importing a github repository
Mark Dönszelmann Stanford Linear Accelerator Center
ESIS Consulting LLC (C) ESIS Consulting LLC. All rights reserved
Maven IIB9 Plug-in Version 9.0
Escidoc build and development environment
Rapid Deployment Models for uPortal -or- "Fast Times at Portal High"
CS3220 Web and Internet Programming Introduction to Java Servlets
Rapid Deployment Models for uPortal -or- "Fast Times at Portal High"
CS4961 Software Design Laboratory Understand Aquila Backend
Práctica 1.
Software Engineering and Architecture
Presentation transcript:

CS520 Web Programming Introduction to Maven Chengyu Sun California State University, Los Angeles

Build Preprocessing Compilation Postprocessing Distribution Deployment

What is Maven? Mostly used as a build tool for Java projects It is more than a build tool Project Object Model (POM) Project lifecycles Dependency management Plugin framework It is a project management tool

A Simple Maven Example pom.xml <project> <modelVersion>4.0.0</modelVersion> <groupId>edu.calstatela.cs520</groupId> <artifactId>maven-example</artifactId> <version>1.0</version> </project> Run: mvn compile mvn package

pom.xml and modelVersion pom.xml is a complete description of the project modelVersion is the version of the “grammar” of the description

Maven Coordinates groupId artifactId version packaging, default: jar Name of the company, organization, team etc., usually using the reverse URL naming convention artifactId A unique name for the project under groupId version packaging, default: jar classifier Maven coordinates uniquely identifies a project.

Convention Over Configuration Systems, libraries, and frameworks should assume reasonable defaults. See the Effect POM tab of pom.xml in Eclipse for all the “defaults”.

Default Directory Structure src/main/java src/main/resources for files that should be placed under classpath src/main/webapp for web applications src/test/java target

How Does Maven Work? Q: what happens when you run mvn compile? A: Maven will go through each phase of the build lifecycle up to the compile phase, and run the operations associated with each phase

Build Lifecycle The process for building and distributing a project A build lifecycle consists of a number of steps called phases. http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

About Lifecycle Phases Not all projects utilize all phases Not all phases have operations associated with them

Example: mvn compile Phase Operation(s) validate initialize generate-sources process-sources resources generate-resources process-resources compile

Goals and Plugins Goals, a.k.a. Mojos, are operations provided by Maven plugins

Some Maven Plugins resources compiler surefire jar, war http://maven.apache.org/plugins/index.html

Example of Using a Plugin <build><plugins><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <executions><execution> <id>default-compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> <configuration> <target>1.7</target> </configuration> </execution></executions> </plugin></plugins></build>

About The Plugin Example A plugin is uniquely identified by its coordinates just like any other project Goals are associated (i.e. bound) to a build lifecycle phase The behavior of a goal can be customized with additional parameters in the <configuration> section

Run a Maven Build mvn <phase> Maven will go through each build lifecycle phase up to the specified phase In each phase, execute the goals bound to that phase

Run a Maven Build in Eclipse Need the m2e Eclipse plugin Right click on the project then select Run As  Maven Build … Give the build a name Enter the phase name for Goals Click Run

Why Not Just Use an IDE Can your IDE do everything you want? Deploy a web application to a remote server Generate source code from some metadata files Create a zip package of selected files for homework submission …

Why Use Maven Everybody uses it! Common framework for project build and management Project Object Model Build lifecycles Archetype Dependency management Resource filtering

Archetype An archetype is a template for a Maven project which can be used to create new projects quickly Example: creating a project from archetype maven-archetype-quickstart maven-archetype-webapp Users can create new archetypes and publish them through catalogs Main Maven archetype catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml

Dependency Management A dependency of a project is a library that the project depends on Adding a dependency to a project is as simple as adding the coordinates of the library to pom.xml Maven automatically downloads the library from an online repository and store it locally for future use

Dependency Example Add a dependency to pom.xml <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> </dependency> </dependencies> Add a dependency to pom.xml Add a dependency in Eclipse

Dependencies and Repositories Search for dependency coordinates at http://mvnrepository.com/ Maven Central Repository - http://repo.maven.apache.org/maven2/ Additional libraries and repositories - https://maven.nuxeo.org/

More About Dependency Management Dependencies of a dependency are automatically included Dependency conflicts are automatically resolved See CSNS2 for example

Resource Filtering Use placeholders in resource files and replace them with actual value during the build process <param name="File" value="${app.dir.log}/csns2.log" /> <param name="File" value="F:/TEMP/csns2/csns2.log" />

Resource Filtering Example <build> <filters> <filter>build.properties</filter> </filters> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>

Summary Project Object Model (POM) Coordinates Lifecycles and phases Plugins and goals Archetype Dependency management Resource filtering

Further Readings Free online Maven books - http://www.sonatype.com/resources/books