+ All Categories
Home > Documents > Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML!...

Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML!...

Date post: 22-May-2020
Category:
Upload: others
View: 5 times
Download: 0 times
Share this document with a friend
22
Roberto Cortez Jfokus 2016 Maven Taming the Beast
Transcript
Page 1: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Roberto Cortez Jfokus 2016

Maven Taming the Beast

Page 2: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Roberto Cortez Speaker, Blogger, Triber, Passionate Developer

twitter: @radcortez

mail: [email protected]

blog: http://www.radcortez.com

Page 3: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Do you hate Maven?

Page 4: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

It’s slow!

It’s verbose!

It’s XML!

Steep Learning Curve!

It’s complex!

It’s hard to extend!

It’s unreliable!

Page 5: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Popularity

Source: Rebellabs

Page 6: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Facts

• It’s around for more than 10 years

• All developers run into problems

• New developers go through the same hard

learning process

Page 7: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Learn how to play with it!

• What are the most common pitfalls?

• How to fix them or debug them?

• Save countless hours of pain and frustration

Page 8: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Why is this JAR in my Build?

POM Dep

Dep’’

Dep’’

Dep’

Dep’

Dep’

Dep’’’

Transitive Dependencies

Page 9: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Why is this JAR in my Build?

• Use mvn dependency:analyze

• Exclude unneeded dependencies

• Some trial and error involved

Page 10: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t see my changes!

• Dependencies are not build in the local repo

• Dependency version is not correct

• Remote repo has overwritten changes

Page 11: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t see my changes!

POM

DepA

DepB

LocalRepo

RemoteRepo

Code Change

Local Install

mvn install

Page 12: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t see my changes!Dependency Mediation

POM

C

Dv1

A

B

Dv2

Who Wins?

Dv1

Page 13: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t see my changes!

• Use mvn dependency:tree

• SNAPSHOT versions from remote may override

your local changes

Page 14: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

A JAR is not being included!

• Usually related with Dependency Scopes

• Might also be excluded somewhere

• Use mvn dependency:list

Page 15: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t find the Artifact!

• “Could not resolve dependencies… Could not

find artifact”

• Even worst than the Java NPE

Page 16: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

I can’t find the Artifact!• Dependency defined correctly?

• Remote repo contains the artifact?

• Most recent pom version?

• Jar is corrupted?

• Cached artifact?

• Dependency overriden?

Page 17: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Weapons of Choice

• mvn help:effective-pom

• mvn -Dmaven.repo=/temp/20160210/.m2

• mvn -o

Page 18: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Bonus: Speedup your Build

• Build in parallel

• Build only the modules you need

• You should know about offline, right?

Page 19: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Bonus: Speedup your Build

• mvn -T 1C install

• mvn install -pl moduleName -am / -amd

• mvn install -o

Page 20: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Tamed?

Page 21: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Never trust the IDE!

If it works on the command-line then it’s an IDE problem!

Page 22: Maven Taming the Beast - Jfokus · Do you hate Maven? It’s slow! It’s verbose! It’s XML! Steep Learning Curve! It’s complex! It’s hard to extend! It’s unreliable! Popularity

Thank you for Attending!

twitter: @radcortez

mail: [email protected]

blog: http://www.radcortez.com


Recommended