Skip to content

Commit 08d53f4

Browse files
koentsjeyrodiere
authored andcommitted
HHH-19820: Make sure that the enhancer is not doing anything if all the enablement parameters are false
Signed-off-by: Koen Aers <[email protected]>
1 parent 9a2e7b9 commit 08d53f4

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,23 @@ public class HibernateEnhancerMojo extends AbstractMojo {
9292
public void execute() {
9393
getLog().debug(STARTING_EXECUTION_OF_ENHANCE_MOJO);
9494
processParameters();
95-
assembleSourceSet();
96-
createEnhancer();
97-
discoverTypes();
98-
performEnhancement();
95+
if (enhancementIsNeeded()) {
96+
assembleSourceSet();
97+
createEnhancer();
98+
discoverTypes();
99+
performEnhancement();
100+
}
99101
getLog().debug(ENDING_EXECUTION_OF_ENHANCE_MOJO);
100102
}
101103

104+
private boolean enhancementIsNeeded() {
105+
// enhancement is not needed when all the parameters are false
106+
return enableAssociationManagement ||
107+
enableDirtyTracking ||
108+
enableLazyInitialization ||
109+
enableExtendedEnhancement;
110+
}
111+
102112
private void processParameters() {
103113
if (!enableLazyInitialization) {
104114
getLog().warn(ENABLE_LAZY_INITIALIZATION_DEPRECATED);

tooling/hibernate-maven-plugin/src/test/java/org/hibernate/orm/tooling/maven/HibernateEnhancerMojoTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
519519

520520
@Test
521521
void testExecute() throws Exception {
522+
Field enableDirtyTrackingField = HibernateEnhancerMojo.class.getDeclaredField( "enableDirtyTracking" );
523+
enableDirtyTrackingField.setAccessible( true );
524+
enableDirtyTrackingField.set( enhanceMojo, true );
522525
Method executeMethod = HibernateEnhancerMojo.class.getDeclaredMethod("execute", new Class[] {});
523526
executeMethod.setAccessible(true);
524527
final String barSource =

0 commit comments

Comments
 (0)