diff --git a/starrocks-thrift-sdk/build-thrift.sh b/starrocks-thrift-sdk/build-thrift-with-docker.sh
similarity index 92%
rename from starrocks-thrift-sdk/build-thrift.sh
rename to starrocks-thrift-sdk/build-thrift-with-docker.sh
index 99ab3ab56..404783825 100755
--- a/starrocks-thrift-sdk/build-thrift.sh
+++ b/starrocks-thrift-sdk/build-thrift-with-docker.sh
@@ -88,10 +88,10 @@ if [ ! -f "$TP_INSTALL_DIR/bin/thrift" ]; then
fi
cd $TP_INSTALL_DIR/bin/
+TARGET=/starrocks-thrift-sdk/target/generated-sources/thrift
+rm -rf $TARGET
+mkdir -p $TARGET
./thrift -r -gen java $ROOT/../gensrc/StarrocksExternalService.thrift
-if [ ! -d "$ROOT/../src/main/java/com/starrocks/thrift" ]; then
- mkdir -p $ROOT/../src/main/java/com/starrocks/thrift
-fi
-echo $pwd
-cp -r gen-java/com/starrocks/thrift/* $ROOT/../src/main/java/com/starrocks/thrift
+mv gen-java/com $TARGET/
+rm -rf thrift
echo "done..."
\ No newline at end of file
diff --git a/starrocks-thrift-sdk/build-thrift.bat b/starrocks-thrift-sdk/build-thrift.bat
deleted file mode 100644
index c50203c84..000000000
--- a/starrocks-thrift-sdk/build-thrift.bat
+++ /dev/null
@@ -1,28 +0,0 @@
-:: Licensed to the Apache Software Foundation (ASF) under one
-:: or more contributor license agreements. See the NOTICE file
-:: distributed with this work for additional information
-:: regarding copyright ownership. The ASF licenses this file
-:: to you 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.
-
-@echo off
-if not exist thrift md thrift
-cd /d thrift
-if not exist thrift.exe (
- certutil -urlcache -split -f http://dlcdn.apache.org/thrift/0.13.0/thrift-0.13.0.exe thrift.exe
-)
-start thrift.exe -r -gen java %~dp0%\gensrc\StarrocksExternalService.thrift
-cd %~p0%
-if not exist src\main\java\com\starrocks\thrift md src\main\java\com\starrocks\thrift
-pause
-copy thrift\gen-java\com\starrocks\thrift src\main\java\com\starrocks\thrift
-pause
\ No newline at end of file
diff --git a/starrocks-thrift-sdk/generate-sources.sh b/starrocks-thrift-sdk/generate-sources.sh
new file mode 100755
index 000000000..cf95186c2
--- /dev/null
+++ b/starrocks-thrift-sdk/generate-sources.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -eu
+
+cd "${BASH_SOURCE%/*}/.."
+
+# use unstable for Thrift 0.19.0
+docker run -v "${PWD}/starrocks-thrift-sdk:/starrocks-thrift-sdk" --rm debian:unstable /bin/sh -c "\
+set -eux
+apt-get update -q
+apt-get install -q -y wget automake bison flex g++ git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config
+cd /starrocks-thrift-sdk/
+./build-thrift-with-docker.sh
+"
\ No newline at end of file
diff --git a/starrocks-thrift-sdk/pom.xml b/starrocks-thrift-sdk/pom.xml
index 4519c81ad..2b7df81a3 100644
--- a/starrocks-thrift-sdk/pom.xml
+++ b/starrocks-thrift-sdk/pom.xml
@@ -44,6 +44,10 @@ limitations under the License.
com.starrocksstarrocks-thrift-sdk1.0.1
+
+ 11
+ 11
+ org.apache.thrift
@@ -53,6 +57,40 @@ limitations under the License.
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.1.0
+
+
+ generate-sources
+
+ exec
+
+
+ ${basedir}/generate-sources.sh
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.3.0
+
+
+ generate-sources
+
+ add-source
+
+
+
+ ${project.build.directory}/generated-sources/thrift
+
+
+
+
+ org.apache.maven.pluginsmaven-shade-plugin
@@ -108,21 +146,6 @@ limitations under the License.
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- package
-
- jar
-
-
-
-
- ./target/
-
- org.apache.maven.pluginsmaven-source-plugin