When builds are broken, there are some potential root causes: Maven; a Maven plugin; or, well, the developer. This session shows you some use cases, how Maven tried to improve them, and how such changes were or weren’t picked up by the community. It will demonstrate some interesting best practices and plus guide you though to changes, explaining how and why they were implemented.
2. Comair Flight 3272
Date January 9, 1997
Location 18 miles (29 km) southwest of Detroit
Metropolitan Wayne County Airport
Fatalities 26 passengers + 3 crewmembers
Summary Atmospheric icing and pilot error
leading to loss of control.
3.
4. Probable Cause
“…This was because the Comair Flight manual
recommendation was in contravention of the
manufacturers due to a concern over "bridging",
a concern held-over from older planes that was
no longer valid on newer generation planes like
the Embraer 120.”
5. Probable Cause
“…This was because the Comair Flight manual
recommendation was in contravention of the
manufacturers due to a concern over "bridging",
a concern held-over from older planes that was
no longer valid on newer generation planes
like the Embraer 120.”
10. Broken build or
broken tools?
“… but it works on my machine”
CI server is your neutral judge
11. Builds of Maven subprojects at ASF
JDK 7 JDK 8 JDK 11 JDK 12 JDK 13-ea
V V V V V
JDK 7 JDK 8 JDK 11 JDK 12 JDK 13-ea
Maven 3.0.5 V
Maven 3.2.5 V
Maven 3.3.9 V
Maven 3.5.2 V
Maven 3.6.1 V V V V V
Frameworks /Libraries
Plugins / Extensions
Operation Systems: Ubuntu + Windows
12. “Works on my machine”
Differences in:
- (local code changes)
- OS
- JDK
- Maven
- Files (Regular/Directories)
- Properties (System/Environment)
13. Analysis
Options Description
-v,--version Display version information
-V,--show-version Display version information WITHOUT
stopping build
-e,--errors Produce execution error messages
-X,--debug Produce execution debug output
14. “Works on my machine”
Differences in:
- OS
- JDK
- Maven
- Files (Regular/Directories)
- Properties (System/Environment)
16. Local Repository “Broken”(1)
Maven 2: dumb cache
Maven 3: cached artifacts verified for existence with
_remote.repositories
Options Description
-llr,--legacy-local-
repository
Use Maven 2 Legacy Local Repository behavior, i.e. no
use of _remote.repositories.
Can also be activated by using
-Dmaven.legacyLocalRepo=true
17. Local Repository “Broken”(2)
■ Maven was written for single user
■ CI server can be considered multi user
– Corrupt files due to concurrent writes/reads
■ Solution:
– Takari Concurrent Local Repository
18. Local Repository “Broken”(3)
■ Checksums are NOT verified by default, repository managers (should) do
■ Set checksumPolicy per repository
■ Future solutions:
– Enable by default
Options Description
-C,--strict-checksums Fail the build if checksums don't match
-c,--lax-checksums Warn if checksums don't match
19. Local Repository “Broken”(4)
■ Maven 2+3: single directory
– Difficult to maintain
■ Future solutions:
– separate SNAPSHOT directory?
– directory per remote repository?
22. Dependency
Resolution “Broken”
Maven 2:
- Not aware of ‘reactor’
- Dependencies had to exist in
local repo.
Maven 3:
- ‘reactor’ aware
- No need for ‘install’ anymore
24. Preferred flow
■ LOCAL:
– mvn verify
– Commit / Push
■ CI Server :
– mvn deploy ( without install(?) )
■ All can have same SNAPSHOTs as served
by the repository manager
25. Lifecycle “Broken”
■ mvn <phase> on multimodule project:
– phase1 .. <phase> on module1
– phase1 .. <phase> on module2
– phase1 .. <phase> on module3
– ...
– phase1 .. <phase> on moduleN
How about calling ‘mvn deploy’ and module3 is broken...
26. 1 2 3 4 5 6 7
validate
compile
test-compile
test
package
install
deploy
DISTRIBUTION
PREBUIL
D
Phases
27. ■ Ideally Maven executes like this:
– Validation on all modules
– Build phases on all modules
– Distribution on all modules
■ Maven Install Plugin has experimental
feature: installAtEnd
■ Maven Deploy Plugin has experimental
feature: deployAtEnd
29. “Maven downloads the
internet”
■ Maven downloads all required files as
defined by your projects:
– Dependencies / parents
– plugins
– extensions
30. Logging
■ Aim for a clean Maven output
– Never write to System.out / System.err
– Don’t log during testing (loglevel=off)
– In the extreme, run Maven with -q or --quiet
31. Files
Delete and re-place
(same) files is waste
of resources
Most maven-plugins
are aware if they
must execute their
task
Avoid “clean”
33. “Works on my machine”
Differences in:
- OS
- JDK
- Maven
- Files (Regular/Directories)
- Properties (System/Environment)
34. Property resolution
■ Pom.xml ( <properties/>)
■ Settings.xml (<profile><properties/></profile>)
■ System properties
■ User properties ( -Dkey=value )
35. Properties “Broken”
■ ‘mvn deploy -Djava.version=12’
■ ‘mvn deploy -Dspring.version=1.0’
■ DON’T EVER DOTHIS
■ REALLY, DON’T EVER DOTHIS
■ Maven should provide the “updated” pom
36. Version is “Broken” (1)
■ Avoid conflict with branch merging
■ Isolating user stories at runtime: make version unique ( 3.1.0-JIRA101-
SNAPSHOT )
■ Maven 3.5.0 comes with special CI-Friendly placeholders:
– revision
– sha1
– changelist
■ Multimodules require a hack to rewrite pom
37. Version is “Broken” (2)
<parent>
<groupId/>
<artifactId/>
<version/>
<relativePath/>
</parent>
■ Build:
Or <RelativePath>
Or <GroupId> +
<ArtifactId> +
<Version>
■ Dependency (consume)
<GroupId> +
<ArtifactId> +
<Version>
43. Be like a responsible pilot
UNDERSTAND
EVERY PLUGIN
STAYCURIOUS, KEEP
INFORMED
QUESTION
OUTDATED
ANSWERS
IMPROVE
INFORMATIONAT
THE SOURCE
44. Up-For-Grabs
■ ~60-80% of Java Project/Developers use Maven
■ The Apache Maven Project holds ~95 (sub)projects
■ Maintained by ~5-10 active volunteers (No Company!)
■ Let’s restore the balance!
■ https://s.apache.org/up-for-grabs_maven
■ https://maven.apache.org/guides/development/guide-committer-school.html