SlideShare a Scribd company logo
Java 9 and the impact on
Maven Projects
Robert Scholte (@rfscholte ) - chairman Apache Maven
“The success of Java 9 depends on the
adoption by IDEs and buildtools like
Maven”
 Jigsaw
 Since September 2015
 https://jdk9.java.net/jigsaw/
 ZIP
 Java9
 Since April 2014
 https://jdk9.java.net/download/
 Executable
3
Early Access releases
Challenge/Strategy Maven and Java9
• Support Maven 3.0 and above
• Only upgrades of plugins
 Set Java Runtime for Maven
 JAVA_HOME=/path/to/jdk-9
 Verify source/target of maven-compiler-plugin
 >= 6 (minimum jdk-9), okay
 < 6, must fork to preferred JDK
 Maven JRE <> maven-compiler-plugin JDK
5
Standard Java upgrade
Summary
Make most of the JDK's internal APIs inaccessible by
default but leave a few critical, widely-used internal
APIs accessible, until supported replacements exist for
all or most of their functionality.
6
JEP 260: Encapsulate Most Internal
APIs
• First java9-ea releases: close to no issues
• First jigsaw-ea release: ~99% of the Java Maven
projects failed to compile.
• Cause: JavacToolProvider + (System)Classloader
• Fixed and released within 72h!
• zero lines of code changed in Maven core codebase
to run on Java9
7
Results so far
• 220: Modular Run-Time Images *
• 223: New Version-String Scheme
• 226: UTF-8 Property Files
• 238: Multi-Release JAR Files
• 247: Compile for Older Platform Versions
• 261: Module System *
• 282: jlink: The Java Linker *
* Part of JSR 376: Java Platform Module System (Project jigsaw)
8
~10% of JEPs related to Maven
• 220: Modular Run-Time Images *
• 223: New Version-String Scheme
• 226: UTF-8 Property Files
• 238: Multi-Release JAR Files
• 247: Compile for Older Platform Versions
• 261: Module System *
• 282: jlink: The Java Linker *
* Part of JSR 376: Java Platform Module System (Project jigsaw)
9
Agenda
Summary
Revise the JDK's version-string scheme so that it is
easier to distinguish major, minor, and security-update
releases.
10
JEP 223: New Version-String Scheme
(project Verona)
11
Major (GA) Example
System property Existing Proposed
java.version 1.9.0 9
java.runtime.version 1.9.0-b100 9+100
java.vm.version 1.9.0-b100 9+100
java.specification.version 1.9 9
java.vm.specification.version 1.9 9
 Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
 at org.codehaus.plexus.archiver.zip.AbstractZipArchiver….
• maven-archiver-3.0.1
 maven-jar-plugin-3.0.0
 maven-war-plugin-3.0.0
 maven-assembly-plugin-3.0.0
 maven-ear-plugin-xxx
• maven-javadoc-plugin-2.10.4
• …
12
version.split(“.”)[1]
Summary
Enhance javac so that it can compile Java programs to
run on selected older versions of the platform.
13
JEP 247: Compile for Older Platform
Versions
Leaking classes of the JDK
The official required javac arguments
 -source N
 -target N
 -bootclasspath <bootclasspath-from-N>
14
The problem
• Always compile with the matching JDK version
• Configure maven-toolchain-plugin
• Configure toolchains.xml
 ${user.home}/.m2/toolchains.xml
 ${maven.home}/conf/toolchains.xml (since 3.3.1)
16
Available Maven Solutions (1)
• Verify code with jre signatures
• Configure animal-sniffer-maven-plugin
 Signature for N
 Execution-block with ‘check’ goal
17
Available Maven Solutions (2)
 “We defined a new command-line option, -release,
which automatically configures the compiler to
produce class files that will link against an
implementation of the given platform version. For the
platforms predefined in javac, -release N is
equivalent to -source N -target N -bootclasspath
<bootclasspath-from-N>.”
9-ea+135-jigsaw: --release (gnu-style)
18
Solution
• Configuration: <release>N</release>
• Property: maven.compiler.release
• If source/target AND release are specified,
release is used.
19
maven-compiler-plugin 3.6.0
if ( javaVersion >= 1.8 ) {
// calculation based on Date-Time API (preferred)
}
else {
// calculation based on Date
}
source/target: 1.7
JDK: 1.8
JDK: 1.7 with reflection
21
Forward compatibility
Summary
Extend the JAR file format to allow multiple, Java-
release-specific versions of class files to coexist in a
single archive.
22
JEP 238: Multi-Release JAR Files
jar root
- A.class
- B.class
- C.class
- D.class
- META-INF
- versions
- 9
- A.class
- B.class
- 10
- A.class
23
JAR structure
project root
src/main/java
- A.java
- B.java
- C.java
- D.java
src/main/java9
- A.java
- B.java
src/main/java10
- A.java
 Will work with Maven execution-blocks, not with (all) IDEs
24
1 to 1 translation
multimodule root
multirelease-base/src/main/java
- A.java
- B.java
- C.java
- D.java
multirelease-nine/src/main/java
- A.java
- B.java
multirelease-ten/src/main/java
- A.java
multirelease/src/assembly/mvjar.xml
 https://github.com/hboutemy/maven-jep238
25
IDE friendly POC
• Introduce new packaging (no install/deploy)
• Merge dependencies in JDK profiles
• Remove assembly descriptor
27
Improvements (in progress)
Summary
Restructure the JDK and JRE run-time images to
accommodate modules and to improve performance,
security, and maintainability. Define a new URI scheme
for naming the modules, classes, and resources stored
in a run-time image without revealing the internal
structure or format of the image. Revise existing
specifications as required to accommodate these
changes.
28
JEP 220: Modular Run-Time Images
 Most Apache maven-plugins already have a lot of
fallback scenarios for a long time.
 Projects that might suffer
 custom doclettags
 …
29
Removal of tools.jar
<profile>
<id>default-tools.jar</id>
<activation>
<jdk>(,9)</jdk> <!-- System.getProperty( “java.version” ) -->
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
30
Tools.jar profile
Summary
Implement the Java Platform Module System, as
specified by JSR 376, together with related JDK-specific
changes and enhancements.
31
JEP 261: Module System
 module-info.java
 Specify exposed packages
 Specify required modules (buildtime + runtime)
 Specify usage and implementation of SPIs
32
In a nutshell
module M.N {
requires A.B;
requires public C.D;
requires static E.F;
requires public static G.H;
exports P.Q;
exports R.S to T1.U1, T2.U2;
exports dynamic PP.QQ;
exports dynamic RR.SS to T1.U1, T2.U2;
uses V.W;
provides X.Y with Z1.Z2;
provides X.Y with Z3.Z4;
}
33
Module Declarations Example
(original proposal)
[|weak|open] module M.N {
requires A.B;
requires transitive C.D;
requires optional E.F;
requires transitive optional G.H;
exports P.Q;
exports R.S to T1.U1, T2.U2;
uses V.W;
provides X.Y with Z1.Z2;
provides X.Y with Z3.Z4;
}
34
Module Declarations Example
(current proposal)
• A hint for other projects using this as dependency (no
effect on this project)
• Maven best practice: don’t trust transitive dependencies;
specify dependency for every used class
• Concept adopted by Java9:
 Modules are unaware of dependency tree
 All (non-transitive) modules MUST be specified
35
Requires Modifier ‘transitive’
 comparable with dependency.optional
 Difference provided versus optional
 Buildtime: no difference
 Runtime:
 provided must be available (servlet-api)
 optional might be available (spring-boot deps)
36
Requires Modifier ‘optional’
37
Common usecases
• :compile, switch to modulepath when compiling
module-info.java
• :test-compile, switch to modulepath + classpath
when target/classes/module-info.class exists
38
maven-compiler-plugin 3.6.0
39
Building Maven with Maven
• Documentation
• Central/Repository Managers?
Archiva/Artifactory/Nexus
• maven-dependency-plugin:list
41
Discover moduleName
• The lower the supported Java version, the more
projects can use it
• The lower the supported Java version, the less Java
features can be used.
 Can we add module-info? Yes!
43
For library/framework/maven-
plugin/… builders
• module-info (-release 9)
• (other) java sources (source/target < 9)
• Maven Recipe
44
Backwards compatible libraries
• Classpath order:
 all direct dependencies
 all first level indirect dependencies
 all second level indirect dependencies
 …
• Locating a class:
 iterate over classpath (in same order); first match wins
