Skip to content

Commit

Permalink
Make Hibernate ORM and jdbc-derby extensions work without any other r…
Browse files Browse the repository at this point in the history
…equired dependencies

With Derby moving to hibernate-community-dialects, Quarkus will need to
add this dependency automatically.
  • Loading branch information
yrodiere committed Sep 16, 2024
1 parent 1de1660 commit cea4ced
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 2 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,16 @@
<artifactId>quarkus-hibernate-orm-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-envers</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache-deployment</artifactId>
Expand Down
60 changes: 60 additions & 0 deletions extensions/hibernate-orm-derby/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-hibernate-orm-derby-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-hibernate-orm-derby-deployment</artifactId>
<name>Quarkus - Hibernate ORM - Derby - Deployment</name>
<description>This extensions is added by Quarkus automatically when quarkus-hibernate-orm and quarkus-jdbc-derby are on the classpath</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-deployment-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-datasource-common</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Set;

import io.quarkus.datasource.common.runtime.DatabaseKind;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.hibernate.orm.deployment.spi.DatabaseKindDialectBuildItem;

public final class HibernateOrmDerbyProcessor {
@BuildStep
void registerHibernateOrmMetadataForDerbyDialect(BuildProducer<DatabaseKindDialectBuildItem> producer) {
producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.DERBY, "Apache Derby",
Set.of("org.hibernate.community.dialect.DerbyDialect")));
}
}
21 changes: 21 additions & 0 deletions extensions/hibernate-orm-derby/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<artifactId>quarkus-extensions-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-hibernate-orm-derby-parent</artifactId>
<name>Quarkus - Hibernate ORM - Derby - Deployment</name>
<packaging>pom</packaging>
<modules>
<module>runtime</module>
<module>deployment</module>
</modules>
</project>
69 changes: 69 additions & 0 deletions extensions/hibernate-orm-derby/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-hibernate-orm-derby-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-hibernate-orm-derby</artifactId>
<name>Quarkus - Hibernate ORM - Derby - Deployment</name>
<description>This extensions is added by Quarkus automatically when quarkus-hibernate-orm and quarkus-jdbc-derby are on the classpath</description>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-community-dialects</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>extension-descriptor</goal>
</goals>
<configuration>
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
<dependencyCondition>
<artifact>io.quarkus:quarkus-hibernate-orm</artifact>
<artifact>io.quarkus:quarkus-jdbc-derby</artifact>
</dependencyCondition>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${project.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Quarkus Hibernate ORM Derby
artifact: ${project.groupId}:${project.artifactId}:${project.version}
description: Conditional extension added when Hibernate ORM and the Derby JDBC driver are present
metadata:
unlisted: true

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public final class DatabaseKindDialectBuildItem extends MultiBuildItem {
* @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
* @param databaseProductName The corresponding database-product-name to set in Hibernate ORM.
* See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
* Also works with {@code org.hibernate.community.dialect.CommunityDatabase} if
* {@code hibernate-community-dialects} is in the classpath.
* @param dialects The corresponding dialects in Hibernate ORM,
* to detect the dbKind when using database multi-tenancy.
*/
Expand All @@ -32,6 +34,8 @@ public static DatabaseKindDialectBuildItem forCoreDialect(String dbKind, String
* @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
* @param databaseProductName The corresponding database-product-name to set in Hibernate ORM.
* See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
* Also works with {@code org.hibernate.community.dialect.CommunityDatabase} if
* {@code hibernate-community-dialects} is in the classpath.
* @param dialects The corresponding dialects in Hibernate ORM,
* to detect the dbKind when using database multi-tenancy.
* @param defaultDatabaseProductVersion The default database-product-version to set in Hibernate ORM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ void registerHibernateOrmMetadataForCoreDialects(
BuildProducer<DatabaseKindDialectBuildItem> producer) {
producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.DB2, "DB2",
Set.of("org.hibernate.dialect.DB2Dialect")));
producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.DERBY, "Apache Derby",
Set.of("org.hibernate.dialect.DerbyDialect")));
producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.H2, "H2",
Set.of("org.hibernate.dialect.H2Dialect"),
// Using our own default version is extra important for H2
Expand Down
5 changes: 5 additions & 0 deletions extensions/jdbc/jdbc-derby/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<artifactId>quarkus-flyway-derby-deployment</artifactId>
<optional>true</optional> <!-- conditional dependency -->
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby-deployment</artifactId>
<optional>true</optional> <!-- conditional dependency -->
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devservices-derby</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions extensions/jdbc/jdbc-derby/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<artifactId>quarkus-flyway-derby</artifactId>
<optional>true</optional> <!-- conditional dependency -->
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-derby</artifactId>
<optional>true</optional> <!-- conditional dependency -->
</dependency>
<!-- Required for JTA and to reference JDBC drivers by name.
See https://db.apache.org/derby/releases/release-10.15.1.3.cgi#Note%20for%20DERBY-6945
"the derbytools.jar library is now required [...] when using Derby DataSources, and when directly referencing the JDBC drivers" -->
Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<module>agroal</module>
<module>jdbc</module>
<module>hibernate-orm</module>
<module>hibernate-orm-derby</module>
<module>hibernate-envers</module>
<module>hibernate-reactive</module>
<module>hibernate-validator</module>
Expand Down

0 comments on commit cea4ced

Please sign in to comment.