SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Apache Maven supports ALL Java
ROBERT SCHOLTE @RFSCHOLTE
The good news
Apache Maven runs fine on JDK 9 ( and 10 )
Apache Maven works like heaven on JDK 11 ( and 12-ea )
Possible issues are often plugin related
Upgrading to the latest version should solve the problem
Applying a module descriptor
1. Just add your module-info.java to src/main/java
2. Upgrade maven-compiler-plugin to at least 3.8.0
3. There’s no step three
Maven will calculate which dependencies belong to the classpath and which to the module path.
No new dependency-element/scope
When two worlds collide…
Maven
Java
<= 8
Maven
Java
<= 8
Java 9+
Goals Java Platform Modular System
Reliable configuration
Strong encapsulation
The module-info.java
module com.foo.module.name
{
// reliable configuration
requires some.other.module;
// strong encapsulation
exports com.foo.package.name;
}
If you’re not careful with your modularization
you can corrupt the whole Maven Ecosystem
Library builders should be aware of the impact of their module descriptors
Application builders should recognize these issues
Revised specifications
• Jars on modulepath
• Support ALL-MODULE-PATH
• Modulenames with numbers
• Automatic module names
Jars on modulepath
Original spec only allowed directories
Maven dependencies point to a file
Directory may contain multiple jars (javadoc,sources)
ALL-MODULE-PATH
--add-modules ALL-MODULE-PATH
In short: Make all entries on the module path see each other
Module names
Déjà Vu
What is the proper module name?
What is the proper groupId and artifactId?
Modulenames with numbers
Project/product names
• AWS-EC2
• AWS-Route53
• AWS-S3
• C3P0
• DB2
• Fabric8
• H2
• JSRnnn
• OAuth2
Versioned libraries (includes
versioned packages)
• Commons-lang2
• Commons-lang3
Bridge libraries to different
versions
• Jspc-compiler-tomcatN
• Mockwire-springN
• Surefire-junitN
Close to 30.000 groupId/artifactId end with a number (Central, March 2017)
Original implementation did not allow module names ending with a number.
#VersionsInModuleNames
Some have argued that library maintainers will
be tempted to encode major version numbers,
or even full version numbers, in module names.
Is there some way we can guide people away
from doing that?
Resolution Abandon the previous proposal to
mandate that module names appearing in
source-form module declarations must both
start and end with “Java letters”. Revise the
automatic-module naming algorithm to allow
digits at the end of module names.
Module names must be
as unique as the coordinates of dependencies
Automatic module names
“… . The module name is otherwise derived from the name of the JAR file.”
NPM Javascript package
registry
Over 13500 ‘rows’ of collisions
Evidence (OCT 2016)
JIGSAW
Automatic modules are required for top-
down adoption
MAVEN
References to automatic module names
will cause collisions sooner or later
Library builders should never refer to automatic modules* and deploy to a public repository.
Application builders can choose to refer to automatic modules.
* Filename based
Application versus library
Application
Module descriptor without exports
maven-compiler-plugin logs info message in
case of automatic module usage
Library
Module descriptor with exports
Tip: Use Maven 3.5.0+ for colour support
maven-compiler-plugin logs
WARNING message in case of
automatic module usage
Automatic modules
Ease of top-down migration for application builders
But what about “in the middle” library builders?
Java Platform. It will be approachable, i.e., easy to learn and
easy to use, so that developers can use it to construct and
maintain libraries and large applications for both the Java SE
and Java EE Platforms.
JSR 376: JavaTM Platform Module System
Original Java Specification Request (JSR)
Section 2.1
Application my-app
Libraries jackson-core jackson-databind jackson-annotations my-lib
java.base
Conference example
Application my-app
Libraries (direct deps) … … … my-lib
Libraries (transitive deps)
…
… … …
Libraries (independent deps) jackson-core jackson-databind jackson-annotations
java.base
More realworld example
1currency-1.0.jar
2buy-service-1.0.jar
module org.moneylibs.buy
{
requires currency;
}
3currence-2.0.jar
module org.moneylibs.currency
{
}
4sell-service-1.0.jar
module org.moneylibs.sell
{
requires org.moneylibs.currency;
}
5animalmarket-1.0.jar
module com.animalmarket
{
requires org.moneylibs.buy;
requires org.moneylibs.sell;
}
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.animalmarket</groupId>
<artifactId>animalmarket</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<!-- the dependencies -->
</dependencies>
</project>
<dependency>
<groupId>org.moneylibs</groupId>
<artifactId>buy-service</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.moneylibs</groupId>
<artifactId>sell-service</artifactId>
<version>1.0</version>
</dependency>
animalmarket.jar
(com.animalmarket)
requires o.m.buy;
requires o.m.sell;
buy-service-1.0.jar (o.m.buy)
requires currency;
sell-service-1.0.jar (o.m.sell)
requires o.m.currency;
animalmarket.jar
(com.animalmarket)
requires org.moneylibs.buy;
requires org.moneylibs.sell;
buy-service-1.0.jar (o.m.buy)
requires currency;
currency-1.0.jar
(currency)
sell-service-1.0.jar (o.m.sell)
requires org.moneylibs.currency;
currency-2.0.jar
(o.m.currency)
animalmarket.jar
(com.animalmarket)
requires o.m.buy;
requires o.m.sell;
buy-service-1.0.jar (o.m.buy)
requires currency;
currency-1.0.jar
(currency)
sell-service-1.0.jar (o.m.sell)
requires o.ms.currency;
currency-2.0.jar
(o.m.currency)
<dependency>
<groupId>org.moneylibs</groupId>
<artifactId>buy-service</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.moneylibs</groupId>
<artifactId>sell-service</artifactId>
<version>1.0</version>
</dependency>
animalmarket.jar
(com.animalmarket)
requires o.m.buy;
requires o.m.sell;
sell-service-1.0.jar (o.m.sell)
requires o.m.currency;
currency-2.0.jar
(o.m.currency)
buy-service-1.0.jar (o.m.buy)
requires currency;
currency-1.0.jar
(currency)
animalmarket.jar
(com.animalmarket)
requires o.m.buy;
requires o.m.sell;
sell-service-1.0.jar (o.m.sell)
requires o.m.currency;
currency-2.0.jar
(o.m.currency)
buy-service-1.0.jar (o.m.buy)
requires currency;
currency-1.0.jar
(currency)
Migrate
META-INF/MANIFEST.MF
•Automatic-Module-Name
2buy-service-1.0.jar
META-INF/MANIFEST.MF
Automatic-Module-Name:
org.moneylibs.buy
Point of
no return
“If you refer to
dependency X:N as a
module and dependency
X:N-1 has no module
name, then you cannot
downgrade this
dependency anymore”
currency-1.0.jar
(currency)
sell-service-1.0.jar
(o.m.sell)
requires o.m.currency;
currency-2.0.jar
(o.m.currency)
Strong advices
-Project must be Java 9 ready!!
o No split packages
o No root classes
-For libraries that depends on at least one filename based automodule:
o Help depending projects by providing intended module name via MANIFEST
-Pick your modulename with care, e.g. the shared package
Mistakes will happen
In fact, first invalid modules are already available at Maven Central
asm-6.0_BETA ( org.ow2.asm)
asm-all-6.0_BETA (org.ow2.asm.all) 1
asm-debug-all-6.0_BETA (org.ow2.asm.debug.all) 1
Application developer cannot fix these mistakes (dependency-exclude doesn’t work)
1 Fixed with asm-6.0 by dropping *-all artifacts (asm includes debug information by
default)
Same packages must
have the same
modulename
(otherwise potential
split package issue)
Tips for using JAVA 9 with MAVEN
DON’T change your folder structure (no need for extra folder with module
name)
Modulepath or classpath? No change to dependencies, just add module-
info.java ( Plexus-java can help plugins to build up the path )
Understanding plexus-java
Maven independent library for general Java features
◦ LocationManager
◦ Version
Used by
◦ maven-compiler-plugin
◦ maven-failsafe-plugin
◦ maven-javadoc-plugin
◦ maven-jlink-plugin
◦ maven-jmod-plugin
◦ maven-surefire-plugin
◦ …
Plexus Java :: LocationManager
If there’s a module descriptor, all its direct and indirect required modules will be put on the
module path, the rest on the classpath
Most plugins show the paths as debug logging ( -X / --debug )
Learn the JPMS specifications
JLINK
“You can use the jlink tool to assemble and optimize a set of modules and their dependencies
into a custom runtime image”
Enhanced solution for fat executable jar
However… it is overrated
Only works with explicit modules!
Source / target 1.9
<release>9<release>
source/target <= 1.8 : animal-sniffer
Issues?
1) Stackoverflow
2) Apache Maven mailinglists
3) Apache Maven Jira in case of bugs / improvements
Frequently Asked Questions
Can every project become modular?
NO
-Java 9 is a gamechanger, it introduces new rules
-The older the project, the more likely it cannot follow these rules
-No worries, the classpath is still there and will stay!
The boomerang question
Or “the ever returning Maven/JavaNEXT/Conference question”
Will Maven generate the module descriptor?
No
Different purpose
◦Pom is used to download jars and make them available
◦Module descriptor is used to specify required modules
Not all modules are dependencies
◦( e.g. java.logging, jdk.compiler )
Module descriptor elements not covered:
◦Module name
◦Open module
◦Exported packages
◦Uses / provides services
Pom 4.0.0 has no space for new elements
Pom hygiene
dependency:analyse
◦ Analyzes the dependencies of this project and determines which are:
◦used and declared (good)
◦used and undeclared (via transitive dependency)
◦unused and declared (ballast!)
Dependencies can be excluded,
required modules cannot
…BUT JDEPS can do it, right?
Can create a rough module descriptor
Intended to help with an initial descriptor
Uses binary classes, i.e. AFTER compile-phase
Some open source project will…
https://github.com/moditect/moditect
[RESULT] Apache Maven supports ALL Java
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
Thank you
@ASFMAVENPROJECT