45
Dependencies and classpath
• Modulepath: packages are mapped to a module
 Duplicate packages will result in an Exception
• Locating a class:
 find module based on package; get class from module
46
Dependencies and modulepath
 ‘requires’ means it is realy required!
 As enduser:
• No option to ignore requirements of third party
libraries
• No option to fix/choose package collisions between
transitive dependencies
47
GOTCHA: Dependency Excludes
 http://openjdk.java.net/projects/jigsaw/spec/issues/
48
Java Platform Module System:
Issue Summary
• Is it using internal classes?
 maven-jdeps-plugin-3.0.0
• Does it have duplicate
 extra-enforcer-rule > banDuplicateClasses
• Does it require certain Java9 features
 Upgrade the matching plugins
49
Is my project Java9-ready?
• Most features should work with Maven 3.0
• Some require Maven 3.3.1 due to improved
toolchains support
• Large number of new features already developed in
plugins, though not always released.
• New recipes “The Maven Way™”
50
The Apache Maven project tasklist
• Maven-compiler-plugin selecting modulePath or/and
classPath
• When Java9/Jigsaw fails:
 Usage internal APIs
 Duplicate (exported) packages
51
Developer awareness
Thank you
Give it a try!
Send feedback, issues & wishes

More Related Content

What's hot

Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
Sander Mak (@Sander_Mak)
 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
Mayank Patel
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
Ryan Cuprak
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
Deepu Xavier
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
Sander Mak (@Sander_Mak)
 
Java 9 modularity
Java 9 modularityJava 9 modularity
Java 9 modularity
Knoldus Inc.
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
Bhanu Prakash Gopularam
 
OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14Ivan Krylov
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Martin Toshev
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
Antoine Sabot-Durand
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
Paul Bakker
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applications
Mayank Patel
 
Java 9 and Project Jigsaw
Java 9 and Project JigsawJava 9 and Project Jigsaw
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
Dan Stine
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
Ryan Cuprak
 
Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9
Mauricio "Maltron" Leal
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
Sander Mak (@Sander_Mak)
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
Ryan Cuprak
 
Modular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache Karaf
Ioan Eugen Stan
 

What's hot (20)

Migrating to Java 9 Modules
Migrating to Java 9 ModulesMigrating to Java 9 Modules
Migrating to Java 9 Modules
 
Java 9 and Beyond
Java 9 and BeyondJava 9 and Beyond
Java 9 and Beyond
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Preparing your code for Java 9
Preparing your code for Java 9Preparing your code for Java 9
Preparing your code for Java 9
 
Java modularity: life after Java 9
Java modularity: life after Java 9Java modularity: life after Java 9
Java modularity: life after Java 9
 
Java 9 modularity
Java 9 modularityJava 9 modularity
Java 9 modularity
 
JDK-9: Modules and Java Linker
JDK-9: Modules and Java LinkerJDK-9: Modules and Java Linker
JDK-9: Modules and Java Linker
 
OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14OpenJDK-Zulu talk at JEEConf'14
OpenJDK-Zulu talk at JEEConf'14
 
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
Modularity of the Java Platform (OSGi, Jigsaw and Penrose)
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
 
Workflow automation for Front-end web applications
Workflow automation for Front-end web applicationsWorkflow automation for Front-end web applications
Workflow automation for Front-end web applications
 
Java 9 and Project Jigsaw
Java 9 and Project JigsawJava 9 and Project Jigsaw
Java 9 and Project Jigsaw
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9Java modules using project jigsaw@jdk 9
Java modules using project jigsaw@jdk 9
 
Modular JavaScript
Modular JavaScriptModular JavaScript
Modular JavaScript
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Modular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache KarafModular Java applications with OSGi on Apache Karaf
Modular Java applications with OSGi on Apache Karaf
 

Viewers also liked

Meetup IA Lyon - Introduction aux chatbots
Meetup IA Lyon - Introduction aux chatbotsMeetup IA Lyon - Introduction aux chatbots
Meetup IA Lyon - Introduction aux chatbots
cbouvard
 
Spark streaming state of the union
Spark streaming state of the unionSpark streaming state of the union
Spark streaming state of the union
Databricks
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
Trisha Gee
 
