-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-18644: New and improved hibernate-maven-plugin
- Change 'hibernate-maven-plugin.gradle' to depend on 'org.apache.maven.shared:file-management:3.1.0' - Add the implementation, test and integration test sources for the new hibernate-maven-plugin Signed-off-by: Koen Aers <[email protected]>
- Loading branch information
Showing
11 changed files
with
1,335 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-maven-plugin</artifactId> | ||
<packaging>maven-plugin</packaging> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<name>Hbernate Maven Plugin</name> | ||
|
||
<url>http://hibernate.org</url> | ||
|
||
<properties> | ||
<hibernate-core.version>7.0.0.Beta1</hibernate-core.version> | ||
<maven-file-management.version>3.1.0</maven-file-management.version> | ||
<maven-invoker-plugin.version>3.8.0</maven-invoker-plugin.version> | ||
<maven-plugin-api.version>3.9.9</maven-plugin-api.version> | ||
<maven-plugin-annotations.version>3.15.0</maven-plugin-annotations.version> | ||
<junit-jupiter.version>5.11.2</junit-jupiter.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>${maven-plugin-api.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.shared</groupId> | ||
<artifactId>file-management</artifactId> | ||
<version>${maven-file-management.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
<version>${maven-plugin-annotations.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>${hibernate-core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-invoker-plugin</artifactId> | ||
<version>${maven-invoker-plugin.version}</version> | ||
<configuration> | ||
<debug>true</debug> | ||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> | ||
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> | ||
<postBuildHookScript>verify</postBuildHookScript> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-test</id> | ||
<goals> | ||
<goal>install</goal> | ||
<goal>run</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.hibernate.orm.tooling.maven</groupId> | ||
<artifactId>enhance-test</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>@hibernate-core.version@</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.hibernate.orm</groupId> | ||
<artifactId>hibernate-maven-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<executions> | ||
<execution> | ||
<id>enhance</id> | ||
<phase>process-classes</phase> | ||
<configuration> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/classes</directory> | ||
<excludes> | ||
<exclude>**/Baz.class</exclude> | ||
</excludes> | ||
</fileSet> | ||
</fileSets> | ||
<enableLazyInitialization>true</enableLazyInitialization> | ||
</configuration> | ||
<goals> | ||
<goal>enhance</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
tooling/hibernate-maven-plugin/src/it/enhance/src/main/java/org/foo/Bar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.foo; | ||
|
||
import jakarta.persistence.Entity; | ||
|
||
@Entity | ||
public class Bar { | ||
|
||
private String foo; | ||
|
||
String getFoo() { | ||
return foo; | ||
} | ||
|
||
public void setFoo(String f) { | ||
foo = f; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
tooling/hibernate-maven-plugin/src/it/enhance/src/main/java/org/foo/Baz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.foo; | ||
|
||
import jakarta.persistence.Entity; | ||
|
||
@Entity | ||
public class Baz { | ||
|
||
private String foo; | ||
|
||
String getFoo() { | ||
return foo; | ||
} | ||
|
||
public void setFoo(String f) { | ||
foo = f; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
tooling/hibernate-maven-plugin/src/it/enhance/src/main/java/org/foo/Foo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.foo; | ||
|
||
public class Foo { | ||
|
||
private Bar bar; | ||
|
||
Bar getBar() { | ||
return bar; | ||
} | ||
|
||
public void setBar(Bar b) { | ||
bar = b; | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
tooling/hibernate-maven-plugin/src/it/enhance/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.nio.file.Files; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
|
||
|
||
File targetFolder = new File(basedir, "target"); | ||
if (!targetFolder.exists()) { | ||
throw new FileNotFoundException("Folder should exist: " + targetFolder); | ||
} | ||
if (targetFolder.isFile()) { | ||
throw new FileNotFoundException("Folder should be a folder: " + targetFolder); | ||
} | ||
File classesFolder = new File(targetFolder, "classes"); | ||
if (!classesFolder.exists()) { | ||
throw new FileNotFoundException("Folder should exist: " + classesFolder); | ||
} | ||
File barClassFile = new File(classesFolder, "org/foo/Bar.class"); | ||
if (!barClassFile.exists()) { | ||
throw new FileNotFoundException("File should exist: " + barClassFile); | ||
} | ||
int amountOfBytes = Files.readAllBytes(barClassFile.toPath()).length; | ||
|
||
File fooClassFile = new File(classesFolder, "org/foo/Foo.class"); | ||
if (!fooClassFile.exists()) { | ||
throw new FileNotFoundException("File should exist: " + fooClassFile); | ||
} | ||
|
||
File bazClassFile = new File(classesFolder, "org/foo/Baz.class"); | ||
if (!bazClassFile.exists()) { | ||
throw new FileNotFoundException("File should exist: " + bazClassFile); | ||
} | ||
|
||
File buildLog = new File(basedir, "build.log"); | ||
if (!buildLog.exists()) { | ||
throw new FileNotFoundException("File should exist: " + buildLog); | ||
} | ||
List<String> listOfStrings = new ArrayList<String>(); | ||
listOfStrings = Files.readAllLines(buildLog.toPath()); | ||
assert listOfStrings.contains("[DEBUG] Configuring mojo execution 'org.hibernate.orm:hibernate-maven-plugin:0.0.1-SNAPSHOT:enhance:enhance' with basic configurator -->"); | ||
assert listOfStrings.contains("[DEBUG] (f) classesDirectory = " + classesFolder); | ||
assert listOfStrings.contains("[DEBUG] (f) enableAssociationManagement = false"); | ||
assert listOfStrings.contains("[DEBUG] (f) enableDirtyTracking = false"); | ||
assert listOfStrings.contains("[DEBUG] (f) enableLazyInitialization = true"); | ||
assert listOfStrings.contains("[DEBUG] (f) enableExtendedEnhancement = false"); | ||
assert listOfStrings.contains("[DEBUG] Starting execution of enhance mojo"); | ||
assert listOfStrings.contains("[DEBUG] Starting assembly of the source set"); | ||
assert listOfStrings.contains("[DEBUG] Processing FileSet"); | ||
assert listOfStrings.contains("[DEBUG] Using base directory: " + classesFolder); | ||
assert listOfStrings.contains("[INFO] Added file to source set: " + barClassFile); | ||
assert listOfStrings.contains("[INFO] Added file to source set: " + fooClassFile); | ||
assert !listOfStrings.contains("[INFO] Added file to source set: " + bazClassFile); | ||
assert listOfStrings.contains("[DEBUG] FileSet was processed succesfully"); | ||
assert listOfStrings.contains("[DEBUG] Ending the assembly of the source set"); | ||
assert listOfStrings.contains("[DEBUG] Creating bytecode enhancer"); | ||
assert listOfStrings.contains("[DEBUG] Creating enhancement context"); | ||
assert listOfStrings.contains("[DEBUG] Creating URL ClassLoader for folder: " + classesFolder); | ||
assert listOfStrings.contains("[DEBUG] Starting type discovery"); | ||
assert listOfStrings.contains("[DEBUG] Trying to discover types for classes in file: " + barClassFile); | ||
assert listOfStrings.contains("[DEBUG] Determining class name for file: " + barClassFile); | ||
assert listOfStrings.contains("[INFO] Succesfully discovered types for classes in file: " + barClassFile); | ||
assert listOfStrings.contains("[DEBUG] Trying to discover types for classes in file: " + fooClassFile); | ||
assert listOfStrings.contains("[DEBUG] Determining class name for file: " + fooClassFile); | ||
assert listOfStrings.contains("[INFO] Succesfully discovered types for classes in file: " + fooClassFile); | ||
assert listOfStrings.contains("[DEBUG] Ending type discovery"); | ||
assert listOfStrings.contains("[DEBUG] Starting class enhancement"); | ||
assert listOfStrings.contains("[DEBUG] Trying to enhance class file: " + barClassFile); | ||
assert listOfStrings.contains("[INFO] Succesfully cleared the contents of file: " + barClassFile); | ||
assert listOfStrings.contains("[DEBUG] " + amountOfBytes + " bytes were succesfully written to file: " +barClassFile); | ||
assert listOfStrings.contains("[INFO] Succesfully enhanced class file: " + barClassFile); | ||
assert listOfStrings.contains("[DEBUG] Trying to enhance class file: " + fooClassFile); | ||
assert listOfStrings.contains("[INFO] Skipping file: " + fooClassFile); | ||
assert listOfStrings.contains("[DEBUG] Ending class enhancement"); | ||
assert listOfStrings.contains("[DEBUG] Ending execution of enhance mojo"); |
Oops, something went wrong.