diff --git a/tooling/hibernate-gradle-plugin/src/main/groovy/org/hibernate/orm/tooling/gradle/HibernatePlugin.java b/tooling/hibernate-gradle-plugin/src/main/groovy/org/hibernate/orm/tooling/gradle/HibernatePlugin.java index d5528651eb..1c9e61879a 100644 --- a/tooling/hibernate-gradle-plugin/src/main/groovy/org/hibernate/orm/tooling/gradle/HibernatePlugin.java +++ b/tooling/hibernate-gradle-plugin/src/main/groovy/org/hibernate/orm/tooling/gradle/HibernatePlugin.java @@ -76,15 +76,14 @@ public class HibernatePlugin implements Plugin { project.getLogger().debug( "Applying Hibernate enhancement action to SourceSet.{}", sourceSet.getName() ); final Task compileTask = project.getTasks().findByName( sourceSet.getCompileJavaTaskName() ); - - final ClassLoader classLoader = toClassLoader( sourceSet.getRuntimeClasspath() ); - compileTask.doLast( new Action() { @Override public void execute(Task task) { project.getLogger().debug( "Starting Hibernate enhancement on SourceSet.{}", sourceSet.getName() ); + final ClassLoader classLoader = toClassLoader( sourceSet.getRuntimeClasspath() ); + EnhancementContext enhancementContext = new DefaultEnhancementContext() { @Override public ClassLoader getLoadingClassLoader() { @@ -120,7 +119,6 @@ public class HibernatePlugin implements Plugin { final Enhancer enhancer = new Enhancer( enhancementContext ); final ClassPool classPool = new ClassPool( false ); - final FileTree fileTree = project.fileTree( sourceSet.getOutput().getClassesDir() ); for ( File file : fileTree ) { if ( !file.getName().endsWith( ".class" ) ) { @@ -151,16 +149,13 @@ public class HibernatePlugin implements Plugin { for ( File file : runtimeClasspath ) { try { urls.add( file.toURI().toURL() ); + logger.debug( "Adding classpath entry for " + file.getAbsolutePath() ); } catch (MalformedURLException e) { throw new GradleException( "Unable to resolve classpath entry to URL : " + file.getAbsolutePath(), e ); } } - - return new URLClassLoader( - urls.toArray( new URL[urls.size()] ), - Enhancer.class.getClassLoader() - ); + return new URLClassLoader( urls.toArray( new URL[urls.size()] ), Enhancer.class.getClassLoader() ); } private CtClass toCtClass(File file, ClassPool classPool) {