Skip to content

Commit 577949a

Browse files
committed
HBX-3000: Maven GenerateJava Mojo should generate annotated entities by default
- Remove the default initialization of the GenerateJavaMojo#ejb3 field and adapt the unit test Signed-off-by: Koen Aers <[email protected]>
1 parent c6b9dd0 commit 577949a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

maven/src/main/java/org/hibernate/tool/maven/GenerateJavaMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class GenerateJavaMojo extends AbstractGenerationMojo {
4848
/** Code will contain JPA features, e.g. using annotations from jakarta.persistence
4949
* and org.hibernate.annotations. */
5050
@Parameter(defaultValue = "true")
51-
private boolean ejb3 = true;
51+
private boolean ejb3;
5252

5353
/** Code will contain JDK 5 constructs such as generics and static imports. */
5454
@Parameter(defaultValue = "false")

maven/src/test/java/org/hibernate/tool/maven/GenerateJavaMojoTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public void testGenerateAnnotatedJava() throws Exception {
4848
File personJavaFile = new File(outputDirectory, "Person.java");
4949
// Person.java should not exist
5050
assertFalse(personJavaFile.exists());
51-
// Execute mojo with default value of 'ejb3' field which is 'true'
51+
// Set value of field 'ejb3' to 'true' and execute mojo
52+
Field ejb3Field = GenerateJavaMojo.class.getDeclaredField("ejb3");
53+
ejb3Field.setAccessible(true);
54+
ejb3Field.set(generateJavaMojo, true);
55+
// Execute mojo
5256
generateJavaMojo.executeExporter(createMetadataDescriptor());
5357
// Person.java should exist
5458
assertTrue(personJavaFile.exists());
@@ -66,6 +70,7 @@ public void testGenerateNonAnnotatedJava() throws Exception {
6670
Field ejb3Field = GenerateJavaMojo.class.getDeclaredField("ejb3");
6771
ejb3Field.setAccessible(true);
6872
ejb3Field.set(generateJavaMojo, false);
73+
// Execute mojo
6974
generateJavaMojo.executeExporter(createMetadataDescriptor());
7075
// Person.java should exist
7176
assertTrue(personJavaFile.exists());

0 commit comments

Comments
 (0)