You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by yu...@apache.org on 2024/09/13 16:08:51 UTC

(polaris) branch main updated: Add support for external deps for eclipselink (#285)

This is an automated email from the ASF dual-hosted git repository.

yufei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new dec43f25 Add support for external deps for eclipselink (#285)
dec43f25 is described below

commit dec43f25c200a41c33d12f3985bdeab5efbe9d27
Author: MonkeyCanCode <yo...@gmail.com>
AuthorDate: Fri Sep 13 11:08:46 2024 -0500

    Add support for external deps for eclipselink (#285)
---
 README.md                                          |  4 ++++
 extension/persistence/eclipselink/build.gradle.kts | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/README.md b/README.md
index 764e01f9..01683246 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,10 @@ insert into db1.table1 values (1, 'a');
 select * from db1.table1;
 ```
 
+Apache Polaris supports the following optional build options:
+- `-PeclipseLink=true` – Enables the EclipseLink extension.
+- `-PeclipseLinkDeps=[groupId]:[artifactId]:[version],...` – Specifies one or more additional dependencies for EclipseLink (e.g., JDBC drivers), separated by commas.
+
 ### More build and run options
 Running in Docker
 - `docker build -t localhost:5001/polaris:latest .` - To build the image.
diff --git a/extension/persistence/eclipselink/build.gradle.kts b/extension/persistence/eclipselink/build.gradle.kts
index 50b7d41e..5c833321 100644
--- a/extension/persistence/eclipselink/build.gradle.kts
+++ b/extension/persistence/eclipselink/build.gradle.kts
@@ -17,6 +17,11 @@
  * under the License.
  */
 
+fun isValidDep(dep: String): Boolean {
+  val depRegex = "^[\\w.]+:[\\w\\-.]+:[\\w\\-.]+$".toRegex()
+  return dep.matches(depRegex)
+}
+
 plugins {
   id("polaris-server")
   `java-library`
@@ -27,6 +32,19 @@ dependencies {
   implementation(libs.eclipselink)
   implementation(platform(libs.dropwizard.bom))
   implementation("io.dropwizard:dropwizard-jackson")
+  val eclipseLinkDeps: String? = project.findProperty("eclipseLinkDeps") as String?
+  eclipseLinkDeps?.let {
+    val dependenciesList = it.split(",")
+    dependenciesList.forEach { dep ->
+      val trimmedDep = dep.trim()
+      if (isValidDep(trimmedDep)) {
+        implementation(trimmedDep)
+      } else {
+        throw GradleException("Invalid dependency format: $trimmedDep")
+      }
+    }
+  }
+
   compileOnly(libs.jetbrains.annotations)
 
   testImplementation(libs.h2)