25
Project Management

03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Project Management

Page 2: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Software Projects

Composed of several modules

Use third-party libraries

Needs to be maintained

DEVELOPMENT IS NOT ONLY CODING

Page 3: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Development process

Building

Dependency management

Documentation

Reports and metrics

Testing

Packaging

Deployment

Page 4: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Developers should care only of the configuration and then tools should perform

the required actions

We need automation

Automation saves time and makes the process easily reproducible

Page 5: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

The maven approachFully automated project

management tasks

Easily extensible via plug-ins to get more features

Pre-defined phases to support the development lifecycle

Page 6: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Build lifecycleComposed of several phases

ValidateCompile

TestPackageInstall

Deploy

You are not going to miss something. Each phases requires the correct execution of the previous

Page 7: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Validate

Maven checks that the project is properly configured.

Correctness of the configuration file

Availability of everything needed by other phases

Page 8: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Compile

This phase only compiles all the java files in the project

It is useful to separate dependencies needed to build the project with

others needed at later phases

Page 9: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Test

Executes tests and reports their outcome

Note: test failures will block the execution of other phases

Page 10: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Package

Creates a package (usually a jar) containing the compiled code and (if

needed) other resources

Page 11: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Install

Copies the package to the local repository

Once the project is installed in a repository it can be used as a

dependency

Page 12: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Deploy

Publishes the package to a remote repository so that they can made

publicly available

Page 13: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Additional features

We can integrate plug-ins in the lifecycle adding more features.

For instance: documentation generation, reporting, metrics, ...

Page 14: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

How it works

Based on conventions

Standard directory layout

Everything is configured in a Project Object Model

(POM) file

Standard way to manage all the projects

Page 15: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Project layout

Configuration file

Non-code resources

Project code

Project test suite

Packages, intermediate files, ...

Page 16: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

A simple POM file<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>

<groupId>it.polimi.dei</groupId> <artifactId>esercitazioniIngegneriaDelSoftware</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging>

<name>esercitazioniIngegneriaDelSoftware</name> <url>http://maven.apache.org</url>

<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>

<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies></project>

Page 17: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Dependency management

traditional way with mavenSearch for the library

Download and configure the required dependencies

Set-up everything again for runtime

Tell maven what you need

Page 18: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Example

<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>11.0</version> <type>jar</type> <scope>compile</scope></dependency>

We want to add Google guava library

Everything we need to do is to add this lines to the POM!

Page 19: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Example

What if you want to use a library just for testing?

Everything we need to do is to add this lines to the POM!

<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency>

Page 20: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Dependency management

Support for multiple library versions

System repository to avoid library duplication

Remote repository with a lot of software available

Page 21: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Building

No need to manually invoke the compiler

Projects are build accordingly to the information in the POM

Maven know where to find source files, libraries and how to build the application

Page 22: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Testing

Crucial to ensure that the application is working properly

Maven integrates with jUnit

Every time the application is packaged, the test suite is run

Page 23: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Packaging

The compiled files are packaged in a single archive

Maven supports several packages: jar, war, ...

Package is available in the target directory

Page 24: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

ReportingMakes it easier to generate reports for the projects

API Documentation

Test results and coverage

Code quality

Everything can be made available on a website

Page 25: 03 - Project Management and Source Controlpeople.csail.mit.edu/am/ingsw/ProvaFinale_01_maven.pdfUseful commands package install test Compilation, testing and JAR generation Packaging

Useful commands

package

install

test

Compilation, testing and JAR generation

Packaging and copy to the local repository

Unit testing

site Generates project site

clean Deletes target directory