Skip to content

Commit da5b229

Browse files
committed
refactor: streamline backend build process and add support for Dameng JDBC driver
- Updated build-backend.sh to use a new script for cloning dependencies. - Introduced clone-build-deps.sh for managing DBeaver and related repositories. - Added patch-dbeaver-dameng.sh to insert Dameng JDBC driver definition into DBeaver's plugin.xml. - Updated plugin.xml to include Dameng driver resources and configurations. - Created pom.xml for Dameng driver to manage dependencies and build process.
1 parent ad2ceed commit da5b229

6 files changed

Lines changed: 138 additions & 11 deletions

File tree

deploy/build-backend.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,8 @@ mkdir ./cloudbeaver/server
1111
mkdir ./cloudbeaver/conf
1212
mkdir ./cloudbeaver/workspace
1313

14-
echo "Pull cloudbeaver platform"
15-
16-
cd ../..
17-
18-
echo "Pull dbeaver platform"
19-
[ ! -d dbeaver ] && git clone --depth 1 https://github.com/dbeaver/dbeaver.git
20-
[ ! -d dbeaver-common ] && git clone --depth 1 https://github.com/dbeaver/dbeaver-common.git
21-
[ ! -d dbeaver-jdbc-libsql ] && git clone --depth 1 https://github.com/dbeaver/dbeaver-jdbc-libsql.git
22-
23-
24-
cd cloudbeaver/deploy
14+
echo "Pull and patch build deps (dbeaver, dbeaver-common, dbeaver-jdbc-libsql)"
15+
./scripts/clone-build-deps.sh
2516

2617
echo "Build CloudBeaver server"
2718

deploy/scripts/clone-build-deps.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# 在本地拉取构建 CloudBeaver 所需的依赖仓库(dbeaver、dbeaver-common、dbeaver-jdbc-libsql)
3+
# 并可选地对 dbeaver 打达梦驱动补丁。
4+
# 应在 cloudbeaver 仓库的上一级目录执行,使 dbeaver 与 cloudbeaver 同级。
5+
set -Eeo pipefail
6+
7+
# 分支/标签,与 server/pom.xml 使用的 DBeaver 版本对应
8+
DBEAVER_BRANCH="${DBEAVER_BRANCH:-release_25_2_1}"
9+
10+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
# deploy/scripts -> deploy -> cloudbeaver;再上一级 = 与 cloudbeaver 同级的目录
12+
CLOUDBEAVER_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
13+
PARENT_DIR="$(dirname "$CLOUDBEAVER_ROOT")"
14+
cd "$PARENT_DIR"
15+
16+
echo "Clone/build deps under: $PARENT_DIR"
17+
echo "DBeaver branch: $DBEAVER_BRANCH"
18+
19+
[ ! -d dbeaver ] && git clone --depth 1 -b "$DBEAVER_BRANCH" https://github.com/dbeaver/dbeaver.git
20+
[ ! -d dbeaver-common ] && git clone --depth 1 -b "$DBEAVER_BRANCH" https://github.com/dbeaver/dbeaver-common.git
21+
[ ! -d dbeaver-jdbc-libsql ] && git clone --depth 1 -b "$DBEAVER_BRANCH" https://github.com/dbeaver/dbeaver-jdbc-libsql.git
22+
23+
# 对 dbeaver 打达梦驱动补丁
24+
"$SCRIPT_DIR/patch-dbeaver-dameng.sh" "$(pwd)/dbeaver"
25+
26+
echo "Clone and patch done. You can run build from cloudbeaver/deploy (e.g. ./build-backend.sh)."
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# 在 DBeaver generic 插件中插入达梦( dameng_jdbc )驱动定义
3+
# 用法: 从 cloudbeaver 仓库根目录的上一级执行;或传入 dbeaver 根目录
4+
set -e
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
if [ -n "$1" ]; then
8+
DBEAVER_ROOT="$1"
9+
else
10+
DBEAVER_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)/../dbeaver"
11+
fi
12+
13+
PLUGIN_XML="${DBEAVER_ROOT}/plugins/org.jkiss.dbeaver.ext.generic/plugin.xml"
14+
if [ ! -f "$PLUGIN_XML" ]; then
15+
echo "DBeaver plugin.xml not found: $PLUGIN_XML"
16+
echo "Usage: $0 [dbeaver_root]"
17+
exit 1
18+
fi
19+
20+
if grep -q 'id="dameng_jdbc"' "$PLUGIN_XML"; then
21+
echo "Dameng driver already present in DBeaver plugin.xml, skip patch."
22+
exit 0
23+
fi
24+
25+
python3 - "$PLUGIN_XML" << 'PY'
26+
import sys
27+
path = sys.argv[1]
28+
# 在 <!-- CUBRID --> 前插入达梦驱动(兼容不同缩进)
29+
marker = "<!-- CUBRID -->"
30+
driver_block = ''' <driver
31+
id="dameng_jdbc"
32+
label="达梦(DM)"
33+
class="dm.jdbc.driver.DmDriver"
34+
sampleURL="jdbc:dm://{host}[:{port}]/[{database}]"
35+
defaultPort="5236"
36+
defaultDatabase="SYSDBA"
37+
defaultUser="SYSDBA"
38+
description="达梦数据库 JDBC 驱动"
39+
supportedConfigurationTypes="MANUAL,URL"
40+
categories="sql">
41+
<file type="jar" path="drivers/dameng" bundle="drivers.dameng"/>
42+
</driver>
43+
44+
<!-- CUBRID -->'''
45+
46+
with open(path, "r", encoding="utf-8", errors="replace") as f:
47+
content = f.read()
48+
if marker not in content:
49+
sys.exit("Marker <!-- CUBRID --> not found in plugin.xml")
50+
# 只替换第一次出现,保留该行原有前导空白
51+
new_content = content.replace(marker, driver_block, 1)
52+
with open(path, "w", encoding="utf-8") as f:
53+
f.write(new_content)
54+
print("Patched DBeaver plugin.xml: added dameng_jdbc driver.")
55+
PY
56+
57+
echo "Done."

