diff --git a/maven/docs/examples/5-minute-tutorial/pom.xml b/maven/docs/examples/5-minute-tutorial/pom.xml
new file mode 100644
index 0000000000..a8038c8705
--- /dev/null
+++ b/maven/docs/examples/5-minute-tutorial/pom.xml
@@ -0,0 +1,53 @@
+
+
+
+ 4.0.0
+
+ org.hibernate.tool.maven.test
+ five-minute-tutorial
+ 0.0.1-SNAPSHOT
+
+
+
+ com.h2database
+ h2
+ @h2.version@
+
+
+
+
+
+
+ org.hibernate.tool
+ hibernate-tools-maven
+ @project.version@
+
+
+ Entity generation
+ generate-sources
+
+ hbm2java
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/maven/docs/examples/5-minute-tutorial/src/main/resources/hibernate.properties b/maven/docs/examples/5-minute-tutorial/src/main/resources/hibernate.properties
new file mode 100644
index 0000000000..60b2483a2f
--- /dev/null
+++ b/maven/docs/examples/5-minute-tutorial/src/main/resources/hibernate.properties
@@ -0,0 +1,23 @@
+############################################################################
+# Hibernate Tools, Tooling for your Hibernate Projects #
+# #
+# Copyright 2004-2025 Red Hat, Inc. #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); #
+# you may not use this file except in compliance with the License. #
+# You may obtain a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" basis, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+############################################################################
+hibernate.connection.driver_class=org.h2.Driver
+hibernate.connection.url=jdbc:h2:tcp://localhost/./sakila
+hibernate.connection.username=sa
+hibernate.default_catalog=SAKILA
+hibernate.default_schema=PUBLIC
+
diff --git a/maven/pom.xml b/maven/pom.xml
index 2932a3a787..a1bb6b6752 100644
--- a/maven/pom.xml
+++ b/maven/pom.xml
@@ -70,6 +70,31 @@
maven-plugin-annotations
provided
+
+ org.apache.maven
+ maven-embedder
+ test
+
+
+ org.apache.maven
+ maven-compat
+ test
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+ test
+
+
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+ test
+
+
+ org.slf4j
+ slf4j-simple
+ test
+
@@ -156,6 +181,83 @@
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-test-source
+ generate-test-sources
+
+ add-test-source
+
+
+
+ src/functionalTest/java
+
+
+
+
+ add-test-resource
+ generate-test-resources
+
+ add-test-resource
+
+
+
+
+ docs/examples
+
+
+ **/hibernate.properties
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ filter-test-resources
+ process-test-resources
+
+ testResources
+
+
+
+
+ ${project.build.testOutputDirectory}
+ true
+
+ **/pom.xml
+
+
+
+
+ @*@
+
+
+
+
+
diff --git a/maven/src/functionalTest/java/org/hibernate/tool/maven/ExamplesTestIT.java b/maven/src/functionalTest/java/org/hibernate/tool/maven/ExamplesTestIT.java
new file mode 100644
index 0000000000..f29bf73224
--- /dev/null
+++ b/maven/src/functionalTest/java/org/hibernate/tool/maven/ExamplesTestIT.java
@@ -0,0 +1,98 @@
+package org.hibernate.tool.maven;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import org.apache.maven.cli.MavenCli;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+
+public class ExamplesTestIT {
+
+ public static final String MVN_HOME = "maven.multiModuleProjectDirectory";
+ private static File baseFolder;
+ private static File localRepo;
+
+ @BeforeAll
+ public static void beforeAll() throws Exception {
+ // The needed resource for this test are put in place
+ // in the 'baseFolder' (normally 'target/test-classes')
+ // by the 'build-helper-maven-plugin' execution.
+ // See the 'pom.xml'
+ baseFolder = determineBaseFolder();
+ localRepo = new File(baseFolder.getParentFile(), "local-repo");
+ createDatabase();
+ }
+
+ private MavenCli mavenCli;
+
+ @Test
+ public void test5MinuteTutorial() throws Exception {
+ File projectFolder = prepareProjectFolder("5-minute-tutorial");
+ File generatedPersonFile = new File(projectFolder, "target/generated-sources/Person.java");
+ assertFalse(generatedPersonFile.exists());
+ new MavenCli().doMain(
+ new String[]{"-Dmaven.repo.local=" + localRepo.getAbsolutePath(), "generate-sources"},
+ projectFolder.getAbsolutePath(),
+ null,
+ null);
+ assertTrue(generatedPersonFile.exists());
+ String personFileContents = new String(Files.readAllBytes(generatedPersonFile.toPath()));
+ assertTrue(personFileContents.contains("public class Person"));
+ }
+
+ private File prepareProjectFolder(String projectName) throws Exception {
+ File projectFolder = new File(baseFolder, projectName);
+ assertTrue(projectFolder.exists());
+ System.setProperty(MVN_HOME, projectFolder.getAbsolutePath());
+ createHibernatePropertiesFile(projectFolder);
+ return projectFolder;
+ }
+
+ private void createHibernatePropertiesFile(File projectFolder) throws Exception {
+ File projectResourcesFolder = new File(projectFolder, "src/main/resources");
+ projectResourcesFolder.mkdirs();
+ File hibernatePropertiesFile = new File(projectResourcesFolder, "hibernate.properties");
+ assertFalse(hibernatePropertiesFile.exists());
+ String hibernatePropertiesFileContents =
+ "hibernate.connection.driver_class=org.h2.Driver\n" +
+ "hibernate.connection.url=" + constructJdbcConnectionString() + "\n" +
+ "hibernate.connection.username=\n" +
+ "hibernate.connection.password=\n" +
+ "hibernate.default_catalog=TEST\n" +
+ "hibernate.default_schema=PUBLIC\n";
+ Files.writeString(hibernatePropertiesFile.toPath(), hibernatePropertiesFileContents);
+ assertTrue(hibernatePropertiesFile.exists());
+ }
+
+ private static File determineBaseFolder() throws Exception {
+ return new File(ExamplesTestIT.class.getClassLoader().getResource("5-minute-tutorial/pom.xml").toURI())
+ .getParentFile().getParentFile();
+ }
+
+ private static void createDatabase() throws Exception {
+ File databaseFile = new File(baseFolder, "database/test.mv.db");
+ assertFalse(databaseFile.exists());
+ assertFalse(databaseFile.isFile());
+ Connection connection = DriverManager.getConnection(constructJdbcConnectionString());
+ Statement statement = connection.createStatement();
+ statement.execute("create table PERSON (ID int not null, NAME varchar(20), primary key (ID))");
+ statement.close();
+ connection.close();
+ assertTrue(databaseFile.exists());
+ assertTrue(databaseFile.isFile());
+ }
+
+ private static String constructJdbcConnectionString() {
+ return "jdbc:h2:" + baseFolder.getAbsolutePath() + "/database/test;AUTO_SERVER=TRUE";
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 90c4d5b195..8f53c42b22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,6 +117,8 @@
19.3.0.0
9.2.1.jre8
4.0.2
+ 1.9.24
+ 2.0.17
3.9.11
@@ -234,10 +236,30 @@
maven-plugin-api
${maven-plugin-api.version}
+
+ org.apache.maven
+ maven-embedder
+ ${maven-core.version}
+
+
+ org.apache.maven
+ maven-compat
+ ${maven-core.version}
+
org.apache.maven.plugin-tools
maven-plugin-annotations
${maven-plugin-annotations.version}
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+ ${maven-resolver.version}
+
+
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+ ${maven-resolver.version}
org.freemarker
@@ -305,6 +327,12 @@
jboss-logging
${jboss-logging.version}
+
+ org.slf4j
+ slf4j-simple
+ 1.7.5
+ test
+
org.junit.jupiter
junit-jupiter-engine