Java: вчера, сегодня, завтра
Java: вчера, сегодня, завтраJava: вчера, сегодня, завтра
Java: вчера, сегодня, завтра
Леонид Ставила
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
Takipi
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
Trisha Gee
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
Ivan Krylov
 
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Four Things to Know About Reliable Spark Streaming with Typesafe and DatabricksFour Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Legacy Typesafe (now Lightbend)
 
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern TalesPolar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
OCTO Technology Suisse
 

Viewers also liked (9)

Meetup IA Lyon - Introduction aux chatbots
Meetup IA Lyon - Introduction aux chatbotsMeetup IA Lyon - Introduction aux chatbots
Meetup IA Lyon - Introduction aux chatbots
 
Spark streaming state of the union
Spark streaming state of the unionSpark streaming state of the union
Spark streaming state of the union
 
Java 9 Functionality and Tooling
Java 9 Functionality and ToolingJava 9 Functionality and Tooling
Java 9 Functionality and Tooling
 
Java: вчера, сегодня, завтра
Java: вчера, сегодня, завтраJava: вчера, сегодня, завтра
Java: вчера, сегодня, завтра
 
Java 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature ListJava 9 – The Ultimate Feature List
Java 9 – The Ultimate Feature List
 
Real World Java 9 (QCon London)
Real World Java 9 (QCon London)Real World Java 9 (QCon London)
Real World Java 9 (QCon London)
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Four Things to Know About Reliable Spark Streaming with Typesafe and DatabricksFour Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
 
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern TalesPolar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
Polar Expeditions and Agility: the 1910 Race to the South Pole and Modern Tales
 

Similar to Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)

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)
Robert Scholte
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
Robert Scholte
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
Eric Wyles
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
Docker, Inc.
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
Arun Gupta
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
Volodymyr Ostapiv
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
Mani Sarkar
 
Webinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java AppsWebinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java Apps
Codefresh
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
venkata20k
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
Volodymyr Ostapiv
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
Raghavan Mohan
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
Onkar Deshpande
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsMert Çalışkan
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
Dmitry Bakaleinik
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
Fabio Fumarola
 
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)
Robert Scholte
 

Similar to Java 9 and the impact on Maven Projects (ApacheCon Europe 2016) (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)
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
 
Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018Java in a World of Containers - DockerCon 2018
Java in a World of Containers - DockerCon 2018
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
 
Java 9 / Jigsaw - AJUG/VJUG session
Java 9 / Jigsaw - AJUG/VJUG  sessionJava 9 / Jigsaw - AJUG/VJUG  session
Java 9 / Jigsaw - AJUG/VJUG session
 
Webinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java AppsWebinar: Creating an Effective Docker Build Pipeline for Java Apps
Webinar: Creating an Effective Docker Build Pipeline for Java Apps
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Maven in mulesoft
Maven in mulesoftMaven in mulesoft
Maven in mulesoft
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
Java, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorialJava, Eclipse, Maven & JSF tutorial
Java, Eclipse, Maven & JSF tutorial
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent Projects
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
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)
 

