Maven git clone https://github.com/jonananas/maven-examples.git - - PowerPoint PPT Presentation

maven
SMART_READER_LITE
LIVE PREVIEW

Maven git clone https://github.com/jonananas/maven-examples.git - - PowerPoint PPT Presentation

Maven git clone https://github.com/jonananas/maven-examples.git Build automation Tools Automates braindraining repetitive work compiling testing creating artifacts Ensures automatic repeatable builds!


slide-1
SLIDE 1

Maven

git clone https://github.com/jonananas/maven-examples.git

Build automation Tools

  • Automates braindraining repetitive work
  • compiling
  • testing
  • creating artifacts
  • Ensures automatic repeatable builds!
  • List_of_build_automation_software
  • Make
  • Ant
  • Maven
  • npm
  • Gradle
  • SBT

Repeatable builds

  • Correct target platform
  • Correct source encoding
  • Correct dependencies incl versions
  • Correct tools including versions
  • Builds on every source platform
slide-2
SLIDE 2

Build automation Tools

  • Enabler for automated
  • Continuous Integration
  • Continuous Delivery
  • Continuous Deployment

Build Server

− Monitors source repository − Triggers on each commit − Runs command (maven, bash, …) − Keeps history − Notifies failure/Success − Examples

  • Bamboo (Atlassian)
  • Jenkins (OpenSource)
  • TeamCity (JetBrains)

Maven

  • Enables repeatable builds
  • Cleans up from earlier builds
  • Puts dependencies on classpath
  • Compiles all code
  • Runs all tests
  • Creates artifact, example project-jar-0.0.1-SNAPSHOT.jar
  • Deploys maven repository and source repository
  • Deploys to server
  • IDE agnostic way of configuring project (Intellij, Eclipse, …)
  • Filters resources
  • Runs static analysis tools

Coverage reports

  • And more!
slide-3
SLIDE 3

Maven

  • dependency management
  • maven coordinates
  • packaging
  • build phases
  • plugins
  • scopes
  • project structure
  • project file - pom.xml
  • commands
  • NyA

pom.xml

  • pom - Project Object Model
  • Information and configuration details required

to build project

Properties

  • DRY - Don’t repeat yourself
slide-4
SLIDE 4

Dependency management

Maven coordinates

  • <dependency>


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


  • https://mvnrepository.com/artifact/junit/junit/4.8.1
  • ~/.m2/repository/junit/junit/4.8.1

dependencyManagement

  • Decides which version of a dependency will be

used

  • Inherited
slide-5
SLIDE 5

Example

dependency-resolution

project structure

  • project-root/
  • pom.xml
  • src/main/java
  • src/main/resources
  • src/test/java
  • src/test/resources
  • target
  • cd project; find src

Example

  • Multimodule
slide-6
SLIDE 6

Packaging

  • packaging
  • pom
  • jar - default
  • war
  • ear

Build phases

  • Default lifecycle
  • validate
  • validate project
  • compile - compile sources
  • test
  • run tests
  • package - package in distributable format
  • verify
  • check quality criteria
  • install
  • copy into local repository
  • deploy
  • copy to remote repository

Build phases

  • Clean lifecycle
  • clean - removes all temporary files (target)
slide-7
SLIDE 7

Plugins

  • plugin
  • goal —> phase
  • maven-compiler-plugin
  • compiler:compile —> compile
  • maven-resources-plugin
  • resources:resources —> process-resources
  • maven-surefire-plugin
  • surefire:test —> test

Commands

  • Import into eclipse
  • mvn clean
  • mvn test
  • mvn package
  • mvn install
  • mvn exec:java
  • mvn deploy
  • mvn release:prepare; mvn release:perform

nya-master/3pp/tools/maven/bin/mvn

pluginManagement

  • Decides which version of a plugin will be used
  • Inherited!

<pluginManagement> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.3</version> </plugin>

slide-8
SLIDE 8

Example

  • maven-examples effective pom

bom

  • bom - Bill of Materials
  • List of several dependencies that will work

together

  • Can be imported in dependencyManagement

Scopes

  • Each dependency has a scope, compile by default
  • compile - transitive, compile, test, run phases
  • provided - non-transitive, compile, test phases
  • runtime - transitive, run, test phases
  • test - non-transitive, test phases
  • import - import dependencyManagement from bom
slide-9
SLIDE 9

Example scopes Example

  • parent och scopes

Film inför 24/4

The Magic Tricks of Testing by Sandi Metz 32 min

https://www.youtube.com/watch?v=URSWYvyc42M

För tips om hur man undviker sköra tester