diff --git a/build.gradle b/build.gradle index dc96a7e3d3..b520d847f6 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,31 @@ apply plugin: 'eclipse' apply plugin: 'idea' apply from: "./libraries.gradle" + +buildscript { + repositories { + mavenCentral() + mavenLocal() + jcenter() + + maven { + name 'jboss-nexus' + url "http://repository.jboss.org/nexus/content/groups/public/" + } + maven { + name "jboss-snapshots" + url "http://snapshots.jboss.org/maven2/" + } + } + dependencies { + classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' + classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:1.0.0-SNAPSHOT' + classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' + classpath 'org.hibernate.build.gradle:gradle-animalSniffer-plugin:1.0.1.Final' + classpath 'org.hibernate.build.gradle:gradle-xjc-plugin:1.0.0.Final' + } +} + allprojects { repositories { mavenCentral() @@ -20,34 +45,12 @@ allprojects { } } -buildscript { - repositories { - mavenCentral() - mavenLocal() - jcenter() - - maven { - name 'jboss-nexus' - url "http://repository.jboss.org/nexus/content/groups/public/" - } - maven { - name "jboss-snapshots" - url "http://snapshots.jboss.org/maven2/" - } - } - dependencies { - classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1' - classpath 'org.hibernate.build.gradle:hibernate-matrix-testing:1.0.0-SNAPSHOT' - classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' - } -} - ext { expectedGradleVersion = '2.2' hibernateTargetVersion = '5.0.0-SNAPSHOT' javaLanguageLevel = '1.6' - osgiExportVersion = hibernateTargetVersion.replaceAll( "-SNAPSHOT", ".SNAPSHOT" ) + osgiExportVersion = hibernateTargetVersion.replaceAll( '-SNAPSHOT', '.SNAPSHOT' ) } if ( !JavaVersion.current().java8Compatible ) { @@ -136,19 +139,22 @@ subprojects { subProject -> apply plugin: 'build-dashboard' apply plugin: 'project-report' + apply plugin: 'org.hibernate.build.gradle.animalSniffer' + + if ( subProject.name == 'hibernate-java8' ) { + animalSniffer { + skip = true + } + } + configurations { provided { // todo : need to make sure these are non-exported description = 'Non-exported compile-time dependencies.' } - jaxb { - description = 'Dependencies for running ant xjc (jaxb class generation)' - } configurations { all*.exclude group: 'xml-apis', module: 'xml-apis' } - animalSnifferSignature - javaApiSignature } // appropriately inject the common dependencies into each sub-project @@ -167,16 +173,8 @@ subprojects { subProject -> testRuntime( libraries.h2 ) testRuntime( libraries.woodstox ) - jaxb( libraries.jaxb ){ - exclude group: "javax.xml.stream" - } - jaxb( libraries.jaxb2_basics ) - jaxb( libraries.jaxb2_ant ) - jaxb( libraries.jaxb2_jaxb ) - jaxb( libraries.jaxb2_jaxb_xjc ) - - animalSnifferSignature( libraries.java16_signature ) - javaApiSignature ( libraries.java16_signature ) + // Configuration added by the AnimalSniffer plugin + animalSnifferSignature libraries.java16_signature } // mac-specific stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -221,9 +219,9 @@ subprojects { subProject -> "-target", '1.6' ] - if ( java6Home != null ) { - task.options.bootClasspath = java6Home.runtimeJar.absolutePath - } +// if ( java6Home != null ) { +// task.options.bootClasspath = java6Home.runtimeJar.absolutePath +// } } } @@ -338,14 +336,6 @@ subprojects { subProject -> // Gradle plugin). For now, just compile first in order to get the logging classes. eclipseClasspath.dependsOn generateSources - if ( subProject.name != 'hibernate-java8' ) { - apply plugin: org.hibernate.build.animalsniffer.AnimalSnifferPlugin - - animalSniffer { - skip = true; - } - } - // specialized API/SPI checkstyle tasks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ task checkstylePublicSources(type: Checkstyle) { checkstyleClasspath = checkstyleMain.checkstyleClasspath diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index d3ebf1eae6..dbcc4d8695 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -7,6 +7,4 @@ apply plugin: "groovy" dependencies { compile gradleApi() compile localGroovy() - - compile "org.codehaus.mojo:animal-sniffer:1.14" } \ No newline at end of file diff --git a/buildSrc/src/main/groovy/org/hibernate/build/animalsniffer/AnimalSnifferPlugin.groovy b/buildSrc/src/main/groovy/org/hibernate/build/animalsniffer/AnimalSnifferPlugin.groovy deleted file mode 100644 index e6ce2c640c..0000000000 --- a/buildSrc/src/main/groovy/org/hibernate/build/animalsniffer/AnimalSnifferPlugin.groovy +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2015, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.build.animalsniffer - -import org.gradle.api.Action -import org.gradle.api.GradleException -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.plugins.JavaPlugin - -import groovy.transform.Canonical -import org.codehaus.mojo.animal_sniffer.SignatureChecker -import org.codehaus.mojo.animal_sniffer.logging.Logger -import org.slf4j.LoggerFactory - -class AnimalSnifferPlugin implements Plugin { - private org.slf4j.Logger logger = LoggerFactory.getLogger( this.class ) - - @Override - void apply(Project project) { - project.configurations.maybeCreate( "animalSnifferSignature" ) - final AnimalSnifferExtension extension = project.extensions.create( "animalSniffer", AnimalSnifferExtension ) - - project.tasks.findByName( JavaPlugin.CLASSES_TASK_NAME ).doLast( - new Action() { - @Override - void execute(Task task) { - if ( extension.skip ) { - return; - } - - def logger = new GradleLogger( logger ) - def signatures = project.configurations.animalSnifferSignature.resolvedConfiguration.resolvedArtifacts*.file - signatures.each { - task.logger.lifecycle( "Starting AnimalSniffer checks against [${it.name}]" ) - SignatureChecker signatureChecker = new SignatureChecker( - it.newInputStream(), - Collections.emptySet(), - logger - ) - signatureChecker.setCheckJars( false ); - - List sourceDirs = new ArrayList(); - sourceDirs.addAll( task.project.sourceSets.main.java.srcDirs ) - signatureChecker.setSourcePath( sourceDirs ) - - signatureChecker.process( project.file( task.project.sourceSets.main.output.classesDir ) ); - - if ( signatureChecker.isSignatureBroken() ) { - throw new GradleException( - "Signature errors found. Verify them and ignore them with the proper annotation if needed." - ); - } - } - } - } - ); - } -} - -@Canonical -class GradleLogger implements Logger { - @Delegate - org.slf4j.Logger logger -} - -class AnimalSnifferExtension { - String signature = "" - String[] signatures = [] - boolean skip = false -} \ No newline at end of file diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index b179449e18..e41755ac75 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -2,6 +2,7 @@ apply plugin: 'antlr' apply plugin: 'hibernate-matrix-testing' apply plugin: 'version-injection' +apply plugin: 'org.hibernate.build.gradle.xjc' versionInjection { into( 'org.hibernate.Version', 'getVersionString' ) @@ -110,57 +111,22 @@ idea { } } -task jaxb { - ext { - // input schemas - cfgXsd = file( 'src/main/resources/org/hibernate/xsd/cfg/legacy-configuration-4.0.xsd') - hbmXsd = file( 'src/main/resources/org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd' ) - ormXsd = file( 'src/main/resources/org/hibernate/jpa/orm_2_0.xsd' ) +xjc { + outputDir = jaxbTargetDir - // input bindings - cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' ) - hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' ) - ormXjb = file( 'src/main/xjb/orm-bindings.xjb' ) + schemas { + cfg { + xsd = file( 'src/main/resources/org/hibernate/xsd/cfg/legacy-configuration-4.0.xsd' ) + xjcBinding = file( 'src/main/xjb/hbm-configuration-bindings.xjb' ) + } + hbm { + xsd = file( 'src/main/resources/org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd' ) + xjcBinding = file( 'src/main/xjb/hbm-mapping-bindings.xjb' ) + xjcExtensions = ['inheritance', 'simplify'] + } } - - // configure Gradle up-to-date checking - inputs.files( [cfgXsd, hbmXsd, ormXsd, cfgXjb, hbmXjb, ormXjb] ) - outputs.dir( jaxbTargetDir ) - - // perform actions - doLast { - jaxbTargetDir.mkdirs() - - ant.taskdef(name: 'xjc', classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task', classpath: configurations.jaxb.asPath) - ant.jaxbTargetDir = jaxbTargetDir - - // hibernate-configuration - ant.xjc( - destdir: '${jaxbTargetDir}', - binding: 'src/main/xjb/hbm-configuration-bindings.xjb', - schema: cfgXsd.path - ) - - // hibernate-mapping - ant.xjc( - destdir: '${jaxbTargetDir}', - binding: 'src/main/xjb/hbm-mapping-bindings.xjb', - schema: hbmXsd.path, - extension: 'true' - ) { - arg line: '-Xinheritance -Xsimplify' - } - -// // orm.xml (jpa) -// ant.xjc( -// destdir: '${jaxbTargetDir}', -// package: 'org.hibernate.internal.jaxb.mapping.orm', -// binding: 'src/main/xjb/orm-bindings.xjb', -// schema: ormXsd.path -// ) - } - } -sourceSets.main.sourceGeneratorsTask.dependsOn jaxb + +//sourceSets.main.sourceGeneratorsTask.dependsOn xjc sourceSets.main.sourceGeneratorsTask.dependsOn generateGrammarSource diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 20c26c498e..9a760a661e 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.naming.Reference; import javax.naming.StringRefAddr; @@ -205,7 +206,7 @@ public final class SessionFactoryImpl private final transient CurrentSessionContext currentSessionContext; private final transient SQLFunctionRegistry sqlFunctionRegistry; private final transient SessionFactoryObserverChain observer = new SessionFactoryObserverChain(); - private final transient ConcurrentHashMap entityNameResolvers = new ConcurrentHashMap(); + private final transient ConcurrentMap entityNameResolvers = new ConcurrentHashMap(); private final transient QueryPlanCache queryPlanCache; private final transient CacheImplementor cacheAccess; private transient boolean isClosed;