HHH-8844 - Add support for Java 8 date and time types (JSR-310)

This commit is contained in:
Steve Ebersole 2015-03-31 13:01:57 -05:00
parent 410a785dfe
commit f295d66d6e
5 changed files with 113 additions and 59 deletions

View File

@ -1,3 +1,5 @@
import org.gradle.internal.jvm.Jvm
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'idea' apply plugin: 'idea'
apply from: "./libraries.gradle" apply from: "./libraries.gradle"
@ -48,22 +50,40 @@ ext {
osgiExportVersion = hibernateTargetVersion.replaceAll( "-SNAPSHOT", ".SNAPSHOT" ) osgiExportVersion = hibernateTargetVersion.replaceAll( "-SNAPSHOT", ".SNAPSHOT" )
} }
if ( !JavaVersion.current().java8Compatible ) {
throw new GradleException( "Gradle must be run with Java 8" )
}
final Jvm java6Home;
String java6HomeDirSetting = null;
if ( rootProject.hasProperty( "JDK6_HOME" ) ) {
java6HomeDirSetting = rootProject.property( "JDK6_HOME" ) as String;
}
if ( java6HomeDirSetting == null ) {
java6HomeDirSetting = System.getProperty( "JDK6_HOME" );
}
if ( java6HomeDirSetting != null ) {
logger.info( "Using JDK6_HOME setting [${java6HomeDirSetting}]" )
final File java6HomeDir = new File( java6HomeDirSetting );
java6Home = Jvm.forHome( java6HomeDir ) as Jvm;
if ( java6Home == null ) {
throw new GradleException( "Could not resolve JDK6_HOME [${java6HomeDirSetting}] to proper JAVA_HOME" );
}
}
else {
logger.warn( "JDK6_HOME setting not specified, some build features will be disabled" )
java6Home = null;
}
idea { idea {
project { project {
languageLevel = javaLanguageLevel jdkName = '1.6'
ipr { languageLevel = '1.6'
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git' vcs = 'Git'
def maxHeapSizeConfig = provider.node.component.find { it.@name == 'JavacSettings' }
if( maxHeapSizeConfig == null ){
def javacSettingsNode = provider.node.appendNode('component',[name: 'JavacSettings'])
javacSettingsNode.appendNode('option', [name:"MAXIMUM_HEAP_SIZE", value:"512"])
}
}
beforeMerged { project ->
project.modulePaths.clear()
}
}
} }
module { module {
name = "hibernate-orm" name = "hibernate-orm"
@ -178,12 +198,60 @@ subprojects { subProject ->
} }
tasks.withType( JavaCompile.class ).all { task-> tasks.withType( JavaCompile.class ).all { task->
// basic compile options
task.options.compilerArgs += [ task.options.compilerArgs += [
"-nowarn", "-nowarn",
"-encoding", "UTF-8", "-encoding", "UTF-8"
"-source", rootProject.javaLanguageLevel,
"-target", rootProject.javaLanguageLevel
] ]
if ( subProject.name.equals( 'hibernate-java8' ) ) {
// For hibernate-java8 module, simply compile using Java 8 JDK which is required to
// launch Gradle (for now). This is verified in settings.gradle
task.options.compilerArgs += [
"-source", '1.8',
"-target", '1.8'
]
}
else {
// For all other modules, use the 1.6 JDK (if available) as bootstrapclasspath
task.options.compilerArgs += [
"-source", '1.6',
"-target", '1.6'
]
if ( java6Home != null ) {
task.options.bootClasspath = java6Home.runtimeJar.absolutePath
}
}
}
tasks.withType( Test.class ).all { task->
task.jvmArgs += ['-XX:+HeapDumpOnOutOfMemoryError', "-XX:HeapDumpPath=${subProject.file('target/OOM-dump.hprof').absolutePath}"]
if ( subProject.name.equals( 'hibernate-osgi' ) ) {
// hibernate-osgi *must* be run using Java 6 or 7. So disable its tests if
// java6Home is not available
if ( java6Home == null ) {
task.enabled = false;
}
else {
task.executable = java6Home.javaExecutable
task.maxHeapSize = '2G'
task.jvmArgs += ['-XX:MaxPermGen=512M']
}
}
else {
// for all other modules, just use the Java 8 used to launch Gradle (for now)
task.maxHeapSize = '2G'
task.jvmArgs += ['-XX:MetaspaceSize=512M']
}
// task.beforeTest { descriptor ->
// println "Starting test: " + descriptor
// }
// task.afterTest { descriptor ->
// println "Completed test: " + descriptor
// }
} }
jar { jar {
@ -230,32 +298,34 @@ subprojects { subProject ->
idea { idea {
module { module {
iml { if ( subProject.name.equals( 'hibernate-java8' ) ) {
beforeMerged { module -> jdkName = '1.8'
module.dependencies.clear()
module.excludeFolders.clear()
}
whenMerged { module ->
module.dependencies*.exported = true
module.excludeFolders += module.pathFactory.path(file(".gradle"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/bundles"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/classes"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/dependency-cache"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/libs"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/reports"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/test-results"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/tmp"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/matrix"))
module.excludeFolders += module.pathFactory.path(file("$buildDir/resources"))
module.excludeFolders -= module.pathFactory.path(file("$buildDir"))
}
} }
excludeDirs = [file( ".gradle" )]
excludeDirs += file( "$buildDir/classes" )
excludeDirs += file( "$buildDir/bundles" )
excludeDirs += file( "$buildDir/packages" )
excludeDirs += file( "$buildDir/dependency-cache" )
excludeDirs += file( "$buildDir/libs" )
excludeDirs += file( "$buildDir/reports" )
excludeDirs += file( "$buildDir/test-results" )
excludeDirs += file( "$buildDir/tmp" )
excludeDirs += file( "$buildDir/matrix" )
excludeDirs += file( "$buildDir/resources" )
downloadSources = true downloadSources = true
scopes.COMPILE.plus += [configurations.provided] scopes.PROVIDED.plus += [configurations.provided]
} }
} }
eclipse { eclipse {
if ( subProject.name != 'hibernate-java8' && java6Home != null ) {
jdt {
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
}
}
classpath { classpath {
plusConfigurations.add( configurations.provided ) plusConfigurations.add( configurations.provided )
} }

View File

@ -3,17 +3,6 @@ dependencies {
testCompile( project(':hibernate-testing') ) testCompile( project(':hibernate-testing') )
} }
targetCompatibility = '1.8'
sourceCompatibility = '1.8'
tasks.withType( JavaCompile.class ).all { task->
task.options.compilerArgs += [
"-nowarn",
"-encoding", "UTF-8",
"-source", sourceCompatibility,
"-target", targetCompatibility
]
}
def pomName() { def pomName() {
return 'Java8-specific Hibernate O/RM functionality' return 'Java8-specific Hibernate O/RM functionality'

View File

@ -27,6 +27,7 @@
ext { ext {
junitVersion = '4.11' junitVersion = '4.11'
// h2Version = '1.4.186'
h2Version = '1.2.145' h2Version = '1.2.145'
bytemanVersion = '2.1.2' bytemanVersion = '2.1.2'
infinispanVersion = '7.1.0.Final' infinispanVersion = '7.1.0.Final'

View File

@ -4,14 +4,6 @@ apply plugin: 'distribution'
buildDir = "target" buildDir = "target"
project.tasks*.each {
it.doFirst {
if ( !JavaVersion.current().java8Compatible ) {
throw new GradleException( "Release must use Java 8 or greater" )
}
}
}
idea.module { idea.module {
} }

View File

@ -1,11 +1,13 @@
if ( !JavaVersion.current().java8Compatible ) {
throw new GradleException( "Gradle must be run with Java 8" )
}
include 'hibernate-core' include 'hibernate-core'
include 'hibernate-testing' include 'hibernate-testing'
include 'hibernate-entitymanager' include 'hibernate-entitymanager'
include 'hibernate-envers' include 'hibernate-envers'
if ( JavaVersion.current().java8Compatible ) { include 'hibernate-java8'
include 'hibernate-java8'
}
include 'hibernate-osgi' include 'hibernate-osgi'