From 0269ea1d567cf305bee62ef88f7ecac29abed827 Mon Sep 17 00:00:00 2001 From: kyotom Date: Sat, 12 Oct 2024 14:53:03 +0800 Subject: [PATCH] [Enhancement] build starrocks-thrift-sdk with docker Signed-off-by: kyotom --- ...-thrift.sh => build-thrift-with-docker.sh} | 10 ++-- starrocks-thrift-sdk/build-thrift.bat | 28 ----------- starrocks-thrift-sdk/generate-sources.sh | 14 ++++++ starrocks-thrift-sdk/pom.xml | 49 +++++++++++++------ 4 files changed, 53 insertions(+), 48 deletions(-) rename starrocks-thrift-sdk/{build-thrift.sh => build-thrift-with-docker.sh} (92%) delete mode 100644 starrocks-thrift-sdk/build-thrift.bat create mode 100755 starrocks-thrift-sdk/generate-sources.sh 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 99ab3ab5..40478382 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 c50203c8..00000000 --- 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 00000000..cf95186c --- /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 4519c81a..4e6e7e6a 100644 --- a/starrocks-thrift-sdk/pom.xml +++ b/starrocks-thrift-sdk/pom.xml @@ -53,6 +53,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.plugins maven-shade-plugin @@ -108,21 +142,6 @@ limitations under the License. - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - - - ./target/ - - org.apache.maven.plugins maven-source-plugin