HHH-9717 - Build script improvements - applied new standalone XJC and AnimalSniffer plugins

This commit is contained in:
Steve Ebersole 2015-04-09 11:36:04 -05:00
parent c11d264743
commit 6e7357beeb
5 changed files with 56 additions and 194 deletions

View File

@ -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

View File

@ -7,6 +7,4 @@ apply plugin: "groovy"
dependencies {
compile gradleApi()
compile localGroovy()
compile "org.codehaus.mojo:animal-sniffer:1.14"
}

View File

@ -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<Project> {
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<Task>() {
@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<File> sourceDirs = new ArrayList<File>();
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
}

View File

@ -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

View File

@ -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<EntityNameResolver,Object> entityNameResolvers = new ConcurrentHashMap<EntityNameResolver, Object>();
private final transient ConcurrentMap<EntityNameResolver,Object> entityNameResolvers = new ConcurrentHashMap<EntityNameResolver, Object>();
private final transient QueryPlanCache queryPlanCache;
private final transient CacheImplementor cacheAccess;
private transient boolean isClosed;