Slide 1

Slide 1 text

What I wish I Knew About

Slide 2

Slide 2 text

@aalmiray | andresalmiray.com Andres Almiray Seasoned Sourceror @ Oracle Java Champion Hackergarten github.com/aalmiray

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

@aalmiray | andresalmiray.com Override Project Properties

Slide 9

Slide 9 text

@aalmiray | andresalmiray.com mvn -Dkey=value • Properties may be defined • In a block • By plugins • Property values defined on the command line have precedence

Slide 10

Slide 10 text

DEMO

Slide 11

Slide 11 text

@aalmiray | andresalmiray.com mvn G:A:V:goal

Slide 12

Slide 12 text

@aalmiray | andresalmiray.com Invoke plugins on the go • Any plugin may be applied using the long notation G:A:V:goal, in other words mvn com.github.ekryd.echo-maven-plugin:echo-maven- plugin:1.2.0:echo -Decho.message="Hello World!"

Slide 13

Slide 13 text

DEMO

Slide 14

Slide 14 text

@aalmiray | andresalmiray.com Dependency Resolution

Slide 15

Slide 15 text

@aalmiray | andresalmiray.com Dependencies • Dependencies defined in a block are known as direct dependencies. • Dependencies brought by direct dependencies are known as transitive dependencies. • Maven resolves dependencies by locality
 - direct in the current POM. Last found wins (closest).
 - direct in the parent hierarchy.
 - transitive in the hierarchy based on number of hops to reach it. First found wins.

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

DEMO

Slide 22

Slide 22 text

@aalmiray | andresalmiray.com Semantic Versioning? https://twitter.com/rfscholte/status/1243226856914063360

Slide 23

Slide 23 text

@aalmiray | andresalmiray.com Use the block!

Slide 24

Slide 24 text

@aalmiray | andresalmiray.com http://maven.apache.org/enforcer/maven-enforcer-plugin/

Slide 25

Slide 25 text

@aalmiray | andresalmiray.com maven-enforcer-plugin https://twitter.com/aalmiray/status/1243515942560313350

Slide 26

Slide 26 text

http://andresalmiray.com/maven-dependencies-pop-quiz-results

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

http://andresalmiray.com/maven-dependencies-pop-quiz-results

Slide 29

Slide 29 text

@aalmiray | andresalmiray.com Surviving Dependency Hell with Maven https://saturnism.me/talk/surviving-dependency-hell-maven/

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

@aalmiray | andresalmiray.com mvn verify • The Reactor knows how to build all requirements. • The install goal should only be used when artifacts must be published to the local repository. • Invoking clean diminishes the reuse of intermediate results -> defeats incremental builds.

Slide 36

Slide 36 text

@aalmiray | andresalmiray.com Broken Buildtools and Bad Behaviors; The Maven Story by Robert Scholte https://www.youtube.com/watch?v=2HyGxtsDf60

Slide 37

Slide 37 text

@aalmiray | andresalmiray.com mvn -am -pl

Slide 38

Slide 38 text

@aalmiray | andresalmiray.com Partial Execution • Maven runs multi-project builds inside a Reactor. • The Reactor executes goals for all projects. • mvn -pl executes the given goals for all projects in • mvn -am -pl also executes for all prerequisites in the Reactor

Slide 39

Slide 39 text

DEMO

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

@aalmiray | andresalmiray.com Restrictions • All invoked plugin goals must exist in every project! • Define common plugins in parent POMs using a combination of and . • You’d be forced to define dummy values for plugins in some cases.

Slide 42

Slide 42 text

DEMO

Slide 43

Slide 43 text

@aalmiray | andresalmiray.com Aggregating POMs

Slide 44

Slide 44 text

@aalmiray | andresalmiray.com Aggregating POMs • These POM files define a section. • They are typically also parent POMs but they DO NOT have to be! • Also, values in are paths, not project names.

Slide 45

Slide 45 text

@aalmiray | andresalmiray.com File Structure & POM

Slide 46

Slide 46 text

DEMO

Slide 47

Slide 47 text

@aalmiray | andresalmiray.com BOM Files

Slide 48

Slide 48 text

@aalmiray | andresalmiray.com BOM Definition

Slide 49

Slide 49 text

@aalmiray | andresalmiray.com BOM Consumption

Slide 50

Slide 50 text

DEMO

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

@aalmiray | andresalmiray.com Resources • https://blogs.oracle.com/developers/mastering-maven- the-series • https://cguntur.me/2020/05/20/understanding-apache- maven-the-series • https://kordamp.org/kordamp-gradle-plugins

Slide 53

Slide 53 text

@aalmiray | andresalmiray.com The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle’s products may change and remains at the sole discretion of Oracle Corporation. Statements in this presentation relating to Oracle’s future plans, expectations, beliefs, intentions and prospects are “forward-looking statements” and are subject to material risks and uncertainties. A detailed discussion of these factors and other risks that affect our business is contained in Oracle’s Securities and Exchange Commission (SEC) filings, including our most recent reports on Form 10-K and Form 10-Q under the heading “Risk Factors.” These filings are available on the SEC’s website or on Oracle’s website at http://www.oracle.com/investor. All information in this presentation is current as of September 2019 and Oracle undertakes no duty to update any statement in light of new information or future events. Safe Harbor Statement

Slide 54

Slide 54 text

@aalmiray | andresalmiray.com