HHH-8306 Changed dependencies to use root project libraries configuration. Renamed the gradle build file to conform to project standard for a module. Fixed findbugs reported issues. Removed unnecessary classes and instead use an anonymous class.
This commit is contained in:
parent
c2ca2193c9
commit
a862f4f0cf
|
@ -30,9 +30,9 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile group: 'org.hibernate', name: 'hibernate-core', version: '4.2.2.Final'
|
compile( project(':hibernate-core') )
|
||||||
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Draft-16'
|
compile( libraries.jpa )
|
||||||
compile group: 'org.javassist', name: 'javassist', version: '3.15.0-GA'
|
compile( libraries.javassist )
|
||||||
compile gradleApi()
|
compile gradleApi()
|
||||||
compile localGroovy()
|
compile localGroovy()
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,6 @@ install {
|
||||||
repositories.mavenInstaller {
|
repositories.mavenInstaller {
|
||||||
pom.groupId = 'org.hibernate'
|
pom.groupId = 'org.hibernate'
|
||||||
pom.artifactId = 'hibernate-gradle-plugin'
|
pom.artifactId = 'hibernate-gradle-plugin'
|
||||||
pom.version = '0.1'
|
pom.version = '1.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,34 +31,30 @@ import org.gradle.api.plugins.JavaBasePlugin;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.plugins.JavaPlugin;
|
import org.gradle.api.plugins.JavaPlugin;
|
||||||
import org.hibernate.bytecode.enhance.plugins.EnhanceTask;
|
import org.hibernate.bytecode.enhance.plugins.EnhanceTask;
|
||||||
import org.hibernate.bytecode.enhance.plugins.EnhancePluginConvention;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This plugin will add Entity enhancement behaviour to the build lifecycle.
|
* This plugin will add Entity enhancement behaviour to the build lifecycle.
|
||||||
*
|
*
|
||||||
* @author Jeremy Whiting
|
* @author Jeremy Whiting
|
||||||
*/
|
*/
|
||||||
public class EnhancePlugin implements Plugin<Project> {
|
@SuppressWarnings("serial")
|
||||||
|
public class EnhancePlugin implements Plugin<Project>{
|
||||||
|
|
||||||
public static final String ENHANCE_TASK_NAME = "enhance";
|
public static final String ENHANCE_TASK_NAME = "enhance";
|
||||||
public static final String PLUGIN_CONVENTION_NAME = "enhance";
|
|
||||||
public static final String HAPPENS_BEFORE_ENHANCE_TASK_NAME = JavaPlugin.CLASSES_TASK_NAME;
|
|
||||||
public static final String HAPPENS_AFTER_ENHANCE_TASK_NAME = JavaPlugin.JAR_TASK_NAME;
|
public static final String HAPPENS_AFTER_ENHANCE_TASK_NAME = JavaPlugin.JAR_TASK_NAME;
|
||||||
|
|
||||||
public void apply(Project project) {
|
public void apply(Project project) {
|
||||||
project.getLogger().debug( "Applying enhance plugin to project." );
|
project.getLogger().debug( "Applying enhance plugin to project." );
|
||||||
project.getConvention().getPlugins().put( PLUGIN_CONVENTION_NAME, new EnhancePluginConvention() );
|
|
||||||
configureTask( project );
|
configureTask( project );
|
||||||
project.getLogger().debug( String.format( "DAG has been configured with enhance task dependent on [%s].", HAPPENS_BEFORE_ENHANCE_TASK_NAME ) );
|
project.getLogger().debug( String.format( "DAG has been configured with enhance task dependent on [%s].", JavaPlugin.CLASSES_TASK_NAME ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureTask(Project project) {
|
private void configureTask(Project project) {
|
||||||
EnhanceTask enhanceTask = project.getTasks().create( ENHANCE_TASK_NAME, EnhanceTask.class );
|
EnhanceTask enhanceTask = project.getTasks().create( ENHANCE_TASK_NAME, EnhanceTask.class );
|
||||||
|
enhanceTask.setGroup(BasePlugin.BUILD_GROUP);
|
||||||
// connect up the task in the task dependency graph
|
// connect up the task in the task dependency graph
|
||||||
final Configuration config = enhanceTask.getProject().getConfigurations().getByName( JavaPlugin.COMPILE_CONFIGURATION_NAME );
|
|
||||||
Task classesTask = project.getTasks().getByName( JavaPlugin.CLASSES_TASK_NAME );
|
Task classesTask = project.getTasks().getByName( JavaPlugin.CLASSES_TASK_NAME );
|
||||||
enhanceTask.dependsOn( classesTask );
|
enhanceTask.dependsOn( classesTask );
|
||||||
enhanceTask.mustRunAfter( HAPPENS_BEFORE_ENHANCE_TASK_NAME );
|
|
||||||
|
|
||||||
Task jarTask = project.getTasks().getByName( HAPPENS_AFTER_ENHANCE_TASK_NAME );
|
Task jarTask = project.getTasks().getByName( HAPPENS_AFTER_ENHANCE_TASK_NAME );
|
||||||
jarTask.dependsOn( enhanceTask );
|
jarTask.dependsOn( enhanceTask );
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, 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.bytecode.enhance.plugins
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convention object for plugin.
|
|
||||||
*/
|
|
||||||
class EnhancePluginConvention {
|
|
||||||
|
|
||||||
def contexts = []
|
|
||||||
|
|
||||||
public EnhancePluginConvention() {
|
|
||||||
contexts.add('org.hibernate.bytecode.enhance.contexts.AssociationReference')
|
|
||||||
}
|
|
||||||
|
|
||||||
def add(final String fullyQualifiedClassName) {
|
|
||||||
contexts.add(fullyQualifiedClassName);
|
|
||||||
}
|
|
||||||
List getContexts() {
|
|
||||||
return contexts
|
|
||||||
}
|
|
||||||
def clear() {
|
|
||||||
contexts.clear();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.bytecode.enhance.plugins
|
package org.hibernate.bytecode.enhance.plugins
|
||||||
|
|
||||||
import org.hibernate.bytecode.enhance.spi.Enhancer
|
import org.hibernate.bytecode.enhance.spi.Enhancer
|
||||||
|
import org.hibernate.bytecode.enhance.spi.EnhancementContext
|
||||||
import javassist.ClassPool
|
import javassist.ClassPool
|
||||||
import javassist.CtClass
|
import javassist.CtClass
|
||||||
import javassist.CtField
|
import javassist.CtField
|
||||||
|
@ -41,7 +42,9 @@ import org.gradle.api.file.FileTree
|
||||||
* which to apply.
|
* which to apply.
|
||||||
* @author Jeremy Whiting
|
* @author Jeremy Whiting
|
||||||
*/
|
*/
|
||||||
public class EnhanceTask extends DefaultTask {
|
public class EnhanceTask extends DefaultTask implements EnhancementContext {
|
||||||
|
|
||||||
|
private ClassLoader overridden
|
||||||
|
|
||||||
public EnhanceTask() {
|
public EnhanceTask() {
|
||||||
super()
|
super()
|
||||||
|
@ -52,10 +55,7 @@ public class EnhanceTask extends DefaultTask {
|
||||||
def enhance () {
|
def enhance () {
|
||||||
logger.info( 'enhance task started')
|
logger.info( 'enhance task started')
|
||||||
ext.pool = new ClassPool(false)
|
ext.pool = new ClassPool(false)
|
||||||
EnhancePluginConvention convention = (EnhancePluginConvention)project.getConvention().getPlugins().get( EnhancePlugin.PLUGIN_CONVENTION_NAME)
|
ext.enhancer = new Enhancer(this)
|
||||||
convention.contexts.each(
|
|
||||||
{ String context ->
|
|
||||||
ext.enhancer = new Enhancer(EnhanceTask.class.getClassLoader().loadClass(context).newInstance())
|
|
||||||
FileTree tree = project.fileTree(dir: project.sourceSets.main.output.classesDir)
|
FileTree tree = project.fileTree(dir: project.sourceSets.main.output.classesDir)
|
||||||
tree.include '**/*.class'
|
tree.include '**/*.class'
|
||||||
tree.each(
|
tree.each(
|
||||||
|
@ -104,7 +104,47 @@ public class EnhanceTask extends DefaultTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
logger.info( 'enhance task finished')
|
logger.info( 'enhance task finished')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassLoader getLoadingClassLoader() {
|
||||||
|
if ( null == this.overridden ) {
|
||||||
|
return getClass().getClassLoader();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return this.overridden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassLoader(ClassLoader loader) {
|
||||||
|
this.overridden = loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEntityClass(CtClass classDescriptor) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLazyLoadableAttributes(CtClass classDescriptor) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLazyLoadable(CtField field) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompositeClass(CtClass classDescriptor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public boolean doDirtyCheckingInline(CtClass classDescriptor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CtField[] order(CtField[] fields) {
|
||||||
|
// TODO: load ordering from configuration.
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPersistentField(CtField ctField) {
|
||||||
|
return !ctField.hasAnnotation( Transient.class );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, 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.bytecode.enhance.contexts;
|
|
||||||
|
|
||||||
import javassist.CtClass;
|
|
||||||
import javassist.CtField;
|
|
||||||
|
|
||||||
public class AssociationReference extends BaseContext {
|
|
||||||
|
|
||||||
private ClassLoader overridden;
|
|
||||||
|
|
||||||
public ClassLoader getLoadingClassLoader() {
|
|
||||||
if ( null == this.overridden ) {
|
|
||||||
return getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.overridden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassLoader(ClassLoader loader) {
|
|
||||||
this.overridden = loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEntityClass(CtClass classDescriptor) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasLazyLoadableAttributes(CtClass classDescriptor) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLazyLoadable(CtField field) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, 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.bytecode.enhance.contexts;
|
|
||||||
|
|
||||||
import java.beans.Transient;
|
|
||||||
|
|
||||||
import javassist.CtClass;
|
|
||||||
import javassist.CtField;
|
|
||||||
|
|
||||||
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
|
|
||||||
|
|
||||||
abstract public class BaseContext implements EnhancementContext {
|
|
||||||
|
|
||||||
private ClassLoader overridden;
|
|
||||||
|
|
||||||
public ClassLoader getLoadingClassLoader() {
|
|
||||||
if ( null == this.overridden ) {
|
|
||||||
return getClass().getClassLoader();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.overridden;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassLoader(ClassLoader loader) {
|
|
||||||
this.overridden = loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEntityClass(CtClass classDescriptor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCompositeClass(CtClass classDescriptor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean doDirtyCheckingInline(CtClass classDescriptor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasLazyLoadableAttributes(CtClass classDescriptor) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLazyLoadable(CtField field) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CtField[] order(CtField[] fields) {
|
|
||||||
// TODO: load ordering from configuration.
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPersistentField(CtField ctField) {
|
|
||||||
return !ctField.hasAnnotation( Transient.class );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,6 +10,7 @@ include 'hibernate-proxool'
|
||||||
|
|
||||||
include 'hibernate-ehcache'
|
include 'hibernate-ehcache'
|
||||||
include 'hibernate-infinispan'
|
include 'hibernate-infinispan'
|
||||||
|
include 'hibernate-gradle-plugin'
|
||||||
include 'documentation'
|
include 'documentation'
|
||||||
include 'release'
|
include 'release'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue