HHH-10864 - Allow ORM to be built with Java 9

This commit is contained in:
Steve Ebersole 2016-06-17 10:27:57 -05:00
parent 45cd13a68f
commit 015be3df6e
7 changed files with 74 additions and 28 deletions

View File

@ -55,7 +55,7 @@ allprojects {
ext {
hibernateTargetVersion = '5.2.1-SNAPSHOT'
expectedGradleVersion = '2.10'
expectedGradleVersion = '3.0-milestone-1'
baselineJavaVersion = '1.8'
osgiExportVersion = hibernateTargetVersion.replaceAll( '-SNAPSHOT', '.SNAPSHOT' )

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-milestone-1-bin.zip

View File

@ -9,7 +9,6 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'antlr'
apply plugin: 'hibernate-matrix-testing'
apply plugin: 'version-injection'
apply plugin: 'org.hibernate.build.gradle.xjc'
configurations {
@ -36,6 +35,31 @@ dependencies {
compile( libraries.dom4j )
compile( libraries.commons_annotations )
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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
xjc( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
xjc( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
xjc( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
xjc( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
xjc( 'javax:javaee-api:7.0' )
testCompile( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
testCompile( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
testCompile( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
testCompile( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
testCompile( 'javax:javaee-api:7.0' )
testRuntime( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
testRuntime( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
testRuntime( 'javax:javaee-api:7.0' )
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
antlr( libraries.antlr )
provided( libraries.jacc )
@ -83,10 +107,6 @@ def osgiDescription() {
return mavenPom.description
}
versionInjection {
into( 'org.hibernate.Version', 'getVersionString' )
}
jar {
manifest {
mainAttributes( 'Main-Class': 'org.hibernate.Version' )

View File

@ -16,6 +16,8 @@ import org.jboss.logging.Logger;
* @author Steve Ebersole
*/
public class Version {
private static String version;
private Version() {
}
@ -27,7 +29,13 @@ public class Version {
* @return The Hibernate version
*/
public static String getVersionString() {
return "[WORKING]";
if ( version == null ) {
version = Version.class.getPackage().getImplementationVersion();
if ( version == null ) {
version = "[WORKING]";
}
}
return version;
}
/**

View File

@ -18,8 +18,25 @@ mavenPom {
description = 'Annotation Processor to generate JPA 2 static metamodel classes'
}
versionInjection {
into( 'org.hibernate.jpamodelgen.Version', 'getVersionString' )
dependencies {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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
xjc( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
xjc( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
xjc( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
xjc( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
xjc( 'javax:javaee-api:7.0' )
testRuntime( 'com.sun.xml.bind:jaxb-impl:2.2.11' )
testRuntime( 'org.glassfish.jaxb:jaxb-xjc:2.2.11' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics:0.11.0' )
testRuntime( 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.11.0' )
testRuntime( 'javax:javaee-api:7.0' )
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
ext {

View File

@ -12,10 +12,18 @@ package org.hibernate.jpamodelgen;
* @author Hardy Ferentschik
*/
public final class Version {
private static String version;
private Version() {
}
public static String getVersionString() {
return "[WORKING]";
if ( version == null ) {
version = Version.class.getPackage().getImplementationVersion();
if ( version == null ) {
version = "[WORKING]";
}
}
return version;
}
}

View File

@ -91,25 +91,18 @@ public class CompilationStatement extends Statement {
@Override
public void evaluate() throws Throwable {
try {
// some test needs to compile some classes prior to the actual classes under test
if ( !preCompileEntities.isEmpty() ) {
compile( getCompilationUnits( preCompileEntities ) );
}
// now we compile the actual test classes
compile( getCompilationUnits( testEntities ) );
if ( !ignoreCompilationErrors ) {
TestUtil.assertNoCompilationError( compilationDiagnostics );
}
// some test needs to compile some classes prior to the actual classes under test
if ( !preCompileEntities.isEmpty() ) {
compile( getCompilationUnits( preCompileEntities ) );
}
catch ( Exception e ) {
StringWriter errors = new StringWriter();
e.printStackTrace( new PrintWriter( errors ) );
log.debug( errors.toString() );
fail( "Unable to process test sources." );
// now we compile the actual test classes
compile( getCompilationUnits( testEntities ) );
if ( !ignoreCompilationErrors ) {
TestUtil.assertNoCompilationError( compilationDiagnostics );
}
originalStatement.evaluate();
}