Recently uploaded

Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)

  • 1. Java 9 and the impact on Maven Projects Robert Scholte (@rfscholte ) - chairman Apache Maven
  • 2. “The success of Java 9 depends on the adoption by IDEs and buildtools like Maven”
  • 3.  Jigsaw  Since September 2015  https://jdk9.java.net/jigsaw/  ZIP  Java9  Since April 2014  https://jdk9.java.net/download/  Executable 3 Early Access releases
  • 4. Challenge/Strategy Maven and Java9 • Support Maven 3.0 and above • Only upgrades of plugins
  • 5.  Set Java Runtime for Maven  JAVA_HOME=/path/to/jdk-9  Verify source/target of maven-compiler-plugin  >= 6 (minimum jdk-9), okay  < 6, must fork to preferred JDK  Maven JRE <> maven-compiler-plugin JDK 5 Standard Java upgrade
  • 6. Summary Make most of the JDK's internal APIs inaccessible by default but leave a few critical, widely-used internal APIs accessible, until supported replacements exist for all or most of their functionality. 6 JEP 260: Encapsulate Most Internal APIs
  • 7. • First java9-ea releases: close to no issues • First jigsaw-ea release: ~99% of the Java Maven projects failed to compile. • Cause: JavacToolProvider + (System)Classloader • Fixed and released within 72h! • zero lines of code changed in Maven core codebase to run on Java9 7 Results so far
  • 8. • 220: Modular Run-Time Images * • 223: New Version-String Scheme • 226: UTF-8 Property Files • 238: Multi-Release JAR Files • 247: Compile for Older Platform Versions • 261: Module System * • 282: jlink: The Java Linker * * Part of JSR 376: Java Platform Module System (Project jigsaw) 8 ~10% of JEPs related to Maven
  • 9. • 220: Modular Run-Time Images * • 223: New Version-String Scheme • 226: UTF-8 Property Files • 238: Multi-Release JAR Files • 247: Compile for Older Platform Versions • 261: Module System * • 282: jlink: The Java Linker * * Part of JSR 376: Java Platform Module System (Project jigsaw) 9 Agenda
  • 10. Summary Revise the JDK's version-string scheme so that it is easier to distinguish major, minor, and security-update releases. 10 JEP 223: New Version-String Scheme (project Verona)
  • 11. 11 Major (GA) Example System property Existing Proposed java.version 1.9.0 9 java.runtime.version 1.9.0-b100 9+100 java.vm.version 1.9.0-b100 9+100 java.specification.version 1.9 9 java.vm.specification.version 1.9 9
  • 12.  Caused by: java.lang.ArrayIndexOutOfBoundsException: 1  at org.codehaus.plexus.archiver.zip.AbstractZipArchiver…. • maven-archiver-3.0.1  maven-jar-plugin-3.0.0  maven-war-plugin-3.0.0  maven-assembly-plugin-3.0.0  maven-ear-plugin-xxx • maven-javadoc-plugin-2.10.4 • … 12 version.split(“.”)[1]
  • 13. Summary Enhance javac so that it can compile Java programs to run on selected older versions of the platform. 13 JEP 247: Compile for Older Platform Versions
  • 14. Leaking classes of the JDK The official required javac arguments  -source N  -target N  -bootclasspath <bootclasspath-from-N> 14 The problem
  • 15.
  • 16. • Always compile with the matching JDK version • Configure maven-toolchain-plugin • Configure toolchains.xml  ${user.home}/.m2/toolchains.xml  ${maven.home}/conf/toolchains.xml (since 3.3.1) 16 Available Maven Solutions (1)
  • 17. • Verify code with jre signatures • Configure animal-sniffer-maven-plugin  Signature for N  Execution-block with ‘check’ goal 17 Available Maven Solutions (2)
  • 18.  “We defined a new command-line option, -release, which automatically configures the compiler to produce class files that will link against an implementation of the given platform version. For the platforms predefined in javac, -release N is equivalent to -source N -target N -bootclasspath <bootclasspath-from-N>.” 9-ea+135-jigsaw: --release (gnu-style) 18 Solution
  • 19. • Configuration: <release>N</release> • Property: maven.compiler.release • If source/target AND release are specified, release is used. 19 maven-compiler-plugin 3.6.0
  • 20.
  • 21. if ( javaVersion >= 1.8 ) { // calculation based on Date-Time API (preferred) } else { // calculation based on Date } source/target: 1.7 JDK: 1.8 JDK: 1.7 with reflection 21 Forward compatibility
  • 22. Summary Extend the JAR file format to allow multiple, Java- release-specific versions of class files to coexist in a single archive. 22 JEP 238: Multi-Release JAR Files
  • 23. jar root - A.class - B.class - C.class - D.class - META-INF - versions - 9 - A.class - B.class - 10 - A.class 23 JAR structure
  • 24. project root src/main/java - A.java - B.java - C.java - D.java src/main/java9 - A.java - B.java src/main/java10 - A.java  Will work with Maven execution-blocks, not with (all) IDEs 24 1 to 1 translation
  • 25. multimodule root multirelease-base/src/main/java - A.java - B.java - C.java - D.java multirelease-nine/src/main/java - A.java - B.java multirelease-ten/src/main/java - A.java multirelease/src/assembly/mvjar.xml  https://github.com/hboutemy/maven-jep238 25 IDE friendly POC
  • 26.
  • 27. • Introduce new packaging (no install/deploy) • Merge dependencies in JDK profiles • Remove assembly descriptor 27 Improvements (in progress)
  • 28. Summary Restructure the JDK and JRE run-time images to accommodate modules and to improve performance, security, and maintainability. Define a new URI scheme for naming the modules, classes, and resources stored in a run-time image without revealing the internal structure or format of the image. Revise existing specifications as required to accommodate these changes. 28 JEP 220: Modular Run-Time Images
  • 29.  Most Apache maven-plugins already have a lot of fallback scenarios for a long time.  Projects that might suffer  custom doclettags  … 29 Removal of tools.jar
  • 30. <profile> <id>default-tools.jar</id> <activation> <jdk>(,9)</jdk> <!-- System.getProperty( “java.version” ) --> </activation> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.4.2</version> <scope>system</scope> <systemPath>${java.home}/../lib/tools.jar</systemPath> </dependency> </dependencies> </profile> 30 Tools.jar profile
  • 31. Summary Implement the Java Platform Module System, as specified by JSR 376, together with related JDK-specific changes and enhancements. 31 JEP 261: Module System
  • 32.  module-info.java  Specify exposed packages  Specify required modules (buildtime + runtime)  Specify usage and implementation of SPIs 32 In a nutshell
  • 33. module M.N { requires A.B; requires public C.D; requires static E.F; requires public static G.H; exports P.Q; exports R.S to T1.U1, T2.U2; exports dynamic PP.QQ; exports dynamic RR.SS to T1.U1, T2.U2; uses V.W; provides X.Y with Z1.Z2; provides X.Y with Z3.Z4; } 33 Module Declarations Example (original proposal)
  • 34. [|weak|open] module M.N { requires A.B; requires transitive C.D; requires optional E.F; requires transitive optional G.H; exports P.Q; exports R.S to T1.U1, T2.U2; uses V.W; provides X.Y with Z1.Z2; provides X.Y with Z3.Z4; } 34 Module Declarations Example (current proposal)
  • 35. • A hint for other projects using this as dependency (no effect on this project) • Maven best practice: don’t trust transitive dependencies; specify dependency for every used class • Concept adopted by Java9:  Modules are unaware of dependency tree  All (non-transitive) modules MUST be specified 35 Requires Modifier ‘transitive’
  • 36.  comparable with dependency.optional  Difference provided versus optional  Buildtime: no difference  Runtime:  provided must be available (servlet-api)  optional might be available (spring-boot deps) 36 Requires Modifier ‘optional’
  • 38. • :compile, switch to modulepath when compiling module-info.java • :test-compile, switch to modulepath + classpath when target/classes/module-info.class exists 38 maven-compiler-plugin 3.6.0
  • 40.
  • 41. • Documentation • Central/Repository Managers? Archiva/Artifactory/Nexus • maven-dependency-plugin:list 41 Discover moduleName
  • 42.
  • 43. • The lower the supported Java version, the more projects can use it • The lower the supported Java version, the less Java features can be used.  Can we add module-info? Yes! 43 For library/framework/maven- plugin/… builders
  • 44. • module-info (-release 9) • (other) java sources (source/target < 9) • Maven Recipe 44 Backwards compatible libraries
  • 45. • Classpath order:  all direct dependencies  all first level indirect dependencies  all second level indirect dependencies  … • Locating a class:  iterate over classpath (in same order); first match wins 45 Dependencies and classpath
  • 46. • Modulepath: packages are mapped to a module  Duplicate packages will result in an Exception • Locating a class:  find module based on package; get class from module 46 Dependencies and modulepath
  • 47.  ‘requires’ means it is realy required!  As enduser: • No option to ignore requirements of third party libraries • No option to fix/choose package collisions between transitive dependencies 47 GOTCHA: Dependency Excludes
  • 49. • Is it using internal classes?  maven-jdeps-plugin-3.0.0 • Does it have duplicate  extra-enforcer-rule > banDuplicateClasses • Does it require certain Java9 features  Upgrade the matching plugins 49 Is my project Java9-ready?
  • 50. • Most features should work with Maven 3.0 • Some require Maven 3.3.1 due to improved toolchains support • Large number of new features already developed in plugins, though not always released. • New recipes “The Maven Way™” 50 The Apache Maven project tasklist
  • 51. • Maven-compiler-plugin selecting modulePath or/and classPath • When Java9/Jigsaw fails:  Usage internal APIs  Duplicate (exported) packages 51 Developer awareness
  • 52. Thank you Give it a try! Send feedback, issues & wishes