Skip to content

Commit 6ef981e

Browse files
committed
HHH-9582 - maven enahcer plugin - fix local classloader
1 parent 3e72b84 commit 6ef981e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tooling/hibernate-enhance-maven-plugin/src/main/java/org/hibernate/orm/tooling/maven/MavenEnhancePlugin.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import java.net.URL;
1818
import java.net.URLClassLoader;
1919
import java.util.ArrayList;
20+
import java.util.Arrays;
2021
import java.util.Collections;
2122
import java.util.List;
22-
import javax.persistence.Embedded;
23-
import javax.persistence.Entity;
23+
2424
import javassist.ClassPool;
2525
import javassist.CtClass;
2626
import javassist.CtField;
@@ -82,7 +82,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8282
File root = new File( this.dir );
8383
walkDir( root );
8484

85-
final ClassLoader classLoader = toClassLoader( sourceSet );
85+
final ClassLoader classLoader = toClassLoader( Arrays.asList( root ) );
8686

8787
EnhancementContext enhancementContext = new DefaultEnhancementContext() {
8888
@Override
@@ -107,7 +107,7 @@ public boolean hasLazyLoadableAttributes(CtClass classDescriptor) {
107107

108108
@Override
109109
public boolean isLazyLoadable(CtField field) {
110-
return true;
110+
return enableLazyInitialization;
111111
}
112112
};
113113

@@ -120,13 +120,15 @@ public boolean isLazyLoadable(CtField field) {
120120
continue;
121121
}
122122

123-
if ( !ctClass.hasAnnotation( Entity.class ) && !ctClass.hasAnnotation( Embedded.class ) ) {
124-
getLog().debug( "Skipping class file [" + file.getAbsolutePath() + "], not an entity nor embedded" );
123+
if ( !enhancementContext.isEntityClass( ctClass ) && !enhancementContext.isCompositeClass( ctClass ) ) {
124+
getLog().info( "Skipping class file [" + file.getAbsolutePath() + "], not an entity nor embeddable" );
125125
continue;
126126
}
127127

128128
final byte[] enhancedBytecode = doEnhancement( ctClass, enhancer );
129129
writeOutEnhancedClass( enhancedBytecode, ctClass, file );
130+
131+
getLog().info( "Successfully enhanced class [" + ctClass.getName() + "]" );
130132
}
131133
}
132134

@@ -135,6 +137,7 @@ private ClassLoader toClassLoader(List<File> runtimeClasspath) throws MojoExecut
135137
for ( File file : runtimeClasspath ) {
136138
try {
137139
urls.add( file.toURI().toURL() );
140+
getLog().debug( "Adding root " + file.getAbsolutePath() + " to classpath " );
138141
}
139142
catch (MalformedURLException e) {
140143
String msg = "Unable to resolve classpath entry to URL: " + file.getAbsolutePath();

0 commit comments

Comments
 (0)