Maven - GitHub Pages

2y ago
16 Views
2 Downloads
4.19 MB
75 Pages
Last View : 7d ago
Last Download : 3m ago
Upload by : Adele Mcdaniel
Transcription

arnaud.nauwynck@gmail.comMavenIntroduction to Concepts:POM, Dependencies, Plugins, PhasesThis en-Intro-Concepts.pdf

31M!!What is Maven ?

https://maven.apache.org/

A software project management andcomprehension tool.Based on a project object model (POM),. project's build, reporting and documentation.

ven-in-five-minutes.htm l

ven-in-five-minutes.htm l

Wikipedia

Maven is a Build Automation Toolpom.xml dependencies plugins packaging phase

1st, it describeshow software is built,2nd, it describesits dependencies. use conventions for build

Ant portable Makein xmlfor Javac, Jar, .200520072010Maven 1Maven 2 Ant Jelly Java Mojo xml build tasks pom.xml scripts( if , var .) rules / lifecycle ile?Maven History2017 ?Maven 3? Split better & compatible pom vs buildoptional .mvnw pom inyaml, groovy, .( not widespread )Yaml / groovy

Authors, Company, CommunityJason Van ZylWorked on TurbineAuthor of- Velocity- MavenSonatype Company( core Contributor Product Nexus )Apache Fondation Open Source Communityfounder of SonatypePMC Chair / Member / Contributor / Plugin-Developpers / Users

Maven Adoption68% uses mavenIt JUST Work !!4.5 Millions publishedartifacts ( jars)

Yet Another Build ToolMakefile, Imake, Cmake,Ant, Maven, Gradle,MsBuild, Sbt, Gulp, Grunt,.

Declarative vs ImperativeDescribe WHAT not HOW

ImperativeDo 1/ This,Then 2/ That,Then 3/ Also That And N/ You have finishedyou want to restart ?

ImplicitConvention over ConfigurationGiven standardsWhen You follow themThen it just works

