Java 9 and the impact on Maven Projects (Devoxx 2016)

Post on 13-Feb-2017

255 views 2 download

transcript

@rfscholte#Devoxx #Maven

Java 9 and the impact on Maven Projects

Robert ScholteChairman Apache Maven

CGI

`

@rfscholte#Devoxx #Maven

Tools in Actions• Migrating an example project to Java9

@rfscholte#Devoxx #Maven

HistoryApril 2014: Java 9 Early Access releases

No remarkable issues when running with MavenSeptember 2015: Jigsaw Early Access releases

99%+ of the Java Maven projects failed to compileOpenJDK fixed issue and released within 72h!

zero LOCs changed in Maven core codebase to run on Java 9

@rfscholte#Devoxx #Maven

Maven by ExampleChapter 7Multi-Module Enterprise Project“In this chapter, we create a multi-module project that evolves the examples from Chapter 6 and Chapter 5 into a project that uses the Spring Framework and Hibernate to create both a simple web application and a command-line utility to read data from the Yahoo Weather feed.”

@rfscholte#Devoxx #Maven

Multi-Module Enterprise ProjectAdjustments:• Added m-shade-plugin to :simple-command• Locked maven-jar-plugin to latest 2.x (= 2.6)• Locked maven-war-plugin to latest 2.x (=2.6)• Add hbm2ddl=create persist config-files

@rfscholte#Devoxx #Maven

Baseline• Maven 3.4.0-SNAPSHOT (colorized output)• JDK 1.8.0_040 / jigsaw-jdk-9-ea+142

@rfscholte#Devoxx #Maven

Source / Target option 1.5 is no longer supported.Java 5 compatible?• Configure maven-toolchain-plugin

Java 6 compatible?• Set source/target to 1.6• Replace source/target with release 6 • (requires maven-compiler-plugin 3.6.0)

@rfscholte#Devoxx #Maven

Caused by: j.l.AIOOBException: 1JEP 223: New Version-String Scheme (project Verona)

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

@rfscholte#Devoxx #Maven

version.split(“\\.”)[1]maven-archiver-3.0.1- maven-jar-plugin-3.0.0- maven-war-plugin-3.0.0- maven-ear-plugin-xxx- maven-assembly-plugin-xxx

maven-javadoc-plugin-2.10.4…

@rfscholte#Devoxx #Maven

j.l.reflect.InaccessibleObjectExceptionjigsaw-jdk-9-ea+135 #AwkwardStrongEncapsulation

Options:• Xstream fix (not available yet)• Improved support project Jigsaw• maven-war-plugin could think of other

implementation• Don’t create war• Use jigsaw-jdk-9-ea+134 or earlier as Maven JRE

(but compile with jigsaw-jdk-9-ea+141)

@rfscholte#Devoxx #Maven

modules are not supported in -source 1.6Options:• Set release=9• Apply recipe “Older projects with module-

info”• maven-compiler-plugin with 2 execution-blocks

@rfscholte#Devoxx #Maven

Split packages“If two or more JAR files on the class path contain types in the same package then at most one of them can be used as an automatic module, since the module system still guarantees that every named module reads at most one named module defining a given package and that named modules defining identically-named packages do not interfere with each other.”

Option (just one): upgrade/replace dependencies

@rfscholte#Devoxx #Maven

How to continue• Not all Java9/jigsaw changes are related to Maven• There will be Maven recipes to help migrating to

Java 9

@rfscholte#Devoxx #Maven

Thank youJava 9 and the impact on Maven

ProjectsRobert Scholte

Please rate & give feedback on this talk

`