Skip to content

Commit

Permalink
HHH-8844 - Add support for Java 8 date and time types (JSR-310)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Mar 31, 2015
1 parent 410a785 commit f295d66
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 59 deletions.
144 changes: 107 additions & 37 deletions build.gradle
@@ -1,3 +1,5 @@
import org.gradle.internal.jvm.Jvm

apply plugin: 'eclipse'
apply plugin: 'idea'
apply from: "./libraries.gradle"
Expand Down Expand Up @@ -48,22 +50,40 @@ ext {
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 {
project {
languageLevel = javaLanguageLevel
ipr {
withXml { provider ->
provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@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()
}
}
jdkName = '1.6'
languageLevel = '1.6'

vcs = 'Git'
}
module {
name = "hibernate-orm"
Expand Down Expand Up @@ -178,12 +198,60 @@ subprojects { subProject ->
}

tasks.withType( JavaCompile.class ).all { task->
// basic compile options
task.options.compilerArgs += [
"-nowarn",
"-encoding", "UTF-8",
"-source", rootProject.javaLanguageLevel,
"-target", rootProject.javaLanguageLevel
"-encoding", "UTF-8"
]

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 {
Expand Down Expand Up @@ -230,32 +298,34 @@ subprojects { subProject ->

idea {
module {
iml {
beforeMerged { module ->
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"))
}
if ( subProject.name.equals( 'hibernate-java8' ) ) {
jdkName = '1.8'
}

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
scopes.COMPILE.plus += [configurations.provided]
scopes.PROVIDED.plus += [configurations.provided]
}
}

eclipse {
if ( subProject.name != 'hibernate-java8' && java6Home != null ) {
jdt {
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
}
}
classpath {
plusConfigurations.add( configurations.provided )
}
Expand Down
11 changes: 0 additions & 11 deletions hibernate-java8/hibernate-java8.gradle
Expand Up @@ -3,17 +3,6 @@ dependencies {
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() {
return 'Java8-specific Hibernate O/RM functionality'
Expand Down
1 change: 1 addition & 0 deletions libraries.gradle
Expand Up @@ -27,6 +27,7 @@
ext {

junitVersion = '4.11'
// h2Version = '1.4.186'
h2Version = '1.2.145'
bytemanVersion = '2.1.2'
infinispanVersion = '7.1.0.Final'
Expand Down
8 changes: 0 additions & 8 deletions release/release.gradle
Expand Up @@ -4,14 +4,6 @@ apply plugin: 'distribution'

buildDir = "target"

project.tasks*.each {
it.doFirst {
if ( !JavaVersion.current().java8Compatible ) {
throw new GradleException( "Release must use Java 8 or greater" )
}
}
}

idea.module {
}

Expand Down
8 changes: 5 additions & 3 deletions settings.gradle
@@ -1,11 +1,13 @@
if ( !JavaVersion.current().java8Compatible ) {
throw new GradleException( "Gradle must be run with Java 8" )
}

include 'hibernate-core'
include 'hibernate-testing'
include 'hibernate-entitymanager'
include 'hibernate-envers'

if ( JavaVersion.current().java8Compatible ) {
include 'hibernate-java8'
}
include 'hibernate-java8'

include 'hibernate-osgi'

Expand Down

0 comments on commit f295d66

Please sign in to comment.