ImplicitConvention over Configurationa Java Program is src/*.java filescompiled in classes/*.classusing javac classpathassembled in jar filetested with Junit testbla bla bla

Implicit Declarative Surprising Magic .

Maven Core Concepts 1 :(declarative) Project Object Model

Mandatory GAV DeclarationUnique ID : GAV Group / Artifact / VersionGroup like dns domain name, reversecom. company , org. . , country . . . .Artifact name of the final jarnaming convention: some-library-nameVersion major.minor.fix (-SNAPSHOT)?

Optional Project Information

Example Project Information

Typical Maven Generated SiteThen yourecognisepom infosMenu whenyou seethis logoLogo comes from maven(maven-site-plugin )

Basic Declarations

Maven Core Concepts 2 :Dependencies

Dependency DeclarationDescribe WHATFirst execution:DownloadNot HOWNext execution:reuse local repository file

WHERE ?http://maven.search.org

Transitive DependenciesTransitive Relation Definition:A B and B C . then A C

Transitive Dependencies ConflictsBD version1ACD version2 ! 1

Dependencies Omitted for ConflictGiven Java ClassLoader load once each classWhen you have conflictThen 1 jar on 2 would be useless,Maven omit oldest jar version

Can Override default configurationOverride to use specific versionOverride to exclude dependency

DependencyManagementavoid duplicate version, use parent

Dependency Scopescompile *.jarsystem *.jarprovided javaProvided*.jartarget/target/classes/**.class *.jarTesttarget/test-classes/**.classRuntime

Dependency SummaryWould be more concise than xml:“junit:junit:4.12:test”Use dependencyManagementversions in parent onlydon't be too verbosetransitive dependencies implicitdon't be too implicituse exact versions, not *

ExampleGetting Started with Mvn & Eclipse

Maven Tools UsagesIn Command LineIn IDE EclipseBuit-in supportIn CI Server Jenkins.Built-in support

Maven Tools UsagesIn Command LineIn IDE EclipseBuit-in supportIn CI Server Jenkins.Built-in support

Installation Unzip export PATH1: Unzip2: export JAVA HOME & PATH

Mvn command linemvn install

mvn clean installmvn install -f ./pom.xml-o -DskipTests -Pprofile.PluginGoalsWithopt ionsSimplephasesTypical Commandsmvn springboot:run

Start Edit a Pom.xml manually ?XML Langage for Computers not for HumansYou only need this identity card :GAV group / artifact / version

New Maven ProjectCopy & Pastemvn archetype:generate New Project. mvn installmvn installImport existing project Type : mavenType: Maven ProjectChoose archetype.mvn install

EclipseImport Existing Maven Project

First Maven Project in Eclipse

Pom.xml

Standard Source Project Layout

Mvn compile (or install)

src target directoriessrccompilesrc/main/java target/classescompile-testtargetsrc/test/java target/test-classesjartarget/classes target/*.jarinstalltarget/*.jar eploy.m2/repository/. .jar r

Mvn cleansrc vs target .gitignore

Typical .gitignorefor target/, .project, .classpath, .

Project Layout Explainedby Dichotomy Questionssrc/** pom.xml .gitignoreDir / FileStored In SCMor Generated(or ignored) ?target/**.git/**.classpath.project.settings

Project Layout Explained (bis)src/main/**src/**Mainor test ?src/test/**Dir / Filetarget/**

Project Layout Explained (ter)src/mainsrcDir / p

Maven Core Concepts 3 :Plugins – Goals

https://maven.apache.org/plugins/Scroll for 100 more

.m2/repository/org/apache/mavenFirst launch mvn will download 150Mo .Plugins .

Maven .m2/repository/ /pluginsstandard plugins in local repository

Use build/pluginsUsepluginUseAnotherDeclare plugin Dependencies with GAV( as “build dependencies” but in section plugins) Plugin will register itself in build lifecyclesee next for configuring.

Plugin configuration Overridepluginconfiguration source “-source” for javac compiler list of options cf next

Eclipse Auto-Completionfor Plugin Configuration

Maven Plugin Doc Sitehttps://maven.apache.org/pluginsSee Plugin Goals & UsageIn 2016default value to changefor jdk8 !!

Configuration Override PropertiesProjectproperties

Properties Override Hierarchy (bis)User /.m2/settings.xmloverrideProject propertiesoverrideCommand Line arguments

plugins/executionsWhen processinglifecycle phase1 executionThen call plugin goalWith this parameterCan add others.

Plugin Execution onoverrideExecutionconfiguration

Command LineExplicit Plugin Goal ExecutionCall build lifecycle 1.* phase(s) sequence of plugin goalsCall explicit 1.* plugin goal(s)

Example of Plugin Goals

Plugin Internal “Mojo” Classesas simple as a “main()”executed within a project build context

Run Mojo Hello World .

Mojo Context Injection @ParameterInject from configuration sources .default properties for valuesInject the FAMOUS pom

Maven Core Concepts 4 :Build Lifecycle - Phases

Maven Phases

Register Goals Execution in PhasesExplicitGoal Executionper phase ImplicitGoal Executionper Phase

Project Type LifeCycle Phases Plugins plugin-3.0.2.jarMETA-INF/plexus/components.xml

ConclusionQuestions ?arnaud.nauwynck@gmail.comOnly a “Short”Introduction to Concepts.other d.nauwynck.free.fr/This en-Intro-Concepts.pdf

Yaml / groovy G r a d l e 2007. Authors, Company, Community Jason Van Zyl Worked on Turbine Author of - Velocity - Maven founder of Sonatype . Logo comes from maven (maven-site-plugin ) Then you recognise pom infos. Basic Declarations. Maven Core Concepts 2 : D

Related Documents:

Tutorial based on Maven training material Courtesy by Sonatype. Maven @ Jfokus 2010 Next Generation Development Infrastructure: Maven, M2Eclipse, Nexus & Hudson by Jason van Zyl 14.15-15.00, Jan 27 Also come visit Sonatype’s booth! Advanced Maven Techniques Maven in your IDE

Hands-on Maven 2 -- working with multiple project builds Installing the Maven 2.x Plug-in for Eclipse 3.2 Working with the Maven 2.x Plug-in for Eclipse 3.2 As you complete this tutorial, you will gain an appreciation and understanding of the philosophy behind the design of Maven

Mac apache-maven-3.3.3-bin.tar.gz Step 4: Extract the Maven archive Extract the archive, to the directory you wish to install Maven 3.3.3. The subdirectory apache-

Maven: The Complete Reference iii 2.3.1 Installing Maven on Linux, BSD or Mac OSX. . . . . . . . . . . . . . . . . . .12 2.3.2 Installing Maven on Microsoft Windows .File Size: 2MBPage Count: 339

Maven extends Ant to let you download dependencies Maven is a set of reusable Ant scriptlets . Maven is able to generate a web site or PDF including any documentation you care to add, and adds to that standard reports about the state of development of the project. Examples of this information can

Maven core components and plugins. Today, the work is on non-XML files to ease encoding configuration of every plugin. When working on m2eclipse, Hervé’s intent is to improve the user experience when learning Maven (Maven Ant Tasks is the first migration step I worked on) and to fix Maven i

maven archetype is a fork of the AEM archetype and adds react support and examples. demo content package provides examples for components and SPA. Maven artifact is available via maven central Javascript project The aem-react projects relies on the aem-react-js subproject, which provides the basic javascript funtionality. It is available as npm .

CUERPOS Y ROSTROS Alfredo López Austín lnstituto de Investigaciones Antropológicas - UNAM En una reseña allibro Literatura náhuatl de Arnos Segala,r Miguel León-Portilla se refiere a dos afi¡maciones que aparecen en mi li- bro Cuerpo humano e ideología:z en una ocasión para criticar mi interpretación filológica de la palabra tlacatl y en otra para contes-