@@ -76,15 +76,14 @@ private void applyEnhancement(final Project project, final HibernateExtension hi
76
76
project .getLogger ().debug ( "Applying Hibernate enhancement action to SourceSet.{}" , sourceSet .getName () );
77
77
78
78
final Task compileTask = project .getTasks ().findByName ( sourceSet .getCompileJavaTaskName () );
79
-
80
- final ClassLoader classLoader = toClassLoader ( sourceSet .getRuntimeClasspath () );
81
-
82
79
compileTask .doLast (
83
80
new Action <Task >() {
84
81
@ Override
85
82
public void execute (Task task ) {
86
83
project .getLogger ().debug ( "Starting Hibernate enhancement on SourceSet.{}" , sourceSet .getName () );
87
84
85
+ final ClassLoader classLoader = toClassLoader ( sourceSet .getRuntimeClasspath () );
86
+
88
87
EnhancementContext enhancementContext = new DefaultEnhancementContext () {
89
88
@ Override
90
89
public ClassLoader getLoadingClassLoader () {
@@ -120,7 +119,6 @@ public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
120
119
final Enhancer enhancer = new Enhancer ( enhancementContext );
121
120
final ClassPool classPool = new ClassPool ( false );
122
121
123
-
124
122
final FileTree fileTree = project .fileTree ( sourceSet .getOutput ().getClassesDir () );
125
123
for ( File file : fileTree ) {
126
124
if ( !file .getName ().endsWith ( ".class" ) ) {
@@ -151,16 +149,13 @@ private ClassLoader toClassLoader(FileCollection runtimeClasspath) {
151
149
for ( File file : runtimeClasspath ) {
152
150
try {
153
151
urls .add ( file .toURI ().toURL () );
152
+ logger .debug ( "Adding classpath entry for " + file .getAbsolutePath () );
154
153
}
155
154
catch (MalformedURLException e ) {
156
155
throw new GradleException ( "Unable to resolve classpath entry to URL : " + file .getAbsolutePath (), e );
157
156
}
158
157
}
159
-
160
- return new URLClassLoader (
161
- urls .toArray ( new URL [urls .size ()] ),
162
- Enhancer .class .getClassLoader ()
163
- );
158
+ return new URLClassLoader ( urls .toArray ( new URL [urls .size ()] ), Enhancer .class .getClassLoader () );
164
159
}
165
160
166
161
private CtClass toCtClass (File file , ClassPool classPool ) {
0 commit comments