Skip to content

Commit

Permalink
HHH-12946 Remove unnecessary dependencies when building with JDK9+
Browse files Browse the repository at this point in the history
We don't need to depend on JAXB's compiler (XJC) in our modules,
we just need the dependency in specific tasks during the build.
In particular we don't want users to transitively depend on XJC.

Also, we don't need an explicit dependency to JAXB in every module,
having one in hibernate-core is enough.
  • Loading branch information
yrodiere authored and gsmet committed Sep 11, 2019
1 parent f9609f9 commit e6cd7d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
27 changes: 6 additions & 21 deletions gradle/java-module.gradle
Expand Up @@ -108,35 +108,20 @@ dependencies {
testRuntime( libraries.hana )
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java 9 ftw!
if ( JavaVersion.current().isJava9Compatible() ) {
// The JDK used to run Gradle is Java 9+, and we assume that that is the same
// JDK for executing tasks
compile( libraries.jaxb_api )
compile( libraries.jaxb_runtime )
compile( libraries.jaxb_xjc )
compile( libraries.jaxb2_basics )
compile( libraries.jaxb2_basics_ant )
// In order for code generated by jpamodelgen to be compiled successfully,
// we need the @javax.annotation.Generated annotation to be in the classpath,
// and it's no longer in the JDK starting with JDK9
// (though @javax.annotation.processing.Generated is available in JDK9).
// Thus we need an additional dependency.
// See also https://hibernate.atlassian.net/browse/HHH-12990
compile( libraries.jsr250_api )

testCompile( libraries.jaxb_api )
testCompile( libraries.jaxb_runtime )
testCompile( libraries.jaxb_xjc )
testCompile( libraries.jaxb2_basics )
testCompile( libraries.jaxb2_basics_ant )
testCompile( libraries.jsr250_api )

testRuntime( libraries.jaxb_api )
testRuntime( libraries.jaxb_runtime )
testRuntime( libraries.jaxb_xjc )
testRuntime( libraries.jaxb2_basics )
testRuntime( libraries.jaxb2_basics_ant )
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// Mac-specific
project.ext.toolsJar = file("${System.getProperty('java.home')}/../lib/tools.jar")
if ( project.toolsJar.exists() ) {
Expand Down
3 changes: 3 additions & 0 deletions hibernate-core/hibernate-core.gradle
Expand Up @@ -27,6 +27,9 @@ dependencies {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java 9 ftw!
if ( JavaVersion.current().isJava9Compatible() ) {
compile( libraries.jaxb_api )
compile( libraries.jaxb_runtime )

xjc( libraries.jaxb_runtime )
xjc( libraries.jaxb_xjc )
xjc( libraries.jaxb2_basics )
Expand Down
2 changes: 2 additions & 0 deletions tooling/metamodel-generator/hibernate-jpamodelgen.gradle
Expand Up @@ -24,6 +24,8 @@ dependencies {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java 9 ftw!
if ( JavaVersion.current().isJava9Compatible() ) {
compile( libraries.jaxb_api )

xjc( libraries.jaxb_runtime )
xjc( libraries.jaxb_xjc )
xjc( libraries.jaxb2_basics )
Expand Down

0 comments on commit e6cd7d8

Please sign in to comment.