server/bundles/io.cloudbeaver.resources.drivers.base/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<resource name="drivers/trino"/>
2222
<resource name="drivers/kyuubi"/>
2323
<resource name="drivers/databend"/>
24+
<resource name="drivers/dameng"/>
2425
</extension>
2526

2627
<!-- Bundles -->
@@ -44,6 +45,7 @@
4445
<bundle id="drivers.trino" label="Trino drivers"/>
4546
<bundle id="drivers.kyuubi" label="Apache Kyuubi drivers"/>
4647
<bundle id="drivers.databend" label="Databend drivers"/>
48+
<bundle id="drivers.dameng" label="达梦(DM) drivers"/>
4749
</extension>
4850

4951
<!-- Enabled drivers -->
@@ -68,6 +70,7 @@
6870
<driver id="generic:duckdb_jdbc"/>
6971
<driver id="generic:kyuubi_hive"/>
7072
<driver id="databend:databend"/>
73+
<driver id="generic:dameng_jdbc"/>
7174
</extension>
7275

7376

server/drivers/dameng/pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<artifactId>drivers.dameng</artifactId>
6+
<version>1.0.0</version>
7+
<parent>
8+
<groupId>io.cloudbeaver</groupId>
9+
<artifactId>drivers</artifactId>
10+
<version>1.0.0</version>
11+
<relativePath>../</relativePath>
12+
</parent>
13+
14+
<properties>
15+
<deps.output.dir>dameng</deps.output.dir>
16+
</properties>
17+
18+
<build>
19+
<plugins>
20+
<plugin>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-resources-plugin</artifactId>
23+
<version>2.6</version>
24+
<executions>
25+
<execution>
26+
<id>copy-dameng-jar</id>
27+
<phase>validate</phase>
28+
<configuration>
29+
<outputDirectory>../../../deploy/drivers/dameng</outputDirectory>
30+
<overwrite>true</overwrite>
31+
<resources>
32+
<resource>
33+
<directory>lib</directory>
34+
<includes>
35+
<include>*.jar</include>
36+
</includes>
37+
</resource>
38+
</resources>
39+
</configuration>
40+
<goals>
41+
<goal>copy-resources</goal>
42+
</goals>
43+
</execution>
44+
</executions>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
49+
</project>

server/drivers/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<modules>
1919
<module>clickhouse_com</module>
2020
<module>databend</module>
21+
<module>dameng</module>
2122
<module>db2</module>
2223
<module>db2-jt400</module>
2324
<module>duckdb</module>

0 commit comments

Comments
 (0)