1717import java .net .URL ;
1818import java .net .URLClassLoader ;
1919import java .util .ArrayList ;
20+ import java .util .Arrays ;
2021import java .util .Collections ;
2122import java .util .List ;
22- import javax .persistence .Embedded ;
23- import javax .persistence .Entity ;
23+
2424import javassist .ClassPool ;
2525import javassist .CtClass ;
2626import 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