Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ protected Set<String> resolveDependencies(Path settings, Path profile) throws Ex
}
}

// automatic add hibernate as JPA provider when using camel-jpa
if (answer.stream().anyMatch(s -> s.contains("camel-jpa") || s.equals("camel:jpa"))) {
answer.add("mvn:org.hibernate.orm:hibernate-core");
}

// remove duplicate versions (keep first)
Map<String, String> versions = new HashMap<>();
Set<String> toBeRemoved = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
## ---------------------------------------------------------------------------

org.messaginghub\:pooled-jms = io.quarkiverse.messaginghub:quarkus-pooled-jms
org.hibernate.orm\:hibernate-core = io.quarkus:quarkus-hibernate-orm
camel\:resilience4j = org.apache.camel.quarkus:camel-quarkus-microprofile-fault-tolerance
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,35 @@ private Export createCommand(RuntimeType rt, String[] files, String... args) {
return command;
}

@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldExportWithJpaAndHibernate(RuntimeType rt) throws Exception {
LOG.info("shouldExportWithJpaAndHibernate {}", rt);
Export command = new Export(new CamelJBangMain());
CommandLine.populateCommand(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir,
"--runtime=%s".formatted(rt.runtime()), "--dep=camel:jpa", "target/test-classes/route.yaml");
int exit = command.doCall();

Assertions.assertEquals(0, exit);
Model model = readMavenModel();

if (rt == RuntimeType.main) {
Assertions.assertTrue(containsDependency(model.getDependencies(), "org.apache.camel", "camel-jpa", null));
Assertions.assertTrue(
containsDependency(model.getDependencies(), "org.hibernate.orm", "hibernate-core", null));
} else if (rt == RuntimeType.springBoot) {
Assertions.assertTrue(
containsDependency(model.getDependencies(), "org.apache.camel.springboot", "camel-jpa-starter", null));
Assertions.assertTrue(
containsDependency(model.getDependencies(), "org.hibernate.orm", "hibernate-core", null));
} else if (rt == RuntimeType.quarkus) {
Assertions.assertTrue(
containsDependency(model.getDependencies(), "org.apache.camel.quarkus", "camel-quarkus-jpa", null));
Assertions.assertTrue(
containsDependency(model.getDependencies(), "io.quarkus", "quarkus-hibernate-orm", null));
}
}

@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldExportLazyBean(RuntimeType rt) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public Component resolveComponent(String name, CamelContext context) {
downloadLoader(quartz.getGroupId(), quartz.getArtifactId(), quartz.getVersion());
}
}
if ("jpa".equals(name)) {
// include hibernate as JPA provider
if (!downloader.alreadyOnClasspath("org.hibernate.orm", "hibernate-core", null)) {
downloader.downloadDependency("org.hibernate.orm", "hibernate-core", "${hibernate-version}");
}
}
if ("activemq".equals(name) || "activemq6".equals(name)) {
// need to include JMS connection-pool (trigger class loader to download correct JAR)
try {
Expand Down
Loading