Weitere ähnliche Inhalte

Was ist angesagt?

OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14
Ivan Krylov
 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallery
njbartlett
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
Holasz Kati
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
Vadym Lotar
 

Was ist angesagt? (20)

OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Java and XPages
Java and XPagesJava and XPages
Java and XPages
 
Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring tools
 
Java 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the GalleryJava 7 Modularity: a View from the Gallery
Java 7 Modularity: a View from the Gallery
 
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos SanchezMaven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
 
Java Programming - 01 intro to java
Java Programming - 01 intro to javaJava Programming - 01 intro to java
Java Programming - 01 intro to java
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Tuscany : Applying OSGi After The Fact
Tuscany : Applying  OSGi After The FactTuscany : Applying  OSGi After The Fact
Tuscany : Applying OSGi After The Fact
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Java EE 7 - Into the Cloud
Java EE 7 - Into the CloudJava EE 7 - Into the Cloud
Java EE 7 - Into the Cloud
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for future
 
Head toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DMHead toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DM
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and How
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 

Ähnlich wie Apache Maven supports all Java (JokerConf 2018)

Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw165
 

Ähnlich wie Apache Maven supports all Java (JokerConf 2018) (20)

Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
The do's and don'ts with java 9 (Devoxx 2017)
The do's and don'ts with java 9 (Devoxx 2017)The do's and don'ts with java 9 (Devoxx 2017)
The do's and don'ts with java 9 (Devoxx 2017)
 
Apache Maven and Java 9 and 10 (Devoxx France 2018)
Apache Maven and Java 9 and 10 (Devoxx France 2018)Apache Maven and Java 9 and 10 (Devoxx France 2018)
Apache Maven and Java 9 and 10 (Devoxx France 2018)
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 
Modern Java Workshop
Modern Java WorkshopModern Java Workshop
Modern Java Workshop
 
Java 9 Module System
Java 9 Module SystemJava 9 Module System
Java 9 Module System
 
Java9
Java9Java9
Java9
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Leaner microservices with Java 10
Leaner microservices with Java 10Leaner microservices with Java 10
Leaner microservices with Java 10
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
 
Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Riga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous IntegrationRiga Dev Day - Automated Android Continuous Integration
Riga Dev Day - Automated Android Continuous Integration
 
JavaOne 2016: Life after Modularity
JavaOne 2016: Life after ModularityJavaOne 2016: Life after Modularity
JavaOne 2016: Life after Modularity
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Apache Maven supports all Java (JokerConf 2018)